X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fnetwork%2Fnetworkd-network.c;h=fc62395217fd5032a8ae8f331514a4ae8b08c9e6;hb=2c36be2f4ba38f9097cdcdcd1e724ffa46da12c7;hp=e13e4a0f620b2c585ee09e84489d99d0c4dcd1e9;hpb=1bd27a45d04639190fc91ad2552b72ea759c0c27;p=elogind.git diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index e13e4a0f6..fc6239521 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -166,13 +166,16 @@ void network_free(Network *network) { strv_free(network->ntp); strv_free(network->dns); + strv_free(network->domains); netdev_unref(network->bridge); netdev_unref(network->bond); - HASHMAP_FOREACH(netdev, network->stacked_netdevs, i) + HASHMAP_FOREACH(netdev, network->stacked_netdevs, i) { + hashmap_remove(network->stacked_netdevs, netdev->ifname); netdev_unref(netdev); + } hashmap_free(network->stacked_netdevs); while ((route = network->static_routes)) @@ -341,6 +344,47 @@ int config_parse_netdev(const char *unit, return 0; } +int config_parse_domains(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) { + Network *network = userdata; + char ***domains = data; + char **domain; + int r; + + r = config_parse_strv(unit, filename, line, section, section_line, + lvalue, ltype, rvalue, domains, userdata); + if (r < 0) + return r; + + strv_uniq(*domains); + network->wildcard_domain = !!strv_find(*domains, "*"); + + STRV_FOREACH(domain, *domains) { + if (is_localhost(*domain)) + log_syntax(unit, LOG_ERR, filename, line, EINVAL, "'localhost' domain names may not be configured, ignoring assignment: %s", *domain); + else if (!hostname_is_valid(*domain)) { + if (!streq(*domain, "*")) + log_syntax(unit, LOG_ERR, filename, line, EINVAL, "domain name is not valid, ignoring assignment: %s", *domain); + } else + continue; + + strv_remove(*domains, *domain); + + /* We removed one entry, make sure we don't skip the next one */ + domain--; + } + + return 0; +} + int config_parse_tunnel(const char *unit, const char *filename, unsigned line,