| File: | build-scan/../src/resolve/resolved-conf.c |
| Warning: | line 315, column 32 Potential leak of memory pointed to by 'txt_data' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ | |||
| 2 | ||||
| 3 | #include "alloc-util.h" | |||
| 4 | #include "conf-parser.h" | |||
| 5 | #include "def.h" | |||
| 6 | #include "extract-word.h" | |||
| 7 | #include "hexdecoct.h" | |||
| 8 | #include "parse-util.h" | |||
| 9 | #include "resolved-conf.h" | |||
| 10 | #include "resolved-dnssd.h" | |||
| 11 | #include "specifier.h" | |||
| 12 | #include "string-table.h" | |||
| 13 | #include "string-util.h" | |||
| 14 | #include "utf8.h" | |||
| 15 | ||||
| 16 | DEFINE_CONFIG_PARSE_ENUM(config_parse_dns_stub_listener_mode, dns_stub_listener_mode, DnsStubListenerMode, "Failed to parse DNS stub listener mode setting")int config_parse_dns_stub_listener_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue , void *data, void *userdata) { DnsStubListenerMode *i = data , x; do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/resolve/resolved-conf.c" , 16, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("lvalue"), "../src/resolve/resolved-conf.c", 16, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rvalue"), "../src/resolve/resolved-conf.c" , 16, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/resolve/resolved-conf.c", 16, __PRETTY_FUNCTION__ ); } while (0); x = dns_stub_listener_mode_from_string(rvalue ); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/resolve/resolved-conf.c" , 16, __func__, "Failed to parse DNS stub listener mode setting" ", ignoring: %s", rvalue) : -abs(_e); }); return 0; } *i = x ; return 0; }; | |||
| 17 | ||||
| 18 | static const char* const dns_stub_listener_mode_table[_DNS_STUB_LISTENER_MODE_MAX] = { | |||
| 19 | [DNS_STUB_LISTENER_NO] = "no", | |||
| 20 | [DNS_STUB_LISTENER_UDP] = "udp", | |||
| 21 | [DNS_STUB_LISTENER_TCP] = "tcp", | |||
| 22 | [DNS_STUB_LISTENER_YES] = "yes", | |||
| 23 | }; | |||
| 24 | DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(dns_stub_listener_mode, DnsStubListenerMode, DNS_STUB_LISTENER_YES)const char *dns_stub_listener_mode_to_string(DnsStubListenerMode i) { if (i < 0 || i >= (DnsStubListenerMode) __extension__ (__builtin_choose_expr( !__builtin_types_compatible_p(typeof (dns_stub_listener_mode_table), typeof(&*(dns_stub_listener_mode_table ))), sizeof(dns_stub_listener_mode_table)/sizeof((dns_stub_listener_mode_table )[0]), ((void)0)))) return ((void*)0); return dns_stub_listener_mode_table [i]; } DnsStubListenerMode dns_stub_listener_mode_from_string (const char *s) { int b; if (!s) return -1; b = parse_boolean (s); if (b == 0) return (DnsStubListenerMode) 0; else if (b > 0) return DNS_STUB_LISTENER_YES; return (DnsStubListenerMode ) string_table_lookup(dns_stub_listener_mode_table, __extension__ (__builtin_choose_expr( !__builtin_types_compatible_p(typeof (dns_stub_listener_mode_table), typeof(&*(dns_stub_listener_mode_table ))), sizeof(dns_stub_listener_mode_table)/sizeof((dns_stub_listener_mode_table )[0]), ((void)0))), s); }; | |||
| 25 | ||||
| 26 | int manager_add_dns_server_by_string(Manager *m, DnsServerType type, const char *word) { | |||
| 27 | union in_addr_union address; | |||
| 28 | int family, r, ifindex = 0; | |||
| 29 | DnsServer *s; | |||
| 30 | ||||
| 31 | assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("m"), "../src/resolve/resolved-conf.c", 31 , __PRETTY_FUNCTION__); } while (0); | |||
| 32 | assert(word)do { if ((__builtin_expect(!!(!(word)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("word"), "../src/resolve/resolved-conf.c" , 32, __PRETTY_FUNCTION__); } while (0); | |||
| 33 | ||||
| 34 | r = in_addr_ifindex_from_string_auto(word, &family, &address, &ifindex); | |||
| 35 | if (r < 0) | |||
| 36 | return r; | |||
| 37 | ||||
| 38 | /* Silently filter out 0.0.0.0 and 127.0.0.53 (our own stub DNS listener) */ | |||
| 39 | if (!dns_server_address_valid(family, &address)) | |||
| 40 | return 0; | |||
| 41 | ||||
| 42 | /* Filter out duplicates */ | |||
| 43 | s = dns_server_find(manager_get_first_dns_server(m, type), family, &address, ifindex); | |||
| 44 | if (s) { | |||
| 45 | /* | |||
| 46 | * Drop the marker. This is used to find the servers | |||
| 47 | * that ceased to exist, see | |||
| 48 | * manager_mark_dns_servers() and | |||
| 49 | * manager_flush_marked_dns_servers(). | |||
| 50 | */ | |||
| 51 | dns_server_move_back_and_unmark(s); | |||
| 52 | return 0; | |||
| 53 | } | |||
| 54 | ||||
| 55 | return dns_server_new(m, NULL((void*)0), type, NULL((void*)0), family, &address, ifindex); | |||
| 56 | } | |||
| 57 | ||||
| 58 | int manager_parse_dns_server_string_and_warn(Manager *m, DnsServerType type, const char *string) { | |||
| 59 | int r; | |||
| 60 | ||||
| 61 | assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("m"), "../src/resolve/resolved-conf.c", 61 , __PRETTY_FUNCTION__); } while (0); | |||
| 62 | assert(string)do { if ((__builtin_expect(!!(!(string)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("string"), "../src/resolve/resolved-conf.c" , 62, __PRETTY_FUNCTION__); } while (0); | |||
| 63 | ||||
| 64 | for (;;) { | |||
| 65 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0); | |||
| 66 | ||||
| 67 | r = extract_first_word(&string, &word, NULL((void*)0), 0); | |||
| 68 | if (r < 0) | |||
| 69 | return r; | |||
| 70 | if (r == 0) | |||
| 71 | break; | |||
| 72 | ||||
| 73 | r = manager_add_dns_server_by_string(m, type, word); | |||
| 74 | if (r < 0) | |||
| 75 | log_warning_errno(r, "Failed to add DNS server address '%s', ignoring: %m", word)({ int _level = ((4)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/resolve/resolved-conf.c", 75, __func__, "Failed to add DNS server address '%s', ignoring: %m" , word) : -abs(_e); }); | |||
| 76 | } | |||
| 77 | ||||
| 78 | return 0; | |||
| 79 | } | |||
| 80 | ||||
| 81 | int manager_add_search_domain_by_string(Manager *m, const char *domain) { | |||
| 82 | DnsSearchDomain *d; | |||
| 83 | bool_Bool route_only; | |||
| 84 | int r; | |||
| 85 | ||||
| 86 | assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("m"), "../src/resolve/resolved-conf.c", 86 , __PRETTY_FUNCTION__); } while (0); | |||
| 87 | assert(domain)do { if ((__builtin_expect(!!(!(domain)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("domain"), "../src/resolve/resolved-conf.c" , 87, __PRETTY_FUNCTION__); } while (0); | |||
| 88 | ||||
| 89 | route_only = *domain == '~'; | |||
| 90 | if (route_only) | |||
| 91 | domain++; | |||
| 92 | ||||
| 93 | if (dns_name_is_root(domain) || streq(domain, "*")(strcmp((domain),("*")) == 0)) { | |||
| 94 | route_only = true1; | |||
| 95 | domain = "."; | |||
| 96 | } | |||
| 97 | ||||
| 98 | r = dns_search_domain_find(m->search_domains, domain, &d); | |||
| 99 | if (r < 0) | |||
| 100 | return r; | |||
| 101 | if (r > 0) | |||
| 102 | dns_search_domain_move_back_and_unmark(d); | |||
| 103 | else { | |||
| 104 | r = dns_search_domain_new(m, &d, DNS_SEARCH_DOMAIN_SYSTEM, NULL((void*)0), domain); | |||
| 105 | if (r < 0) | |||
| 106 | return r; | |||
| 107 | } | |||
| 108 | ||||
| 109 | d->route_only = route_only; | |||
| 110 | return 0; | |||
| 111 | } | |||
| 112 | ||||
| 113 | int manager_parse_search_domains_and_warn(Manager *m, const char *string) { | |||
| 114 | int r; | |||
| 115 | ||||
| 116 | assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("m"), "../src/resolve/resolved-conf.c", 116 , __PRETTY_FUNCTION__); } while (0); | |||
| 117 | assert(string)do { if ((__builtin_expect(!!(!(string)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("string"), "../src/resolve/resolved-conf.c" , 117, __PRETTY_FUNCTION__); } while (0); | |||
| 118 | ||||
| 119 | for (;;) { | |||
| 120 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0); | |||
| 121 | ||||
| 122 | r = extract_first_word(&string, &word, NULL((void*)0), EXTRACT_QUOTES); | |||
| 123 | if (r < 0) | |||
| 124 | return r; | |||
| 125 | if (r == 0) | |||
| 126 | break; | |||
| 127 | ||||
| 128 | r = manager_add_search_domain_by_string(m, word); | |||
| 129 | if (r < 0) | |||
| 130 | log_warning_errno(r, "Failed to add search domain '%s', ignoring: %m", word)({ int _level = ((4)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/resolve/resolved-conf.c", 130, __func__, "Failed to add search domain '%s', ignoring: %m" , word) : -abs(_e); }); | |||
| 131 | } | |||
| 132 | ||||
| 133 | return 0; | |||
| 134 | } | |||
| 135 | ||||
| 136 | int config_parse_dns_servers( | |||
| 137 | const char *unit, | |||
| 138 | const char *filename, | |||
| 139 | unsigned line, | |||
| 140 | const char *section, | |||
| 141 | unsigned section_line, | |||
| 142 | const char *lvalue, | |||
| 143 | int ltype, | |||
| 144 | const char *rvalue, | |||
| 145 | void *data, | |||
| 146 | void *userdata) { | |||
| 147 | ||||
| 148 | Manager *m = userdata; | |||
| 149 | int r; | |||
| 150 | ||||
| 151 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/resolve/resolved-conf.c" , 151, __PRETTY_FUNCTION__); } while (0); | |||
| 152 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/resolve/resolved-conf.c" , 152, __PRETTY_FUNCTION__); } while (0); | |||
| 153 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/resolve/resolved-conf.c" , 153, __PRETTY_FUNCTION__); } while (0); | |||
| 154 | assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("m"), "../src/resolve/resolved-conf.c", 154 , __PRETTY_FUNCTION__); } while (0); | |||
| 155 | ||||
| 156 | if (isempty(rvalue)) | |||
| 157 | /* Empty assignment means clear the list */ | |||
| 158 | dns_server_unlink_all(manager_get_first_dns_server(m, ltype)); | |||
| 159 | else { | |||
| 160 | /* Otherwise, add to the list */ | |||
| 161 | r = manager_parse_dns_server_string_and_warn(m, ltype, rvalue); | |||
| 162 | if (r < 0) { | |||
| 163 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse DNS server string '%s'. Ignoring.", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/resolve/resolved-conf.c", 163, __func__ , "Failed to parse DNS server string '%s'. Ignoring.", rvalue ) : -abs(_e); }); | |||
| 164 | return 0; | |||
| 165 | } | |||
| 166 | } | |||
| 167 | ||||
| 168 | /* If we have a manual setting, then we stop reading | |||
| 169 | * /etc/resolv.conf */ | |||
| 170 | if (ltype == DNS_SERVER_SYSTEM) | |||
| 171 | m->read_resolv_conf = false0; | |||
| 172 | if (ltype == DNS_SERVER_FALLBACK) | |||
| 173 | m->need_builtin_fallbacks = false0; | |||
| 174 | ||||
| 175 | return 0; | |||
| 176 | } | |||
| 177 | ||||
| 178 | int config_parse_search_domains( | |||
| 179 | const char *unit, | |||
| 180 | const char *filename, | |||
| 181 | unsigned line, | |||
| 182 | const char *section, | |||
| 183 | unsigned section_line, | |||
| 184 | const char *lvalue, | |||
| 185 | int ltype, | |||
| 186 | const char *rvalue, | |||
| 187 | void *data, | |||
| 188 | void *userdata) { | |||
| 189 | ||||
| 190 | Manager *m = userdata; | |||
| 191 | int r; | |||
| 192 | ||||
| 193 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/resolve/resolved-conf.c" , 193, __PRETTY_FUNCTION__); } while (0); | |||
| 194 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/resolve/resolved-conf.c" , 194, __PRETTY_FUNCTION__); } while (0); | |||
| 195 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/resolve/resolved-conf.c" , 195, __PRETTY_FUNCTION__); } while (0); | |||
| 196 | assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("m"), "../src/resolve/resolved-conf.c", 196 , __PRETTY_FUNCTION__); } while (0); | |||
| 197 | ||||
| 198 | if (isempty(rvalue)) | |||
| 199 | /* Empty assignment means clear the list */ | |||
| 200 | dns_search_domain_unlink_all(m->search_domains); | |||
| 201 | else { | |||
| 202 | /* Otherwise, add to the list */ | |||
| 203 | r = manager_parse_search_domains_and_warn(m, rvalue); | |||
| 204 | if (r < 0) { | |||
| 205 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse search domains string '%s'. Ignoring.", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/resolve/resolved-conf.c", 205, __func__ , "Failed to parse search domains string '%s'. Ignoring.", rvalue ) : -abs(_e); }); | |||
| 206 | return 0; | |||
| 207 | } | |||
| 208 | } | |||
| 209 | ||||
| 210 | /* If we have a manual setting, then we stop reading | |||
| 211 | * /etc/resolv.conf */ | |||
| 212 | m->read_resolv_conf = false0; | |||
| 213 | ||||
| 214 | return 0; | |||
| 215 | } | |||
| 216 | ||||
| 217 | int config_parse_dnssd_service_name(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { | |||
| 218 | static const Specifier specifier_table[] = { | |||
| 219 | { 'b', specifier_boot_id, NULL((void*)0) }, | |||
| 220 | { 'H', specifier_host_name, NULL((void*)0) }, | |||
| 221 | { 'm', specifier_machine_id, NULL((void*)0) }, | |||
| 222 | { 'v', specifier_kernel_release, NULL((void*)0) }, | |||
| 223 | {} | |||
| 224 | }; | |||
| 225 | DnssdService *s = userdata; | |||
| 226 | _cleanup_free___attribute__((cleanup(freep))) char *name = NULL((void*)0); | |||
| 227 | int r; | |||
| 228 | ||||
| 229 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/resolve/resolved-conf.c" , 229, __PRETTY_FUNCTION__); } while (0); | |||
| 230 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/resolve/resolved-conf.c" , 230, __PRETTY_FUNCTION__); } while (0); | |||
| 231 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/resolve/resolved-conf.c" , 231, __PRETTY_FUNCTION__); } while (0); | |||
| 232 | assert(s)do { if ((__builtin_expect(!!(!(s)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("s"), "../src/resolve/resolved-conf.c", 232 , __PRETTY_FUNCTION__); } while (0); | |||
| 233 | ||||
| 234 | if (isempty(rvalue)) { | |||
| 235 | log_syntax(unit, LOG_ERR, filename, line, 0, "Service instance name can't be empty. Ignoring.")({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/resolve/resolved-conf.c", 235, __func__ , "Service instance name can't be empty. Ignoring.") : -abs(_e ); }); | |||
| 236 | return -EINVAL22; | |||
| 237 | } | |||
| 238 | ||||
| 239 | r = free_and_strdup(&s->name_template, rvalue); | |||
| 240 | if (r < 0) | |||
| 241 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/resolve/resolved-conf.c" , 241, __func__); | |||
| 242 | ||||
| 243 | r = specifier_printf(s->name_template, specifier_table, NULL((void*)0), &name); | |||
| 244 | if (r < 0) | |||
| 245 | return log_debug_errno(r, "Failed to replace specifiers: %m")({ int _level = ((7)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/resolve/resolved-conf.c", 245, __func__, "Failed to replace specifiers: %m" ) : -abs(_e); }); | |||
| 246 | ||||
| 247 | if (!dns_service_name_is_valid(name)) { | |||
| 248 | log_syntax(unit, LOG_ERR, filename, line, 0, "Service instance name template renders to invalid name '%s'. Ignoring.", name)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/resolve/resolved-conf.c", 248, __func__ , "Service instance name template renders to invalid name '%s'. Ignoring." , name) : -abs(_e); }); | |||
| 249 | return -EINVAL22; | |||
| 250 | } | |||
| 251 | ||||
| 252 | return 0; | |||
| 253 | } | |||
| 254 | ||||
| 255 | int config_parse_dnssd_service_type(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { | |||
| 256 | DnssdService *s = userdata; | |||
| 257 | int r; | |||
| 258 | ||||
| 259 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/resolve/resolved-conf.c" , 259, __PRETTY_FUNCTION__); } while (0); | |||
| 260 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/resolve/resolved-conf.c" , 260, __PRETTY_FUNCTION__); } while (0); | |||
| 261 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/resolve/resolved-conf.c" , 261, __PRETTY_FUNCTION__); } while (0); | |||
| 262 | assert(s)do { if ((__builtin_expect(!!(!(s)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("s"), "../src/resolve/resolved-conf.c", 262 , __PRETTY_FUNCTION__); } while (0); | |||
| 263 | ||||
| 264 | if (isempty(rvalue)) { | |||
| 265 | log_syntax(unit, LOG_ERR, filename, line, 0, "Service type can't be empty. Ignoring.")({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/resolve/resolved-conf.c", 265, __func__ , "Service type can't be empty. Ignoring.") : -abs(_e); }); | |||
| 266 | return -EINVAL22; | |||
| 267 | } | |||
| 268 | ||||
| 269 | if (!dnssd_srv_type_is_valid(rvalue)) { | |||
| 270 | log_syntax(unit, LOG_ERR, filename, line, 0, "Service type is invalid. Ignoring.")({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/resolve/resolved-conf.c", 270, __func__ , "Service type is invalid. Ignoring.") : -abs(_e); }); | |||
| 271 | return -EINVAL22; | |||
| 272 | } | |||
| 273 | ||||
| 274 | r = free_and_strdup(&s->type, rvalue); | |||
| 275 | if (r < 0) | |||
| 276 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/resolve/resolved-conf.c" , 276, __func__); | |||
| 277 | ||||
| 278 | return 0; | |||
| 279 | } | |||
| 280 | ||||
| 281 | int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { | |||
| 282 | _cleanup_(dnssd_txtdata_freep)__attribute__((cleanup(dnssd_txtdata_freep))) DnssdTxtData *txt_data = NULL((void*)0); | |||
| 283 | DnssdService *s = userdata; | |||
| 284 | DnsTxtItem *last = NULL((void*)0); | |||
| 285 | ||||
| 286 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/resolve/resolved-conf.c" , 286, __PRETTY_FUNCTION__); } while (0); | |||
| ||||
| 287 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/resolve/resolved-conf.c" , 287, __PRETTY_FUNCTION__); } while (0); | |||
| 288 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/resolve/resolved-conf.c" , 288, __PRETTY_FUNCTION__); } while (0); | |||
| 289 | assert(s)do { if ((__builtin_expect(!!(!(s)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("s"), "../src/resolve/resolved-conf.c", 289 , __PRETTY_FUNCTION__); } while (0); | |||
| 290 | ||||
| 291 | if (isempty(rvalue)) { | |||
| 292 | /* Flush out collected items */ | |||
| 293 | s->txt_data_items = dnssd_txtdata_free_all(s->txt_data_items); | |||
| 294 | return 0; | |||
| 295 | } | |||
| 296 | ||||
| 297 | txt_data = new0(DnssdTxtData, 1)((DnssdTxtData*) calloc((1), sizeof(DnssdTxtData))); | |||
| 298 | if (!txt_data) | |||
| 299 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/resolve/resolved-conf.c" , 299, __func__); | |||
| 300 | ||||
| 301 | for (;;) { | |||
| 302 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0); | |||
| 303 | _cleanup_free___attribute__((cleanup(freep))) char *key = NULL((void*)0); | |||
| 304 | _cleanup_free___attribute__((cleanup(freep))) char *value = NULL((void*)0); | |||
| 305 | _cleanup_free___attribute__((cleanup(freep))) void *decoded = NULL((void*)0); | |||
| 306 | size_t length = 0; | |||
| 307 | DnsTxtItem *i; | |||
| 308 | int r; | |||
| 309 | ||||
| 310 | r = extract_first_word(&rvalue, &word, NULL((void*)0), | |||
| 311 | EXTRACT_QUOTES|EXTRACT_CUNESCAPE|EXTRACT_CUNESCAPE_RELAX); | |||
| 312 | if (r == 0) | |||
| 313 | break; | |||
| 314 | if (r == -ENOMEM12) | |||
| 315 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/resolve/resolved-conf.c" , 315, __func__); | |||
| ||||
| 316 | if (r < 0) | |||
| 317 | return log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/resolve/resolved-conf.c", 317, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
| 318 | ||||
| 319 | r = split_pair(word, "=", &key, &value); | |||
| 320 | if (r == -ENOMEM12) | |||
| 321 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/resolve/resolved-conf.c" , 321, __func__); | |||
| 322 | if (r == -EINVAL22) | |||
| 323 | key = TAKE_PTR(word)({ typeof(word) _ptr_ = (word); (word) = ((void*)0); _ptr_; } ); | |||
| 324 | ||||
| 325 | if (!ascii_is_valid(key)) { | |||
| 326 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid syntax, ignoring: %s", key)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/resolve/resolved-conf.c", 326, __func__ , "Invalid syntax, ignoring: %s", key) : -abs(_e); }); | |||
| 327 | return -EINVAL22; | |||
| 328 | } | |||
| 329 | ||||
| 330 | switch (ltype) { | |||
| 331 | ||||
| 332 | case DNS_TXT_ITEM_DATA: | |||
| 333 | if (value) { | |||
| 334 | r = unbase64mem(value, strlen(value), &decoded, &length); | |||
| 335 | if (r == -ENOMEM12) | |||
| 336 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/resolve/resolved-conf.c" , 336, __func__); | |||
| 337 | if (r < 0) | |||
| 338 | return log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/resolve/resolved-conf.c", 339, __func__ , "Invalid base64 encoding, ignoring: %s", value) : -abs(_e); }) | |||
| 339 | "Invalid base64 encoding, ignoring: %s", value)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/resolve/resolved-conf.c", 339, __func__ , "Invalid base64 encoding, ignoring: %s", value) : -abs(_e); }); | |||
| 340 | } | |||
| 341 | ||||
| 342 | r = dnssd_txt_item_new_from_data(key, decoded, length, &i); | |||
| 343 | if (r < 0) | |||
| 344 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/resolve/resolved-conf.c" , 344, __func__); | |||
| 345 | break; | |||
| 346 | ||||
| 347 | case DNS_TXT_ITEM_TEXT: | |||
| 348 | r = dnssd_txt_item_new_from_string(key, value, &i); | |||
| 349 | if (r < 0) | |||
| 350 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/resolve/resolved-conf.c" , 350, __func__); | |||
| 351 | break; | |||
| 352 | ||||
| 353 | default: | |||
| 354 | assert_not_reached("Unknown type of Txt config")do { log_assert_failed_unreachable_realm(LOG_REALM_SYSTEMD, ( "Unknown type of Txt config"), "../src/resolve/resolved-conf.c" , 354, __PRETTY_FUNCTION__); } while (0); | |||
| 355 | } | |||
| 356 | ||||
| 357 | LIST_INSERT_AFTER(items, txt_data->txt, last, i)do { typeof(*(txt_data->txt)) **_head = &(txt_data-> txt), *_a = (last), *_b = (i); do { if ((__builtin_expect(!!( !(_b)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("_b") , "../src/resolve/resolved-conf.c", 357, __PRETTY_FUNCTION__) ; } while (0); if (!_a) { if ((_b->items_next = *_head)) _b ->items_next->items_prev = _b; _b->items_prev = ((void *)0); *_head = _b; } else { if ((_b->items_next = _a->items_next )) _b->items_next->items_prev = _b; _b->items_prev = _a; _a->items_next = _b; } } while (0); | |||
| 358 | last = i; | |||
| 359 | } | |||
| 360 | ||||
| 361 | if (!LIST_IS_EMPTY(txt_data->txt)(!(txt_data->txt))) { | |||
| 362 | LIST_PREPEND(items, s->txt_data_items, txt_data)do { typeof(*(s->txt_data_items)) **_head = &(s->txt_data_items ), *_item = (txt_data); do { if ((__builtin_expect(!!(!(_item )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("_item"), "../src/resolve/resolved-conf.c", 362, __PRETTY_FUNCTION__); } while (0); if ((_item->items_next = *_head)) _item-> items_next->items_prev = _item; _item->items_prev = ((void *)0); *_head = _item; } while (0); | |||
| 363 | txt_data = NULL((void*)0); | |||
| 364 | } | |||
| 365 | ||||
| 366 | return 0; | |||
| 367 | } | |||
| 368 | ||||
| 369 | int manager_parse_config_file(Manager *m) { | |||
| 370 | int r; | |||
| 371 | ||||
| 372 | assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("m"), "../src/resolve/resolved-conf.c", 372 , __PRETTY_FUNCTION__); } while (0); | |||
| 373 | ||||
| 374 | r = config_parse_many_nulstr(PKGSYSCONFDIR"/etc/systemd" "/resolved.conf", | |||
| 375 | CONF_PATHS_NULSTR("systemd/resolved.conf.d")"/etc/" "systemd/resolved.conf.d" "\0" "/run/" "systemd/resolved.conf.d" "\0" "/usr/local/lib/" "systemd/resolved.conf.d" "\0" "/usr/lib/" "systemd/resolved.conf.d" "\0", | |||
| 376 | "Resolve\0", | |||
| 377 | config_item_perf_lookup, resolved_gperf_lookup, | |||
| 378 | CONFIG_PARSE_WARN, m); | |||
| 379 | if (r < 0) | |||
| 380 | return r; | |||
| 381 | ||||
| 382 | if (m->need_builtin_fallbacks) { | |||
| 383 | r = manager_parse_dns_server_string_and_warn(m, DNS_SERVER_FALLBACK, DNS_SERVERS"8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844"); | |||
| 384 | if (r < 0) | |||
| 385 | return r; | |||
| 386 | } | |||
| 387 | ||||
| 388 | #if ! HAVE_GCRYPT1 | |||
| 389 | if (m->dnssec_mode != DNSSEC_NO) { | |||
| 390 | log_warning("DNSSEC option cannot be enabled or set to allow-downgrade when systemd-resolved is built without gcrypt support. Turning off DNSSEC support.")({ int _level = (((4))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/resolve/resolved-conf.c", 390, __func__, "DNSSEC option cannot be enabled or set to allow-downgrade when systemd-resolved is built without gcrypt support. Turning off DNSSEC support." ) : -abs(_e); }); | |||
| 391 | m->dnssec_mode = DNSSEC_NO; | |||
| 392 | } | |||
| 393 | #endif | |||
| 394 | ||||
| 395 | #if ! ENABLE_DNS_OVER_TLS1 | |||
| 396 | if (m->dns_over_tls_mode != DNS_OVER_TLS_NO) { | |||
| 397 | log_warning("DNS-over-TLS option cannot be set to opportunistic when systemd-resolved is built without DNS-over-TLS support. Turning off DNS-over-TLS support.")({ int _level = (((4))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/resolve/resolved-conf.c", 397, __func__, "DNS-over-TLS option cannot be set to opportunistic when systemd-resolved is built without DNS-over-TLS support. Turning off DNS-over-TLS support." ) : -abs(_e); }); | |||
| 398 | m->dns_over_tls_mode = DNS_OVER_TLS_NO; | |||
| 399 | } | |||
| 400 | #endif | |||
| 401 | return 0; | |||
| 402 | ||||
| 403 | } |