]> 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:08:02 +0000 (06:08 +0000)
committerMark Andrews <marka@isc.org>
Thu, 7 Dec 2006 06:08:02 +0000 (06:08 +0000)
                        labels were failing. [RT #16447]

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

diff --git a/CHANGES b/CHANGES
index 3e9d0eda4473bfbf40273f6a719b1456051d1f11..421a95d1c93868f10e9bff18217c53a4060835ec 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 2fc6c74db79fcad4d7b35c2241535112de5ca8fa..2d6c70ec5f4f7b13d96b380c98ae9e8d1e14e525 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dighost.c,v 1.259.18.36 2006/12/07 01:27:21 marka Exp $ */
+/* $Id: dighost.c,v 1.259.18.37 2006/12/07 06:08:02 marka Exp $ */
 
 /*! \file
  *  \note
@@ -754,6 +754,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);
@@ -826,6 +828,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,
@@ -1608,6 +1612,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);
 
@@ -1622,13 +1627,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);
 }
@@ -1770,18 +1784,27 @@ 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 (lookup->new_search) {
 #ifdef WITH_IDN
-       if ((count_dots(utf8_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 ((count_dots(utf8_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;
+               }
 #else
-       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 ((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;
+               }
 #endif
+       }
 
 #ifdef WITH_IDN
        if (lookup->origin != NULL) {
@@ -3025,7 +3048,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) || showsearch) {
                                printmessage(query, msg, ISC_TRUE);
                                received(b->used, &sevent->address, query);
@@ -3115,7 +3139,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
                        chase_msg2->msg = msg;
                }
 #endif
-       
        }
        
 #ifdef DIG_SIGCHASE
index 29f3551066fc732f34426f9f615b07717b57a512..675bb155b68d786d61abaaae5d5204b1da865552 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dig.h,v 1.82.18.18 2006/12/07 01:27:22 marka Exp $ */
+/* $Id: dig.h,v 1.82.18.19 2006/12/07 06:08:02 marka Exp $ */
 
 #ifndef DIG_H
 #define DIG_H
@@ -126,6 +126,8 @@ struct dig_lookup {
                section_additional,
                servfail_stops,
                new_search,
+               need_search,
+               done_as_is,
                besteffort,
                dnssec;
 #ifdef DIG_SIGCHASE
index f9bd51f2401ea29faceb5923c1fa2e58eb6c2759..e2310af0d944a16b221d3638666c60639eb50651 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: nslookup.c,v 1.101.18.11 2006/06/09 23:50:54 marka Exp $ */
+/* $Id: nslookup.c,v 1.101.18.12 2006/12/07 06:08:02 marka Exp $ */
 
 #include <config.h>
 
@@ -620,8 +620,10 @@ setoption(char *opt) {
                tcpmode = ISC_FALSE;
        } else if (strncasecmp(opt, "deb", 3) == 0) {
                short_form = ISC_FALSE;
+               showsearch = ISC_TRUE;
        } else if (strncasecmp(opt, "nodeb", 5) == 0) {
                short_form = ISC_TRUE;
+               showsearch = ISC_FALSE;
        } else if (strncasecmp(opt, "d2", 2) == 0) {
                debugging = ISC_TRUE;
        } else if (strncasecmp(opt, "nod2", 4) == 0) {