summaryrefslogtreecommitdiff
path: root/src/dns-manager
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-04-28 14:20:19 -0400
committerDan Winship <danw@gnome.org>2014-04-29 14:47:25 -0400
commit50bafeaf2e318f63dd24053440712dee3035fa84 (patch)
tree78147cfacc6d4350fe3d0eff6b1da99e84fa3bcd /src/dns-manager
parent93c10a6eead2383ef33d58a065117f10e0d98fd4 (diff)
downloadNetworkManager-50bafeaf2e318f63dd24053440712dee3035fa84.tar.gz
dns-manager: fix the rules for public suffixes and search domains (rh #851521)
dfe194ee made it so that we don't use "public suffixes" as resolv.conf search domains (eg, we don't add "search com" if the hostname is "example.com"). However, if this results in us writing a resolv.conf with no "search" line at all, then the resolver will fall back to using the parent domain of the hostname as a search domain anyway, thwarting us. To fix that, use the domain itself as a search domain in this case, since that's likely to be the expected behavior anyway. (And even if it's not, there doesn't appear to be any way to block the resolver from using the hostname's parent domain as a search domain unless we specify at least one search domain ourselves.) https://bugzilla.gnome.org/show_bug.cgi?id=729137
Diffstat (limited to 'src/dns-manager')
-rw-r--r--src/dns-manager/nm-dns-manager.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c
index 3c638ed9fe..fe8cf6c94a 100644
--- a/src/dns-manager/nm-dns-manager.c
+++ b/src/dns-manager/nm-dns-manager.c
@@ -633,18 +633,23 @@ update_dns (NMDnsManager *self,
g_assert_not_reached ();
}
- /* Add the current domain name (from the hostname) to the searches list;
- * see rh #600407. The bug report is that when the hostname is set to
- * something like 'dcbw.foobar.com' (ie an FQDN) that pinging 'dcbw' doesn't
- * work because the resolver doesn't have anything to append to 'dcbw' when
- * looking it up.
+ /* If the hostname is a FQDN ("dcbw.example.com"), then add the domain part of it
+ * ("example.com") to the searches list, to ensure that we can still resolve its
+ * non-FQ form ("dcbw") too. (Also, if there are no other search domains specified,
+ * this makes a good default.) However, if the hostname is the top level of a domain
+ * (eg, "example.com"), then use the hostname itself as the search (since the user is
+ * unlikely to want "com" as a search domain).
*/
if (priv->hostname) {
- const char *hostsearch = strchr (priv->hostname, '.');
-
- /* +1 to get rid of the dot */
- if (hostsearch && DOMAIN_IS_VALID (hostsearch + 1))
- add_string_item (rc.searches, hostsearch + 1);
+ const char *hostdomain = strchr (priv->hostname, '.');
+
+ if (hostdomain) {
+ hostdomain++;
+ if (DOMAIN_IS_VALID (hostdomain))
+ add_string_item (rc.searches, hostdomain);
+ else if (DOMAIN_IS_VALID (priv->hostname))
+ add_string_item (rc.searches, priv->hostname);
+ }
}
/* Per 'man resolv.conf', the search list is limited to 6 domains