]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-conf.c
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 "alloc-util.h"
23 #include "conf-parser.h"
25 #include "extract-word.h"
26 #include "parse-util.h"
27 #include "resolved-conf.h"
28 #include "string-util.h"
30 int manager_parse_dns_server(Manager
*m
, DnsServerType type
, const char *string
) {
37 first
= type
== DNS_SERVER_FALLBACK
? m
->fallback_dns_servers
: m
->dns_servers
;
40 _cleanup_free_
char *word
= NULL
;
41 union in_addr_union addr
;
46 r
= extract_first_word(&string
, &word
, NULL
, 0);
48 return log_error_errno(r
, "Failed to parse resolved dns server syntax \"%s\": %m", string
);
52 r
= in_addr_from_string_auto(word
, &family
, &addr
);
54 log_warning("Ignoring invalid DNS address '%s'", word
);
58 /* Filter out duplicates */
59 LIST_FOREACH(servers
, s
, first
)
60 if (s
->family
== family
&& in_addr_equal(family
, &s
->address
, &addr
)) {
68 r
= dns_server_new(m
, NULL
, type
, NULL
, family
, &addr
);
76 int config_parse_dnsv(
81 unsigned section_line
,
88 Manager
*m
= userdata
;
97 /* Empty assignment means clear the list */
98 manager_flush_dns_servers(m
, ltype
);
100 /* Otherwise, add to the list */
101 r
= manager_parse_dns_server(m
, ltype
, rvalue
);
103 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse DNS server string '%s'. Ignoring.", rvalue
);
108 /* If we have a manual setting, then we stop reading
109 * /etc/resolv.conf */
110 if (ltype
== DNS_SERVER_SYSTEM
)
111 m
->read_resolv_conf
= false;
116 int config_parse_support(
118 const char *filename
,
121 unsigned section_line
,
128 Support support
, *v
= data
;
135 support
= support_from_string(rvalue
);
137 r
= parse_boolean(rvalue
);
139 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse support level '%s'. Ignoring.", rvalue
);
143 support
= r
? SUPPORT_YES
: SUPPORT_NO
;
150 int manager_parse_config_file(Manager
*m
) {
153 return config_parse_many("/etc/systemd/resolved.conf",
154 CONF_DIRS_NULSTR("systemd/resolved.conf"),
156 config_item_perf_lookup
, resolved_gperf_lookup
,