]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2114. [bug] dig/host/nslookup: searches for names with multiple
authorMark Andrews <marka@isc.org>
Thu, 7 Dec 2006 06:07:32 +0000 (06:07 +0000)
committerMark Andrews <marka@isc.org>
Thu, 7 Dec 2006 06:07:32 +0000 (06:07 +0000)
                        labels were failing. [RT #16447]

CHANGES
bin/dig/dighost.c
bin/dig/include/dig/dig.h

diff --git a/CHANGES b/CHANGES
index 6d6f44ccb4f8ee188edd33e907b61fcab9d91fd0..f0404c281aaa046bf9c7db9c0b2bf6884587e709 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+2114.  [bug]           dig/host/nslookup: searches for names with multiple
+                       labels were failing. [RT #16447]
+
 2113.  [bug]           nsupdate: if a zone is specified it should be used
                        for server discover. [RT# 16455]
                        
index 822fde6b85b2f7464663bfe1c75b94e569ed09db..3b542000f2c04a7643f9c858c31054e886946c74 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dighost.c,v 1.221.2.34 2006/12/07 01:36:49 marka Exp $ */
+/* $Id: dighost.c,v 1.221.2.35 2006/12/07 06:07:31 marka Exp $ */
 
 /*
  * Notice to programmers:  Do not use this code as an example of how to
@@ -382,12 +382,12 @@ set_nameserver(char *opt) {
       flush_server_list();
 
       for (i = 0; i < count; i++) {
-            isc_netaddr_fromsockaddr(&netaddr, &sockaddrs[i]);
-            isc_netaddr_format(&netaddr, tmp, sizeof(tmp));
-            srv = make_server(tmp, opt);
-            if (srv == NULL)
-                  fatal("memory allocation failure");
-            ISC_LIST_APPEND(server_list, srv, link);
+           isc_netaddr_fromsockaddr(&netaddr, &sockaddrs[i]);
+           isc_netaddr_format(&netaddr, tmp, sizeof(tmp));
+           srv = make_server(tmp, opt);
+           if (srv == NULL)
+                 fatal("memory allocation failure");
+           ISC_LIST_APPEND(server_list, srv, link);
       }
 }          
 
@@ -472,6 +472,8 @@ make_empty_lookup(void) {
        looknew->section_authority = ISC_TRUE;
        looknew->section_additional = ISC_TRUE;
        looknew->new_search = ISC_FALSE;
+       looknew->done_as_is = ISC_FALSE;
+       looknew->need_search = ISC_FALSE;
        ISC_LINK_INIT(looknew, link);
        ISC_LIST_INIT(looknew->q);
        ISC_LIST_INIT(looknew->my_server_list);
@@ -528,6 +530,8 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
        looknew->section_additional = lookold->section_additional;
        looknew->retries = lookold->retries;
        looknew->tsigctx = NULL;
+       looknew->need_search = lookold->need_search;
+       looknew->done_as_is = lookold->done_as_is;
 
        if (servers)
                clone_server_list(lookold->my_server_list,
@@ -1153,6 +1157,7 @@ followup_lookup(dns_message_t *msg, dig_query_t *query, dns_section_t section)
 static isc_boolean_t
 next_origin(dns_message_t *msg, dig_query_t *query) {
        dig_lookup_t *lookup;
+       dig_searchlist_t *search;
 
        UNUSED(msg);
 
@@ -1167,13 +1172,22 @@ next_origin(dns_message_t *msg, dig_query_t *query) {
                 * about finding the next entry.
                 */
                return (ISC_FALSE);
-       if (query->lookup->origin == NULL)
+       if (query->lookup->origin == NULL && !query->lookup->need_search)
                /*
                 * Then we just did rootorg; there's nothing left.
                 */
                return (ISC_FALSE);
-       lookup = requeue_lookup(query->lookup, ISC_TRUE);
-       lookup->origin = ISC_LIST_NEXT(query->lookup->origin, link);
+       if (query->lookup->origin == NULL && query->lookup->need_search) {
+               lookup = requeue_lookup(query->lookup, ISC_TRUE);
+               lookup->origin = ISC_LIST_HEAD(search_list);
+               query->lookup->need_search = ISC_FALSE;
+       } else {
+               search = ISC_LIST_NEXT(query->lookup->origin, link);
+               if (search == NULL && query->lookup->done_as_is)
+                       return (ISC_FALSE);
+               lookup = requeue_lookup(query->lookup, ISC_TRUE);
+               lookup->origin = search;
+       }
        cancel_lookup(query->lookup);
        return (ISC_TRUE);
 }
@@ -1295,12 +1309,17 @@ setup_lookup(dig_lookup_t *lookup) {
         * take the first entry in the searchlist iff either usesearch
         * is TRUE or we got a domain line in the resolv.conf file.
         */
-       /* XXX New search here? */
-       if ((count_dots(lookup->textname) >= ndots) || !usesearch)
-               lookup->origin = NULL; /* Force abs lookup */
-       else if (lookup->origin == NULL && lookup->new_search && usesearch) {
-               lookup->origin = ISC_LIST_HEAD(search_list);
+       if (lookup->new_search) {
+               if ((count_dots(lookup->textname) >= ndots) || !usesearch) {
+                       lookup->origin = NULL; /* Force abs lookup */
+                       lookup->done_as_is = ISC_TRUE;
+                       lookup->need_search = usesearch;
+               } else if (lookup->origin == NULL && usesearch) {
+                       lookup->origin = ISC_LIST_HEAD(search_list);
+                       lookup->need_search = ISC_FALSE;
+               }
        }
+
        if (lookup->origin != NULL) {
                debug("trying origin %s", lookup->origin->origin);
                result = dns_message_gettempname(lookup->sendmsg,
@@ -2299,7 +2318,7 @@ recv_done(isc_task_t *task, isc_event_t *event) {
                }
        }
 
-       result = dns_message_peekheader(b, &id, &msgflags);
+       result = dns_message_peekheader(b, &id, &msgflags);
        if (result != ISC_R_SUCCESS || l->sendmsg->id != id) {
                match = ISC_FALSE;
                if (l->tcp_mode) {
@@ -2486,7 +2505,8 @@ recv_done(isc_task_t *task, isc_event_t *event) {
        }
 
        if (!l->doing_xfr || l->xfr_q == query) {
-               if (msg->rcode != dns_rcode_noerror && l->origin != NULL) {
+               if (msg->rcode != dns_rcode_noerror &&
+                   (l->origin != NULL || l->need_search)) {
                        if (!next_origin(msg, query)) {
                                printmessage(query, msg, ISC_TRUE);
                                received(b->used, &sevent->address, query);
index b53922523e66c37cd6d84667014b5e380fb241b3..6b6ff1d470d98ed205019bd87c0192ce0eb7c12c 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dig.h,v 1.71.2.15 2006/12/07 01:36:50 marka Exp $ */
+/* $Id: dig.h,v 1.71.2.16 2006/12/07 06:07:32 marka Exp $ */
 
 #ifndef DIG_H
 #define DIG_H
@@ -100,6 +100,8 @@ struct dig_lookup {
                section_additional,
                servfail_stops,
                new_search,
+               need_search,
+               done_as_is,
                besteffort,
                dnssec;
        char textname[MXNAME]; /* Name we're going to be looking up */