1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2014 Tom Gundersen <teg@jklm.no>
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include "conf-parser.h"
24 #include "resolved-conf.h"
26 int manager_parse_dns_server(Manager *m, DnsServerType type, const char *string) {
27 const char *word, *state;
35 first = type == DNS_SERVER_FALLBACK ? m->fallback_dns_servers : m->dns_servers;
37 FOREACH_WORD_QUOTED(word, length, string, state) {
38 char buffer[length+1];
40 union in_addr_union addr;
44 memcpy(buffer, word, length);
47 r = in_addr_from_string_auto(buffer, &family, &addr);
49 log_warning("Ignoring invalid DNS address '%s'", buffer);
53 /* Filter out duplicates */
54 LIST_FOREACH(servers, s, first)
55 if (s->family == family && in_addr_equal(family, &s->address, &addr)) {
63 r = dns_server_new(m, NULL, type, NULL, family, &addr);
71 int config_parse_dnsv(
76 unsigned section_line,
83 Manager *m = userdata;
92 if (ltype == DNS_SERVER_FALLBACK)
93 l = &m->fallback_dns_servers;
97 if (isempty(rvalue)) {
99 /* Empty assignment means clear the list */
105 /* Otherwise add to the list */
106 r = manager_parse_dns_server(m, ltype, rvalue);
108 log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to parse DNS server string '%s'. Ignoring.", rvalue);
113 /* If we have a manual setting, then we stop reading
114 * /etc/resolv.conf */
115 if (ltype == DNS_SERVER_SYSTEM)
116 m->read_resolv_conf = false;
121 int config_parse_support(
123 const char *filename,
126 unsigned section_line,
133 Manager *m = userdata;
134 Support support, *v = data;
142 support = support_from_string(rvalue);
144 r = parse_boolean(rvalue);
146 log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to parse support level '%s'. Ignoring.", rvalue);
150 support = r ? SUPPORT_YES : SUPPORT_NO;
157 int manager_parse_config_file(Manager *m) {
160 return config_parse(NULL, "/etc/systemd/resolved.conf", NULL,
162 config_item_perf_lookup, resolved_gperf_lookup,
163 false, false, true, m);