From 2758519ed2d4f1931a30e63ef94060bd693d7eab Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Thu, 10 Jun 2010 11:14:36 +0000 Subject: [PATCH] Change default hostname resolution order Hostnames that contain at least one period, are now first attempted to be resolved as FQDNs, before adding local domains is tried. --- lib/libc/ip/res_query.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/libc/ip/res_query.c b/lib/libc/ip/res_query.c index 2fa6ce2ac..7f8f57456 100644 --- a/lib/libc/ip/res_query.c +++ b/lib/libc/ip/res_query.c @@ -175,7 +175,17 @@ res_search(name, class, type, answer, anslen) return (res_query(cp, class, type, answer, anslen)); /* - * We do at least one level of search if + * First try the name as fully-qualified, but only if it contained + * at least one dot (even trailing). This is purely a heuristic; we + * assume that any reasonable query about a top-level domain (for + * servers, SOA, etc) will not use res_search. + */ + if (n && (ret = res_querydomain(name, (char *)NULL, class, type, + answer, anslen)) > 0) + return (ret); + + /* + * If the FQDN lookup failed, we do at least one level of search if * - there is no dot and RES_DEFNAME is set, or * - there is at least one dot, there is no trailing dot, * and RES_DNSRCH is set. @@ -209,16 +219,6 @@ res_search(name, class, type, answer, anslen) (_res.options & RES_DNSRCH) == 0) break; } - /* - * If the search/default failed, try the name as fully-qualified, - * but only if it contained at least one dot (even trailing). - * This is purely a heuristic; we assume that any reasonable query - * about a top-level domain (for servers, SOA, etc) will not use - * res_search. - */ - if (n && (ret = res_querydomain(name, (char *)NULL, class, type, - answer, anslen)) > 0) - return (ret); if (got_nodata) h_errno = NO_DATA; return (-1); -- 2.44.0