Commit cd48bc74 authored by Thomas Haller's avatar Thomas Haller

config: cleanup fields in NMGlobalDnsConfig

- consistently set options, searches, domains fields to %NULL,
  if there are no values.

- in nm_global_dns_config_update_checksum(), ensure that we uniquely
  hash values. E.g. a config with "searches[a], options=[b]" should
  hash differently from "searches=[ab], options=[]".

- in nm_global_dns_config_to_dbus(), reuse the sorted domain list.
  We already have it, and it guarantees a consistent ordering of
  fields.

- in global_dns_domain_from_dbus(), fix memleaks if D-Bus strdict
  contains duplicate entries.
parent 0f1dc3bc
......@@ -970,30 +970,36 @@ merge_global_dns_config (NMResolvConfData *rc, NMGlobalDnsConfig *global_conf)
const char *const *searches;
const char *const *options;
const char *const *servers;
gint i;
guint i;
if (!global_conf)
return FALSE;
searches = nm_global_dns_config_get_searches (global_conf);
options = nm_global_dns_config_get_options (global_conf);
for (i = 0; searches && searches[i]; i++) {
if (domain_is_routing (searches[i]))
continue;
if (!domain_is_valid (searches[i], FALSE))
continue;
add_string_item (rc->searches, searches[i], TRUE);
if (searches) {
for (i = 0; searches[i]; i++) {
if (domain_is_routing (searches[i]))
continue;
if (!domain_is_valid (searches[i], FALSE))
continue;
add_string_item (rc->searches, searches[i], TRUE);
}
}
for (i = 0; options && options[i]; i++)
add_string_item (rc->options, options[i], TRUE);
options = nm_global_dns_config_get_options (global_conf);
if (options) {
for (i = 0; options[i]; i++)
add_string_item (rc->options, options[i], TRUE);
}
default_domain = nm_global_dns_config_lookup_domain (global_conf, "*");
g_assert (default_domain);
nm_assert (default_domain);
servers = nm_global_dns_domain_get_servers (default_domain);
for (i = 0; servers && servers[i]; i++)
add_string_item (rc->nameservers, servers[i], TRUE);
if (servers) {
for (i = 0; servers[i]; i++)
add_string_item (rc->nameservers, servers[i], TRUE);
}
return TRUE;
}
......
This diff is collapsed.
......@@ -254,7 +254,7 @@ test_config_global_dns (void)
NMConfig *config;
const NMGlobalDnsConfig *dns;
NMGlobalDnsDomain *domain;
const char *const *strv;
const char *const*strv;
config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL,
"/no/such/dir", "", NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment