From b3ffa2b5f3aa68dc6ab15893d5eeba8906aa3a9e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 29 Sep 2020 16:10:40 +0200 Subject: [PATCH] resolved: turn off that a search domain is derived from the host's fqdn If the hostname of a system is set to an fqdn, glibc traditionally derives a search domain from it if none is explicitly configured. This is a bit weird, and we currently don't do that in our own search path logic. Following #17193 let's turn this behaviour off for now. Yes, this has a slight chance of pissing people off who think this behaviour is good. If this is indeed an issue, we can revisit the issue but in that case if we readd the concept we should do it properly: derive the search domain from the fqdn in our codebase too and report it in resolvectl, and in our generated stub files. But I have the suspicion most people who set the hostname to an fqdn aren#t even aware of this behaviour nor want it, so let's wait until people complain. Fixes: #17193 --- src/resolve/resolv.conf | 1 + src/resolve/resolved-resolv-conf.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/resolve/resolv.conf b/src/resolve/resolv.conf index dc5ac05532a..b4e9a96b35a 100644 --- a/src/resolve/resolv.conf +++ b/src/resolve/resolv.conf @@ -16,3 +16,4 @@ nameserver 127.0.0.53 options edns0 trust-ad +search . diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c index 0de50463677..7f48c0b9a75 100644 --- a/src/resolve/resolved-resolv-conf.c +++ b/src/resolve/resolved-resolv-conf.c @@ -271,7 +271,10 @@ static int write_uplink_resolv_conf_contents(FILE *f, OrderedSet *dns, OrderedSe write_resolv_conf_server(s, f, &count); } - if (!ordered_set_isempty(domains)) + if (ordered_set_isempty(domains)) + fputs("search .", f); /* Make sure that if the local hostname is chosen as fqdn this does not + * imply a search domain */ + else write_resolv_conf_search(domains, f); return fflush_and_check(f); @@ -297,7 +300,10 @@ static int write_stub_resolv_conf_contents(FILE *f, OrderedSet *dns, OrderedSet "nameserver 127.0.0.53\n" "options edns0 trust-ad\n", f); - if (!ordered_set_isempty(domains)) + if (ordered_set_isempty(domains)) + fputs("search .", f); /* Make sure that if the local hostname is chosen as fqdn this does not + * imply a search domain */ + else write_resolv_conf_search(domains, f); return fflush_and_check(f);