diff --git a/CHANGES b/CHANGES index 1628b498eb..be6a22fb1c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +1095. [func] libbind: resolver option: no-tld-query. disables + trying unqualified as a tld. no_tld_query is also + supported for FreeBSD compatability. + 1094. [func] libbind: add support gcc's format string checking. 1093. [doc] libbind: miscellaneous nroff fixes. diff --git a/lib/bind/include/resolv.h b/lib/bind/include/resolv.h index 0582bcfbd8..544cf02a1e 100644 --- a/lib/bind/include/resolv.h +++ b/lib/bind/include/resolv.h @@ -50,7 +50,7 @@ /* * @(#)resolv.h 8.1 (Berkeley) 6/2/93 - * $Id: resolv.h,v 1.8 2001/11/01 03:37:18 marka Exp $ + * $Id: resolv.h,v 1.9 2001/11/01 04:50:56 marka Exp $ */ #ifndef _RESOLV_H_ @@ -237,6 +237,7 @@ union res_sockaddr_union { #define RES_BLAST 0x00020000 /* blast all recursive servers */ #define RES_NO_NIBBLE 0x00040000 /* disable IPv6 nibble mode reverse */ #define RES_NO_BITSTRING 0x00080000 /* disable IPv6 bits tring mode reverse */ +#define RES_NOTLDQUERY 0x00100000 /* don't unqualified name as a tld */ /* KAME extensions: use higher bit to avoid conflict with ISC use */ #define RES_USE_EDNS0 0x40000000 /* use EDNS0 if configured */ #define RES_USE_A6 0x20000000 /* use A6 */ diff --git a/lib/bind/resolv/res_debug.c b/lib/bind/resolv/res_debug.c index be33c03943..bc1e3d3681 100644 --- a/lib/bind/resolv/res_debug.c +++ b/lib/bind/resolv/res_debug.c @@ -95,7 +95,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: res_debug.c,v 1.3 2001/06/21 08:26:22 marka Exp $"; +static const char rcsid[] = "$Id: res_debug.c,v 1.4 2001/11/01 04:50:58 marka Exp $"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -616,6 +616,9 @@ p_option(u_long option) { #ifdef RES_USE_DNAME case RES_USE_DNAME: return "dname"; #endif +#ifdef RES_NOTLDQUERY + case RES_NOTLDQUERY: return "no-tld-query"; +#endif /* XXX nonreentrant */ default: sprintf(nbuf, "?0x%lx?", (u_long)option); diff --git a/lib/bind/resolv/res_init.c b/lib/bind/resolv/res_init.c index 6072617ef1..198dfd4b9f 100644 --- a/lib/bind/resolv/res_init.c +++ b/lib/bind/resolv/res_init.c @@ -70,7 +70,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; -static const char rcsid[] = "$Id: res_init.c,v 1.9 2001/07/03 06:55:04 marka Exp $"; +static const char rcsid[] = "$Id: res_init.c,v 1.10 2001/11/01 04:50:59 marka Exp $"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -487,9 +487,13 @@ res_setoptions(res_state statp, const char *options, const char *source) } printf(";;\tdebug\n"); #endif + } else if (!strncmp(cp, "no_tld_query", + sizeof("no_tld_query") - 1) || + !strncmp(cp, "no-tld-query", + sizeof("no-tld-query") - 1)) { + statp->options |= RES_NOTLDQUERY; } else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) { statp->options |= RES_USE_INET6; - } else if (!strncmp(cp, "rotate", sizeof("rotate") - 1)) { statp->options |= RES_ROTATE; } else if (!strncmp(cp, "no-check-names", diff --git a/lib/bind/resolv/res_query.c b/lib/bind/resolv/res_query.c index e77de9dd02..539c2eabfb 100644 --- a/lib/bind/resolv/res_query.c +++ b/lib/bind/resolv/res_query.c @@ -70,7 +70,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: res_query.c,v 1.2 2001/04/03 06:42:33 marka Exp $"; +static const char rcsid[] = "$Id: res_query.c,v 1.3 2001/11/01 04:51:00 marka Exp $"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -212,6 +212,7 @@ res_nsearch(res_state statp, int trailing_dot, ret, saved_herrno; int got_nodata = 0, got_servfail = 0, root_on_list = 0; int tried_as_is = 0; + int searched = 0; errno = 0; RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); /* True if we never query. */ @@ -255,6 +256,7 @@ res_nsearch(res_state statp, for (domain = (const char * const *)statp->dnsrch; *domain && !done; domain++) { + searched = 1; if (domain[0][0] == '\0' || (domain[0][0] == '.' && domain[0][1] == '\0')) @@ -312,11 +314,11 @@ res_nsearch(res_state statp, } /* - * If the name has any dots at all, and no earlier 'as-is' query - * for the name, and "." is not on the search list, then try an as-is - * query now. + * If the query has not already been tried as is then try it + * unless RES_NOTLDQUERY is set and there were no dots. */ - if (statp->ndots && !(tried_as_is || root_on_list)) { + if ((dots || !searched || (statp->options & RES_NOTLDQUERY) == 0) && + !(tried_as_is || root_on_list)) { ret = res_nquerydomain(statp, name, NULL, class, type, answer, anslen); if (ret > 0)