diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 81bba499b8..d22fafd93c 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dig.c,v 1.91 2000/09/13 00:03:25 mws Exp $ */ +/* $Id: dig.c,v 1.92 2000/09/13 00:27:21 mws Exp $ */ #include #include @@ -960,7 +960,7 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only, rv++; rc--; } - get_address(address, 0, &bind_address); + get_address(address, 0, &bind_address, ISC_FALSE); specified_source = ISC_TRUE; } else if (strncmp(rv[0], "-h", 2) == 0) { show_usage(); diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 9be161d3ce..6f1bad3102 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dighost.c,v 1.123 2000/09/13 00:13:54 gson Exp $ */ +/* $Id: dighost.c,v 1.124 2000/09/13 00:27:23 mws Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -2208,7 +2208,8 @@ recv_done(isc_task_t *task, isc_event_t *event) { * routines, since they may be using a non-DNS system for these lookups. */ void -get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) { +get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr, + isc_boolean_t running) { struct in_addr in4; struct in6_addr in6; #if defined(HAVE_ADDRINFO) && defined(HAVE_GETADDRINFO) @@ -2227,9 +2228,11 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) { else { #if defined(HAVE_ADDRINFO) && defined(HAVE_GETADDRINFO) debug ("before getaddrinfo()"); - isc_app_block(); + if (running) + isc_app_block(); result = getaddrinfo(host, NULL, NULL, &res); - isc_app_unblock(); + if (running) + isc_app_unblock(); if (result != 0) { fatal("Couldn't find server '%s': %s", host, gai_strerror(result)); @@ -2240,9 +2243,11 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) { freeaddrinfo(res); #else debug ("before gethostbyname()"); - isc_app_block(); + if (running) + isc_app_block(); he = gethostbyname(host); - isc_app_unblock(); + if (running) + isc_app_unblock(); if (he == NULL) fatal("Couldn't find server '%s' (h_errno=%d)", host, h_errno); @@ -2283,15 +2288,16 @@ do_lookup_tcp(dig_lookup_t *lookup) { query != NULL; query = ISC_LIST_NEXT(query, link)) { query->waiting_connect = ISC_TRUE; - get_address(query->servname, port, &query->sockaddr); + get_address(query->servname, port, &query->sockaddr, + ISC_TRUE); if (specified_source && (isc_sockaddr_pf(&query->sockaddr) != isc_sockaddr_pf(&bind_address))) { printf(";; Skipping server %s, incompatible " "address family\n", query->servname); - continue; query->waiting_connect = ISC_FALSE; + continue; } INSIST(query->sock == NULL); result = isc_socket_create(socketmgr, @@ -2333,7 +2339,8 @@ do_lookup_udp(dig_lookup_t *lookup) { query = ISC_LIST_NEXT(query, link)) { /* XXX Check the sense of this, need assertion? */ query->waiting_connect = ISC_FALSE; - get_address(query->servname, port, &query->sockaddr); + get_address(query->servname, port, &query->sockaddr, + ISC_TRUE); result = isc_socket_create(socketmgr, isc_sockaddr_pf(&query->sockaddr), diff --git a/bin/dig/host.c b/bin/dig/host.c index ca77b241b9..d7d8bfdebd 100644 --- a/bin/dig/host.c +++ b/bin/dig/host.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: host.c,v 1.52 2000/09/13 00:12:49 gson Exp $ */ +/* $Id: host.c,v 1.53 2000/09/13 00:27:24 mws Exp $ */ #include #include @@ -415,6 +415,20 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) { UNUSED(headers); + if (listed_server) { + printf("Using domain server:\n"); + printf("Name: %s\n", query->servname); + result = isc_buffer_allocate(mctx, &b, MXNAME); + check_result(result, "isc_buffer_allocate"); + result = isc_sockaddr_totext(&query->sockaddr, b); + check_result(result, "isc_sockaddr_totext"); + printf("Address: %.*s\n", + (int)isc_buffer_usedlength(b), + (char*)isc_buffer_base(b)); + isc_buffer_free(&b); + printf("Aliases: \n\n"); + } + if (msg->rcode != 0) { result = isc_buffer_allocate(mctx, &b, MXNAME); check_result(result, "isc_buffer_allocate"); @@ -492,20 +506,6 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) { ISC_TF(!short_form), query); if (result != ISC_R_SUCCESS) return (result); - } else { - if (short_form && listed_server) { - printf("Using domain server:\n"); - printf("Name: %s\n", query->servname); - result = isc_buffer_allocate(mctx, &b, MXNAME); - check_result(result, "isc_buffer_allocate"); - result = isc_sockaddr_totext(&query->sockaddr, b); - check_result(result, "isc_sockaddr_totext"); - printf("Address: %.*s\n", - (int)isc_buffer_usedlength(b), - (char*)isc_buffer_base(b)); - isc_buffer_free(&b); - printf("Aliases: \n\n"); - } } if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_AUTHORITY]) && diff --git a/bin/dig/include/dig/dig.h b/bin/dig/include/dig/dig.h index 85932e9f66..ba57dfc355 100644 --- a/bin/dig/include/dig/dig.h +++ b/bin/dig/include/dig/dig.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dig.h,v 1.44 2000/09/13 00:03:28 mws Exp $ */ +/* $Id: dig.h,v 1.45 2000/09/13 00:27:27 mws Exp $ */ #ifndef DIG_H #define DIG_H @@ -164,7 +164,8 @@ struct dig_searchlist { * Routines in dighost.c. */ void -get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr); +get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr, + isc_boolean_t running); void fatal(const char *format, ...); diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index 8c2a5bc6b1..2f9feebadb 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nslookup.c,v 1.41 2000/09/01 23:43:55 bwelling Exp $ */ +/* $Id: nslookup.c,v 1.42 2000/09/13 00:27:25 mws Exp $ */ #include @@ -545,7 +545,7 @@ show_settings(isc_boolean_t full) { while (srv != NULL) { result = isc_buffer_allocate(mctx, &b, MXNAME); check_result(result, "isc_buffer_allocate"); - get_address(srv->servername, 53, &sockaddr); + get_address(srv->servername, 53, &sockaddr, ISC_FALSE); result = isc_sockaddr_totext(&sockaddr, b); check_result(result, "isc_sockaddr_totext"); printf("Default server: %s\nAddress: %.*s\n",