diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2018-01-10 11:22:11 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2018-01-12 13:42:08 +0100 |
commit | b4db0e8362fa0587fcf25a13a2086864fd3062e2 (patch) | |
tree | 5a028203e5b5ca3c15dc680096561a26aba788df /src/dns | |
parent | e78bfb63cd7c4727a283fb38cf196350fe974922 (diff) | |
download | NetworkManager-b4db0e8362fa0587fcf25a13a2086864fd3062e2.tar.gz |
dns: add @dup argument to add_dns_domains() and add_string_item()
Add a @dup argument that tells whether the new item should be
duplicated.
Diffstat (limited to 'src/dns')
-rw-r--r-- | src/dns/nm-dns-manager.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index 912b9a8a2a..39dd78ceab 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -350,7 +350,7 @@ _ip_config_lst_head (NMDnsManager *self) /*****************************************************************************/ static void -add_string_item (GPtrArray *array, const char *str) +add_string_item (GPtrArray *array, const char *str, gboolean dup) { int i; @@ -366,7 +366,7 @@ add_string_item (GPtrArray *array, const char *str) } /* No dupes, add the new item */ - g_ptr_array_add (array, g_strdup (str)); + g_ptr_array_add (array, dup ? g_strdup (str): (gpointer) str); } static void @@ -377,7 +377,7 @@ add_dns_option_item (GPtrArray *array, const char *str) } static void -add_dns_domains (GPtrArray *array, const NMIPConfig *ip_config) +add_dns_domains (GPtrArray *array, const NMIPConfig *ip_config, gboolean dup) { guint num_domains, num_searches, i; const char *str; @@ -388,13 +388,13 @@ add_dns_domains (GPtrArray *array, const NMIPConfig *ip_config) for (i = 0; i < num_searches; i++) { str = nm_ip_config_get_search (ip_config, i); if (domain_is_valid (str, FALSE)) - add_string_item (array, str); + add_string_item (array, str, dup); } if (num_domains > 1 || !num_searches) { for (i = 0; i < num_domains; i++) { str = nm_ip_config_get_domain (ip_config, i); if (domain_is_valid (str, FALSE)) - add_string_item (array, str); + add_string_item (array, str, dup); } } } @@ -436,10 +436,10 @@ merge_one_ip_config (NMResolvConfData *rc, } } - add_string_item (rc->nameservers, buf); + add_string_item (rc->nameservers, buf, TRUE); } - add_dns_domains (rc->searches, ip_config); + add_dns_domains (rc->searches, ip_config, TRUE); num = nm_ip_config_get_num_dns_options (ip_config); for (i = 0; i < num; i++) { @@ -454,7 +454,8 @@ merge_one_ip_config (NMResolvConfData *rc, num = nm_ip4_config_get_num_nis_servers (ip4_config); for (i = 0; i < num; i++) { add_string_item (rc->nis_servers, - nm_utils_inet4_ntop (nm_ip4_config_get_nis_server (ip4_config, i), buf)); + nm_utils_inet4_ntop (nm_ip4_config_get_nis_server (ip4_config, i), buf), + TRUE); } if (nm_ip4_config_get_nis_domain (ip4_config)) { @@ -967,17 +968,17 @@ merge_global_dns_config (NMResolvConfData *rc, NMGlobalDnsConfig *global_conf) for (i = 0; searches && searches[i]; i++) { if (domain_is_valid (searches[i], FALSE)) - add_string_item (rc->searches, searches[i]); + add_string_item (rc->searches, searches[i], TRUE); } for (i = 0; options && options[i]; i++) - add_string_item (rc->options, options[i]); + add_string_item (rc->options, options[i], TRUE); default_domain = nm_global_dns_config_lookup_domain (global_conf, "*"); g_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]); + add_string_item (rc->nameservers, servers[i], TRUE); return TRUE; } @@ -1090,9 +1091,9 @@ _collect_resolv_conf_data (NMDnsManager *self, && !nm_utils_ipaddr_valid (AF_UNSPEC, priv->hostname)) { hostdomain++; if (domain_is_valid (hostdomain, TRUE)) - add_string_item (rc.searches, hostdomain); + add_string_item (rc.searches, hostdomain, TRUE); else if (domain_is_valid (priv->hostname, TRUE)) - add_string_item (rc.searches, priv->hostname); + add_string_item (rc.searches, priv->hostname, TRUE); } } |