]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: use exact-match domain as routing domain for single-labels
authorTad Fisher <tadfisher@gmail.com>
Fri, 6 Oct 2023 20:52:07 +0000 (13:52 -0700)
committerLennart Poettering <lennart@poettering.net>
Mon, 6 Nov 2023 21:27:12 +0000 (22:27 +0100)
With ResolveUnicastSingleLabel=yes, a scope's search domains are affixed to the
query even when a routing domain matches the single-label query name,
preventing the use of dotless single-label domains entirely.

This changes dns_scope_name_wants_search_domain() to return false when the
scope contains an exact match of the single-label name in the query, allowing
lookups for dotless domains with ResolveUnicastSingleLabel enabled.

src/resolve/resolved-dns-scope.c

index cd5945eb000bbed458326cd28d985c12bc8cc3cd..d9d8acfd25ea98d198aede4141fa3d98d6ee7567 100644 (file)
@@ -1365,7 +1365,17 @@ bool dns_scope_name_wants_search_domain(DnsScope *s, const char *name) {
         if (s->protocol != DNS_PROTOCOL_DNS)
                 return false;
 
-        return dns_name_is_single_label(name);
+        if (!dns_name_is_single_label(name))
+                return false;
+
+        /* If we allow single-label domain lookups on unicast DNS, and this scope has a search domain that matches
+         * _exactly_ this name, then do not use search domains. */
+        if (s->manager->resolve_unicast_single_label)
+                LIST_FOREACH(domains, d, dns_scope_get_search_domains(s))
+                        if (dns_name_equal(name, d->name) > 0)
+                                return false;
+
+        return true;
 }
 
 bool dns_scope_network_good(DnsScope *s) {