]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3640. [bug] ndots was not being checked when searching. Only
authorMark Andrews <marka@isc.org>
Wed, 4 Sep 2013 03:24:11 +0000 (13:24 +1000)
committerMark Andrews <marka@isc.org>
Wed, 4 Sep 2013 03:24:11 +0000 (13:24 +1000)
                        continue searching on NXDOMAIN responses.  Add the
                        ability to specify ndots to nslookup. [RT #34711]

CHANGES
bin/dig/dighost.c
bin/dig/nslookup.c
bin/dig/nslookup.docbook

diff --git a/CHANGES b/CHANGES
index 1b2169e99b6676dd9202586300b70a608dd86549..f58b51894d13a9989a419214105c921e82d43eba 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+3640.  [bug]           ndots was not being checked when searching.  Only
+                       continue searching on NXDOMAIN responses.  Add the
+                       ability to specify ndots to nslookup. [RT #34711]
+
 3639.  [bug]           Treat type 65533 (KEYDATA) as opaque except when used
                        in a key zone. [RT #34238]
 
index dd6b7625fd20c4fcea3f88827988a5fbd4d7fd46..80e7ee28e6a1856634255cdf6fc971e32eec8afb 100644 (file)
@@ -1881,6 +1881,9 @@ static isc_boolean_t
 next_origin(dig_query_t *query) {
        dig_lookup_t *lookup;
        dig_searchlist_t *search;
+       dns_fixedname_t fixed;
+       dns_name_t *name;
+       isc_result_t result;
 
        INSIST(!free_now);
 
@@ -1893,6 +1896,19 @@ next_origin(dig_query_t *query) {
                 * about finding the next entry.
                 */
                return (ISC_FALSE);
+       
+       /*
+        * Check for a absolute name or ndots being met.
+        */
+       dns_fixedname_init(&fixed);
+       name = dns_fixedname_name(&fixed);
+       result = dns_name_fromstring2(name, query->lookup->textname, NULL,
+                                     0, NULL);
+       if (result == ISC_R_SUCCESS &&
+           (dns_name_isabsolute(name) ||
+            (int)dns_name_countlabels(name) > ndots))
+               return (ISC_FALSE);
+               
        if (query->lookup->origin == NULL && !query->lookup->need_search)
                /*
                 * Then we just did rootorg; there's nothing left.
@@ -3398,7 +3414,7 @@ recv_done(isc_task_t *task, isc_event_t *event) {
        }
 
        if (!l->doing_xfr || l->xfr_q == query) {
-               if (msg->rcode != dns_rcode_noerror &&
+               if (msg->rcode == dns_rcode_nxdomain &&
                    (l->origin != NULL || l->need_search)) {
                        if (!next_origin(query) || showsearch) {
                                printmessage(query, msg, ISC_TRUE);
index 3f5b82fd292df817d6894032d57ddbde144916ba..ab8066656ca03bf2ed0e28dec92cf112f93de198 100644 (file)
@@ -442,8 +442,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
                dns_name_format(query->lookup->name,
                                nametext, sizeof(nametext));
                printf("** server can't find %s: %s\n",
-                      (msg->rcode != dns_rcode_nxdomain) ? nametext :
-                      query->lookup->textname, rcode_totext(msg->rcode));
+                      nametext, rcode_totext(msg->rcode));
                debug("returning with rcode == 0");
 
                /* the lookup failed */
@@ -502,8 +501,8 @@ show_settings(isc_boolean_t full, isc_boolean_t serv_only) {
        printf("  %s\t\t%s\n",
               usesearch ? "search" : "nosearch",
               recurse ? "recurse" : "norecurse");
-       printf("  timeout = %d\t\tretry = %d\tport = %d\n",
-              timeout, tries, port);
+       printf("  timeout = %d\t\tretry = %d\tport = %d\tndots = %d\n",
+              timeout, tries, port, ndots);
        printf("  querytype = %-8s\tclass = %s\n", deftype, defclass);
        printf("  srchlist = ");
        for (listent = ISC_LIST_HEAD(search_list);
@@ -574,6 +573,14 @@ set_tries(const char *value) {
                tries = n;
 }
 
+static void
+set_ndots(const char *value) {
+       isc_uint32_t n;
+       isc_result_t result = parse_uint(&n, value, 128, "ndots");
+       if (result == ISC_R_SUCCESS)
+               ndots = n;
+}
+
 static void
 setoption(char *opt) {
        if (strncasecmp(opt, "all", 4) == 0) {
@@ -654,6 +661,8 @@ setoption(char *opt) {
                nofail=ISC_FALSE;
        } else if (strncasecmp(opt, "nofail", 3) == 0) {
                nofail=ISC_TRUE;
+       } else if (strncasecmp(opt, "ndots=", 6) == 0) {
+               set_ndots(&opt[6]);
        } else {
                printf("*** Invalid option: %s\n", opt);
        }
index f4d497b3998bf2ae231299cae21bd182ad2e0ba8..3f7d1f6fb8b171c8ea9393261fc982852a8197b0 100644 (file)
@@ -409,6 +409,17 @@ nslookup -query=hinfo  -timeout=10
                 </listitem>
               </varlistentry>
 
+              <varlistentry>
+                <term><constant>ndots=</constant><replaceable>number</replaceable></term>
+                <listitem>
+                  <para>
+                   Set the number of dots (label separators) in a domain
+                   that will disable searching.  Absolute names always
+                   stop searching.
+                  </para>
+                </listitem>
+              </varlistentry>
+
               <varlistentry>
                 <term><constant>retry=</constant><replaceable>number</replaceable></term>
                 <listitem>