302b22
From ba56e64560c5907e99186116623f2899b8520b68 Mon Sep 17 00:00:00 2001
302b22
From: Petr Mensik <pemensik@redhat.com>
302b22
Date: Wed, 2 Oct 2019 14:00:13 +0200
302b22
Subject: [PATCH] Revert "3640.   [bug]           ndots was not being checked
302b22
 when searching.  Only"
302b22
302b22
This reverts commit 8afea636ab0c07399aa3e2410b2cfbd41099df98.
302b22
302b22
Revert is only partial. Absolute names does not search. Name with dots
302b22
tries first absolute, then relative with search appended.
302b22
---
302b22
 bin/dig/dighost.c        | 8 +++-----
302b22
 bin/dig/nslookup.c       | 3 ++-
302b22
 bin/dig/nslookup.docbook | 2 +-
302b22
 3 files changed, 6 insertions(+), 7 deletions(-)
302b22
302b22
diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c
302b22
index d46379ddc2..30b19b3121 100644
302b22
--- a/bin/dig/dighost.c
302b22
+++ b/bin/dig/dighost.c
302b22
@@ -2273,14 +2273,12 @@ next_origin(dig_lookup_t *oldlookup) {
302b22
 		return (ISC_FALSE);
302b22
 
302b22
 	/*
302b22
-	 * Check for a absolute name or ndots being met.
302b22
+	 * Check for a absolute name.
302b22
 	 */
302b22
 	name = dns_fixedname_initname(&fixed);
302b22
 	result = dns_name_fromstring2(name, oldlookup->textname, NULL,
302b22
 				      0, NULL);
302b22
-	if (result == ISC_R_SUCCESS &&
302b22
-	    (dns_name_isabsolute(name) ||
302b22
-	     (int)dns_name_countlabels(name) > ndots))
302b22
+	if (result == ISC_R_SUCCESS && dns_name_isabsolute(name))
302b22
 		return (ISC_FALSE);
302b22
 
302b22
 	if (oldlookup->origin == NULL && !oldlookup->need_search)
302b22
@@ -4215,7 +4213,7 @@ recv_done(isc_task_t *task, isc_event_t *event) {
302b22
 	} else if (l->sendcookie && msg->opt != NULL)
302b22
 		process_opt(l, msg);
302b22
 	if (!l->doing_xfr || l->xfr_q == query) {
302b22
-		if (msg->rcode == dns_rcode_nxdomain &&
302b22
+		if (msg->rcode != dns_rcode_noerror &&
302b22
 		    (l->origin != NULL || l->need_search)) {
302b22
 			if (!next_origin(query->lookup) || showsearch) {
302b22
 				dighost_printmessage(query, msg, ISC_TRUE);
302b22
diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c
302b22
index 89a615bf1c..5c8aa51a48 100644
302b22
--- a/bin/dig/nslookup.c
302b22
+++ b/bin/dig/nslookup.c
302b22
@@ -472,7 +472,8 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
302b22
 		dns_name_format(query->lookup->name,
302b22
 				nametext, sizeof(nametext));
302b22
 		printf("** server can't find %s: %s\n",
302b22
-		       nametext, rcode_totext(msg->rcode));
302b22
+		       (msg->rcode != dns_rcode_nxdomain) ? nametext :
302b22
+		       query->lookup->textname, rcode_totext(msg->rcode));
302b22
 		debug("returning with rcode == 0");
302b22
 
302b22
 		/* the lookup failed */
302b22
diff --git a/bin/dig/nslookup.docbook b/bin/dig/nslookup.docbook
302b22
index 86a09c658e..e3e8869e33 100644
302b22
--- a/bin/dig/nslookup.docbook
302b22
+++ b/bin/dig/nslookup.docbook
302b22
@@ -412,7 +412,7 @@ nslookup -query=hinfo  -timeout=10
302b22
                 <listitem>
302b22
                   <para>
302b22
 		    Set the number of dots (label separators) in a domain
302b22
-		    that will disable searching.  Absolute names always
302b22
+		    that will reverse order of searching.  Absolute names always
302b22
 		    stop searching.
302b22
                   </para>
302b22
                 </listitem>
302b22
-- 
302b22
2.20.1
302b22