From: Andreas Gustafsson Date: Fri, 20 Oct 2000 21:54:13 +0000 (+0000) Subject: pullup: X-Git-Tag: v9.0.1rc1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5993bf7f96caed1e629c9337e439070f37101c17;p=thirdparty%2Fbind9.git pullup: various dig patches from Mike --- diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 656bc08cb35..e7a25931d59 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.51.2.9 2000/10/06 19:08:01 mws Exp $ */ +/* $Id: dig.c,v 1.51.2.10 2000/10/20 21:54:08 gson Exp $ */ #include #include @@ -78,13 +78,13 @@ dig_lookup_t *default_lookup = NULL; extern isc_uint32_t name_limit; extern isc_uint32_t rr_limit; -extern isc_boolean_t debugging, show_packets; +extern isc_boolean_t debugging, memdebugging; char *batchname = NULL; FILE *batchfp = NULL; char *argv0; isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE, - nibble = ISC_FALSE; + nibble = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE; isc_uint16_t bufsize = 0; isc_boolean_t forcecomment = ISC_FALSE; @@ -356,14 +356,12 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) { check_result(result, "isc_buffer_allocate"); if (query->lookup->comments && !short_form) { - if (!query->lookup->doing_xfr) { - if (query->lookup->cmdline[0] != 0) - printf ("; %s\n",query->lookup->cmdline); - if (msg == query->lookup->sendmsg) - printf(";; Sending:\n"); - else - printf(";; Got answer:\n"); - } + if (query->lookup->cmdline[0] != 0) + printf("; %s\n", query->lookup->cmdline); + if (msg == query->lookup->sendmsg) + printf(";; Sending:\n"); + else + printf(";; Got answer:\n"); if (headers) { printf(";; ->>HEADER<<- opcode: %s, status: %s, " @@ -604,14 +602,14 @@ plus_option(char *option, isc_boolean_t is_batchfile, cmd += 2; state = ISC_FALSE; } - switch (tolower(cmd[0])) { + switch (cmd[0]) { case 'a': - switch (tolower(cmd[1])) { + switch (cmd[1]) { case 'a': /* aaflag */ lookup->aaonly = state; break; case 'd': - switch (tolower(cmd[2])) { + switch (cmd[2]) { case 'd': /* additional */ lookup->section_additional = state; break; @@ -651,7 +649,7 @@ plus_option(char *option, isc_boolean_t is_batchfile, lookup->udpsize = COMMSIZE; break; case 'c': - switch (tolower(cmd[1])) { + switch (cmd[1]) { case 'd':/* cdflag */ lookup->cdflag = state; break; @@ -660,13 +658,15 @@ plus_option(char *option, isc_boolean_t is_batchfile, break; case 'o': /* comments */ lookup->comments = state; + if (lookup == default_lookup) + pluscomm = state; break; default: goto invalid_option; } break; case 'd': - switch (tolower(cmd[1])) { + switch (cmd[1]) { case 'e': lookup->defname = state; break; @@ -686,7 +686,7 @@ plus_option(char *option, isc_boolean_t is_batchfile, lookup->servfail_stops = state; break; case 'i': - switch (tolower(cmd[1])) { + switch (cmd[1]) { case 'd': /* identify */ lookup->identify = state; break; @@ -696,7 +696,7 @@ plus_option(char *option, isc_boolean_t is_batchfile, } break; case 'n': - switch (tolower(cmd[1])) { + switch (cmd[1]) { case 'a': /* namelimit */ if (value == NULL) goto need_value; @@ -733,19 +733,21 @@ plus_option(char *option, isc_boolean_t is_batchfile, } break; case 'q': - switch (tolower(cmd[1])) { + switch (cmd[1]) { case 'r': /* qr */ qr = state; break; case 'u': /* question */ lookup->section_question = state; + if (lookup == default_lookup) + plusquest = state; break; default: goto invalid_option; } break; case 'r': - switch (tolower(cmd[1])) { + switch (cmd[1]) { case 'e': /* recurse */ lookup->recurse = state; break; @@ -761,7 +763,7 @@ plus_option(char *option, isc_boolean_t is_batchfile, } break; case 's': - switch (tolower(cmd[1])) { + switch (cmd[1]) { case 'e': /* search */ usesearch = state; break; @@ -784,7 +786,7 @@ plus_option(char *option, isc_boolean_t is_batchfile, } break; case 't': - switch (tolower(cmd[1])) { + switch (cmd[1]) { case 'c': /* tcp */ if (!is_batchfile) lookup->tcp_mode = state; @@ -799,7 +801,7 @@ plus_option(char *option, isc_boolean_t is_batchfile, timeout = 1; break; case 'r': - switch (tolower(cmd[2])) { + switch (cmd[2]) { case 'a': /* trace */ lookup->trace = state; lookup->trace_root = state; @@ -871,7 +873,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, value_from_next = ISC_TRUE; value = next; } - switch (tolower(cmd)) { + switch (cmd) { case 'd': debugging = ISC_TRUE; return (ISC_FALSE); @@ -879,20 +881,16 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, show_usage(); exit(0); break; - case 'm': - isc_mem_debugging = ISC_TRUE; + case 'm': /* memdebug */ + /* memdebug is handled in preparse_args() */ return (ISC_FALSE); case 'n': nibble = ISC_TRUE; return (ISC_FALSE); - case 'w': - show_packets = ISC_TRUE; - return (ISC_FALSE); - } if (value == NULL) goto invalid_option; - switch (tolower(cmd)) { + switch (cmd) { case 'b': get_address(value, 0, &bind_address); specified_source = ISC_TRUE; @@ -926,15 +924,21 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, (*lookup)->rdtype = dns_rdatatype_ixfr; (*lookup)->ixfr_serial = atoi(&value[5]); + (*lookup)->section_question = plusquest; + (*lookup)->comments = pluscomm; return (value_from_next); } tr.base = value; tr.length = strlen(value); result = dns_rdatatype_fromtext(&rdtype, (isc_textregion_t *)&tr); - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS) { (*lookup)->rdtype = rdtype; - else + if (rdtype == dns_rdatatype_axfr) { + (*lookup)->section_question = plusquest; + (*lookup)->comments = pluscomm; + } + } else fprintf(stderr, ";; Warning, ignoring " "invalid type %s\n", value); @@ -1015,6 +1019,30 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, return (ISC_FALSE); } +/* + * Because we may be trying to do memory allocation recording, we're going + * to need to parse the arguments for the -m *before* we start the main + * argument parsing routine. + * I'd prefer not to have to do this, but I am not quite sure how else to + * fix the problem. Argument parsing in dig involves memory allocation + * by its nature, so it can't be done in the main argument parser. + */ +static void +preparse_args(int argc, char **argv) { + int rc; + char **rv; + + rc = argc; + rv = argv; + for (rc--, rv++; rc > 0; rc--, rv++) { + if (strcmp(rv[0], "-m") == 0) { + memdebugging = ISC_TRUE; + isc_mem_debugging = ISC_TRUE; + return; + } + } +} + static void parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only, int argc, char **argv) { @@ -1028,12 +1056,12 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only, isc_boolean_t open_type_class = ISC_TRUE; char batchline[MXNAME]; int bargc; - char *bargv[16]; + char *bargv[64]; int rc; char **rv; #ifndef NOPOSIX char *homedir; - char rcfile[132]; + char rcfile[256]; #endif char *input; @@ -1059,7 +1087,7 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only, */ homedir = getenv("HOME"); if (homedir != NULL) - snprintf(rcfile, 132, "%s/.digrc", homedir); + snprintf(rcfile, sizeof(rcfile), "%s/.digrc", homedir); else strcpy(rcfile, ".digrc"); batchfp = fopen(rcfile, "r"); @@ -1071,7 +1099,7 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only, input = batchline; bargv[bargc] = next_token(&input, " \t\r\n"); while ((bargv[bargc] != NULL) && - (bargc < 14)) { + (bargc < 62)) { bargc++; bargv[bargc] = next_token(&input, " \t\r\n"); } @@ -1128,12 +1156,19 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only, lookup->rdtype = dns_rdatatype_ixfr; lookup->ixfr_serial = atoi(&rv[0][5]); + lookup->section_question = plusquest; + lookup->comments = pluscomm; continue; } result = dns_rdatatype_fromtext(&rdtype, (isc_textregion_t *)&tr); if ((result == ISC_R_SUCCESS) && (rdtype != dns_rdatatype_ixfr)) { + if (rdtype == dns_rdatatype_axfr) { + lookup->section_question = + plusquest; + lookup->comments = pluscomm; + } lookup->rdtype = rdtype; continue; } @@ -1275,6 +1310,7 @@ main(int argc, char **argv) { ISC_LIST_INIT(search_list); debug("main()"); + preparse_args(argc, argv); progname = argv[0]; result = isc_app_start(); check_result(result, "isc_app_start"); @@ -1294,8 +1330,6 @@ main(int argc, char **argv) { (dig_server_t *)s2, link); isc_mem_free(mctx, s2); } - if (isc_mem_debugging != 0) - isc_mem_stats(mctx, stderr); isc_mem_free(mctx, default_lookup); if (batchname != NULL) { if (batchfp != stdin) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 41a8a84d652..aaf4f3a91e8 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.58.2.12 2000/10/06 19:08:03 mws Exp $ */ +/* $Id: dighost.c,v 1.58.2.13 2000/10/20 21:54:09 gson Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -36,6 +36,7 @@ extern int h_errno; #endif +#include #include #include #include @@ -46,6 +47,7 @@ extern int h_errno; #include #include #include + #include #include @@ -75,8 +77,7 @@ isc_boolean_t qr = ISC_FALSE, is_dst_up = ISC_FALSE, have_domain = ISC_FALSE, - is_blocking =ISC_FALSE, - show_packets = ISC_FALSE; + is_blocking =ISC_FALSE; in_port_t port = 53; unsigned int timeout = 0; @@ -115,6 +116,7 @@ isc_boolean_t validated = ISC_TRUE; isc_entropy_t *entp = NULL; isc_mempool_t *commctx = NULL; isc_boolean_t debugging = ISC_FALSE; +isc_boolean_t memdebugging = ISC_FALSE; char *progname = NULL; isc_mutex_t lookup_lock; dig_lookup_t *current_lookup = NULL; @@ -181,7 +183,7 @@ hex_dump(isc_buffer_t *b) { printf("%d bytes\n", r.length); for (len = 0; len < r.length; len++) { printf("%02x ", r.base[len]); - if (len != 0 && len % 16 == 0) + if (len % 16 == 15) printf("\n"); } if (len % 16 != 0) @@ -2099,8 +2101,6 @@ recv_done(isc_task_t *task, isc_event_t *event) { UNUSED(task); INSIST(!free_now); - if (show_packets) - puts(";; begin of DNS packet"); debug("recv_done()"); LOCK_LOOKUP; @@ -2316,11 +2316,7 @@ recv_done(isc_task_t *task, isc_event_t *event) { query); } } else { - if (query->first_soa_rcvd && - l->doing_xfr) - printmessage(query, msg, ISC_FALSE); - else - printmessage(query, msg, ISC_TRUE); + printmessage(query, msg, ISC_TRUE); } } else if ((dns_message_firstname(msg, DNS_SECTION_ANSWER) == ISC_R_SUCCESS) && @@ -2630,7 +2626,7 @@ destroy_libs(void) { UNLOCK_LOOKUP; DESTROYLOCK(&lookup_lock); - if (isc_mem_debugging != 0) + if (memdebugging != 0) isc_mem_stats(mctx, stderr); if (mctx != NULL) isc_mem_destroy(&mctx); diff --git a/bin/dig/host.c b/bin/dig/host.c index 643dc4c5adb..80499c9e8d1 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.29.2.7 2000/10/06 19:08:05 mws Exp $ */ +/* $Id: host.c,v 1.29.2.8 2000/10/20 21:54:11 gson Exp $ */ #include #include @@ -196,7 +196,7 @@ static const char *rtypetext[] = { "has 97 record", /* 97 */ "has 98 record", /* 98 */ "has 99 record", /* 99 */ - "UNIFO", /* 100 */ + "UINFO", /* 100 */ "UID", /* 101 */ "GID", /* 102 */ "UNSPEC"}; /* 103 */ diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index fd9a0da6ae3..0818cf0b0f1 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.20.2.9 2000/10/06 19:08:06 mws Exp $ */ +/* $Id: nslookup.c,v 1.20.2.10 2000/10/20 21:54:13 gson Exp $ */ #include @@ -533,7 +533,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) { if (((msg->flags & DNS_MESSAGEFLAG_AA) == 0) && (query->lookup->rdtype != dns_rdatatype_a)) { - puts("\nAuthorative answers can be found from:"); + puts("\nAuthoritative answers can be found from:"); printsection(query, msg, headers, DNS_SECTION_AUTHORITY); printsection(query, msg, headers,