diff --git a/CHANGES b/CHANGES index e0851ea43d..5c00169c7e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3335. [func] nslookup: return a nonzero exit code when unable + to get an answer. [RT #29492] + 3334. [bug] Hold a zone table reference while performing a asyncronous load of a zone. [RT #28326] diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index 2f56b8522a..63897b29b0 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -65,6 +65,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]; @@ -414,6 +415,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)); @@ -441,6 +445,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); } @@ -909,5 +916,5 @@ main(int argc, char **argv) { destroy_libs(); isc_app_finish(); - return (0); + return (query_error | print_error); }