From b8f09dec6c11e5ef5f0d35a5f8ec0b6b9ccbfdff Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 25 Aug 2005 00:43:26 +0000 Subject: [PATCH] 1917. [func] dig now warns if 'RA' is not set in the answer when 'RD' was set in the query. host/nslookup skip servers that fail to set 'RA' when 'RD' is set unless a server is explicitly set. [RT #15005] --- CHANGES | 5 +++++ bin/dig/dig.c | 7 ++++++- bin/dig/dighost.c | 21 ++++++++++++++------- bin/dig/host.c | 5 +++-- bin/dig/include/dig/dig.h | 4 ++-- bin/dig/nslookup.c | 10 +++++++--- 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index 6272e92d03..94afe0e176 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +1917. [func] dig now warns if 'RA' is not set in the answer when + 'RD' was set in the query. host/nslookup skip servers + that fail to set 'RA' when 'RD' is set unless a server + is explicitly set. [RT #15005] + 1916. [func] host/nslookup now continue (default)/fail on SERVFAIL. [RT #15006] diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 2628e3ad98..8c1515378f 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dig.c,v 1.186.18.19 2005/08/25 00:20:59 marka Exp $ */ +/* $Id: dig.c,v 1.186.18.20 2005/08/25 00:43:24 marka Exp $ */ /*! \file */ @@ -490,6 +490,11 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) { msg->counts[DNS_SECTION_ANSWER], msg->counts[DNS_SECTION_AUTHORITY], msg->counts[DNS_SECTION_ADDITIONAL]); + + if ((msg->flags & DNS_MESSAGEFLAG_RD) != 0 && + (msg->flags & DNS_MESSAGEFLAG_RA) == 0) + printf(";; WARNING: recusion requested " + "but not available\n"); } if (msg != query->lookup->sendmsg && extrabytes != 0U) printf(";; WARNING: Messages has %u extra byte%s at " diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index c57dd2b86e..e7ba03fe57 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dighost.c,v 1.259.18.21 2005/08/25 00:20:59 marka Exp $ */ +/* $Id: dighost.c,v 1.259.18.22 2005/08/25 00:43:25 marka Exp $ */ /*! \file * \note @@ -96,6 +96,7 @@ dig_serverlist_t server_list; dig_searchlistlist_t search_list; isc_boolean_t + check_ra = ISC_FALSE, have_ipv4 = ISC_FALSE, have_ipv6 = ISC_FALSE, specified_source = ISC_FALSE, @@ -2789,8 +2790,8 @@ recv_done(isc_task_t *task, isc_event_t *event) { UNLOCK_LOOKUP; return; } - if ((msg->flags & DNS_MESSAGEFLAG_TC) != 0 - && !l->ignore && !l->tcp_mode) { + if ((msg->flags & DNS_MESSAGEFLAG_TC) != 0 && + !l->ignore && !l->tcp_mode) { printf(";; Truncated, retrying in TCP mode.\n"); n = requeue_lookup(l, ISC_TRUE); n->tcp_mode = ISC_TRUE; @@ -2803,7 +2804,9 @@ recv_done(isc_task_t *task, isc_event_t *event) { UNLOCK_LOOKUP; return; } - if (msg->rcode == dns_rcode_servfail && !l->servfail_stops) { + if ((msg->rcode == dns_rcode_servfail && !l->servfail_stops) || + (check_ra && (msg->flags & DNS_MESSAGEFLAG_RA) == 0 && l->recurse)) + { dig_query_t *next = ISC_LIST_NEXT(query, link); if (l->current_query == query) l->current_query = NULL; @@ -2821,9 +2824,13 @@ recv_done(isc_task_t *task, isc_event_t *event) { */ if ((ISC_LIST_HEAD(l->q) != query) || (ISC_LIST_NEXT(query, link) != NULL)) { - printf(";; Got SERVFAIL reply from %s, " - "trying next server\n", - query->servname); + if( l->comments == ISC_TRUE ) + printf(";; Got %s from %s, " + "trying next server\n", + msg->rcode == dns_rcode_servfail ? + "SERVFAIL reply" : + "recursion not available", + query->servname); clear_query(query); check_next_lookup(l); dns_message_destroy(&msg); diff --git a/bin/dig/host.c b/bin/dig/host.c index dfa17d99a9..0bd05565fa 100644 --- a/bin/dig/host.c +++ b/bin/dig/host.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: host.c,v 1.94.18.10 2005/08/25 00:33:35 marka Exp $ */ +/* $Id: host.c,v 1.94.18.11 2005/08/25 00:43:25 marka Exp $ */ /*! \file */ @@ -748,7 +748,8 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { set_nameserver(argv[isc_commandline_index+1]); debug("server is %s", argv[isc_commandline_index+1]); listed_server = ISC_TRUE; - } + } else + check_ra = ISC_TRUE; lookup->pending = ISC_FALSE; if (get_reverse(store, sizeof(store), hostname, diff --git a/bin/dig/include/dig/dig.h b/bin/dig/include/dig/dig.h index 93a32089df..f3c12eec17 100644 --- a/bin/dig/include/dig/dig.h +++ b/bin/dig/include/dig/dig.h @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dig.h,v 1.82.18.13 2005/08/25 00:21:01 marka Exp $ */ +/* $Id: dig.h,v 1.82.18.14 2005/08/25 00:43:26 marka Exp $ */ #ifndef DIG_H #define DIG_H @@ -243,7 +243,7 @@ extern dig_serverlist_t server_list; extern dig_searchlistlist_t search_list; extern unsigned int extrabytes; -extern isc_boolean_t have_ipv4, have_ipv6, specified_source, +extern isc_boolean_t check_ra, have_ipv4, have_ipv6, specified_source, usesearch, showsearch, qr; extern in_port_t port; extern unsigned int timeout; diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index e2ba3bd015..861fad76a9 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nslookup.c,v 1.101.18.8 2005/08/25 00:33:36 marka Exp $ */ +/* $Id: nslookup.c,v 1.101.18.9 2005/08/25 00:43:25 marka Exp $ */ #include @@ -734,6 +734,7 @@ get_next_command(void) { (strcasecmp(ptr, "lserver") == 0)) { isc_app_block(); set_nameserver(arg); + check_ra = ISC_FALSE; isc_app_unblock(); show_settings(ISC_TRUE, ISC_TRUE); } else if (strcasecmp(ptr, "exit") == 0) { @@ -772,9 +773,10 @@ parse_args(int argc, char **argv) { have_lookup = ISC_TRUE; in_use = ISC_TRUE; addlookup(argv[0]); - } - else + } else { set_nameserver(argv[0]); + check_ra = ISC_FALSE; + } } } } @@ -850,6 +852,8 @@ main(int argc, char **argv) { ISC_LIST_INIT(server_list); ISC_LIST_INIT(search_list); + check_ra = ISC_TRUE; + result = isc_app_start(); check_result(result, "isc_app_start");