]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
nslookup exit with error if unsuccessful
authorEvan Hunt <each@isc.org>
Fri, 8 Jun 2012 05:09:47 +0000 (22:09 -0700)
committerEvan Hunt <each@isc.org>
Fri, 8 Jun 2012 05:09:47 +0000 (22:09 -0700)
3335. [func] nslookup: return a nonzero exit code when unable
to get an answer. [RT #29492]

CHANGES
bin/dig/nslookup.c

diff --git a/CHANGES b/CHANGES
index e53ad0f3ba9ba580a66dc4f38cca397ce9b94e90..5320215f6a5c0895349db41db9853670fcf9dccc 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3335.  [func]          nslookup: return a nonzero exit code when unable
+                       to get an answer. [RT #29492]
+
 3332.  [bug]           Re-use cached DS rrsets if possible. [RT #29446]
 
 3331.  [security]      dns_rdataslab_fromrdataset could produce bad
index e990055ab23737a3c635c167b68513b93012303f..ba586195e167c2c9440bfa6f3be16651e8f883ec 100644 (file)
@@ -57,6 +57,7 @@ static isc_boolean_t in_use = ISC_FALSE;
 static char defclass[MXRD] = "IN";
 static char deftype[MXRD] = "A";
 static isc_event_t *global_event = NULL;
+static int query_error = 1, print_error = 0;
 
 static char domainopt[DNS_NAME_MAXTEXT];
 
@@ -406,6 +407,9 @@ isc_result_t
 printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
        char servtext[ISC_SOCKADDR_FORMATSIZE];
 
+       /* I've we've gotten this far, we've reached a server. */
+       query_error = 0;
+
        debug("printmessage()");
 
        isc_sockaddr_format(&query->sockaddr, servtext, sizeof(servtext));
@@ -433,6 +437,9 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
                       (msg->rcode != dns_rcode_nxdomain) ? nametext :
                       query->lookup->textname, rcode_totext(msg->rcode));
                debug("returning with rcode == 0");
+
+               /* the lookup failed */
+               print_error |= 1;
                return (ISC_R_SUCCESS);
        }
 
@@ -903,5 +910,5 @@ main(int argc, char **argv) {
        destroy_libs();
        isc_app_finish();
 
-       return (0);
+       return (query_error | print_error);
 }