resolved-conf.c revision b938cb902c3b5bca807a94b277672c64d6767886
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen This file is part of systemd.
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen Copyright 2014 Tom Gundersen <teg@jklm.no>
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen systemd is free software; you can redistribute it and/or modify it
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen under the terms of the GNU Lesser General Public License as published by
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen (at your option) any later version.
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen systemd is distributed in the hope that it will be useful, but
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen Lesser General Public License for more details.
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen You should have received a copy of the GNU Lesser General Public License
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersenint manager_parse_dns_server(Manager *m, DnsServerType type, const char *string) {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen first = type == DNS_SERVER_FALLBACK ? m->fallback_dns_servers : m->dns_servers;
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen bool found = false;
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen r = extract_first_word(&string, &word, NULL, 0);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen return log_error_errno(r, "Failed to parse resolved dns server syntax \"%s\": %m", string);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen r = in_addr_from_string_auto(word, &family, &addr);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen log_warning("Ignoring invalid DNS address '%s'", word);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen /* Filter out duplicates */
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen if (s->family == family && in_addr_equal(family, &s->address, &addr)) {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen r = dns_server_new(m, NULL, type, NULL, family, &addr);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen /* Empty assignment means clear the list */
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen /* Otherwise, add to the list */
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen r = manager_parse_dns_server(m, ltype, rvalue);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse DNS server string '%s'. Ignoring.", rvalue);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen /* If we have a manual setting, then we stop reading
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse support level '%s'. Ignoring.", rvalue);