mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-08 17:20:31 +01:00
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
This commit is contained in:
parent
93c10a6eea
commit
50bafeaf2e
1 changed files with 14 additions and 9 deletions
|
|
@ -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, '.');
|
||||
const char *hostdomain = strchr (priv->hostname, '.');
|
||||
|
||||
/* +1 to get rid of the dot */
|
||||
if (hostsearch && DOMAIN_IS_VALID (hostsearch + 1))
|
||||
add_string_item (rc.searches, hostsearch + 1);
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue