From: Michael Sawyer Date: Mon, 30 Oct 2000 17:21:45 +0000 (+0000) Subject: Pullup, to make domain= code work under dig and vc option work under X-Git-Tag: v9.0.1rc1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35f705870be8e72d30984058178a6eaac6c47033;p=thirdparty%2Fbind9.git Pullup, to make domain= code work under dig and vc option work under nslookup. Reviewed by Brian --- diff --git a/bin/dig/dig.c b/bin/dig/dig.c index e7a25931d59..9da8ccfc7fe 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.10 2000/10/20 21:54:08 gson Exp $ */ +/* $Id: dig.c,v 1.51.2.11 2000/10/30 17:21:41 mws Exp $ */ #include #include @@ -677,6 +677,7 @@ plus_option(char *option, isc_boolean_t is_batchfile, goto invalid_option; strncpy(fixeddomain, value, sizeof(fixeddomain)); fixeddomain[sizeof(fixeddomain)-1]=0; + usesearch = state; break; default: goto invalid_option; diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index aaf4f3a91e8..bae89e8b671 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.13 2000/10/20 21:54:09 gson Exp $ */ +/* $Id: dighost.c,v 1.58.2.14 2000/10/30 17:21:43 mws Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -96,6 +96,7 @@ int ndots = -1; int tries = 2; int lookup_counter = 0; char fixeddomain[MXNAME] = ""; +dig_searchlist_t *fixedsearch = NULL; /* * Exit Codes: * 0 Everything went well, including things like NXDOMAIN @@ -526,19 +527,6 @@ setup_system(void) { debug("setup_system()"); - if (fixeddomain[0] != 0) { - debug("using fixed domain %s", fixeddomain); - search = isc_mem_allocate(mctx, sizeof(struct dig_server)); - if (search == NULL) - fatal("Memory allocation failure in %s:%d", - __FILE__, __LINE__); - strncpy(search->origin, fixeddomain, - sizeof(search->origin)); - search->origin[sizeof(search->origin)-1]=0; - /* XXX Check ordering, with search -vs- domain */ - ISC_LIST_PREPEND(search_list, search, link); - } - free_now = ISC_FALSE; get_servers = ISC_TF(server_list.head == NULL); fp = fopen(RESOLVCONF, "r"); @@ -1051,6 +1039,16 @@ next_origin(dns_message_t *msg, dig_query_t *query) { debug("next_origin()"); debug("following up %s", query->lookup->textname); + if (fixedsearch == query->lookup->origin) { + /* + * This is a fixed domain search; there is no next entry. + * While we're here, clear out the fixedsearch alloc. + */ + isc_mem_free(mctx, fixedsearch); + fixedsearch = NULL; + query->lookup->origin = NULL; + return (ISC_FALSE); + } if (!usesearch) /* * We're not using a search list, so don't even think @@ -1189,8 +1187,23 @@ setup_lookup(dig_lookup_t *lookup) { if ((count_dots(lookup->textname) >= ndots) || lookup->defname) lookup->origin = NULL; /* Force abs lookup */ else if (lookup->origin == NULL && lookup->new_search && - (usesearch || have_domain)) - lookup->origin = ISC_LIST_HEAD(search_list); + (usesearch || have_domain)) { + if (fixeddomain[0] != 0) { + debug("using fixed domain %s", fixeddomain); + if (fixedsearch != NULL) + isc_mem_free(mctx, fixedsearch); + fixedsearch = isc_mem_allocate(mctx, + sizeof(struct dig_searchlist)); + if (fixedsearch == NULL) + fatal("Memory allocation failure in %s:%d", + __FILE__, __LINE__); + strncpy(fixedsearch->origin, fixeddomain, + sizeof(fixedsearch->origin)); + fixedsearch->origin[sizeof(fixedsearch->origin)-1]=0; + lookup->origin = fixedsearch; + } else + lookup->origin = ISC_LIST_HEAD(search_list); + } if (lookup->origin != NULL) { debug("trying origin %s", lookup->origin->origin); result = dns_message_gettempname(lookup->sendmsg, @@ -2581,6 +2594,11 @@ destroy_libs(void) { free_now = ISC_TRUE; + if (fixedsearch != NULL) { + debug("freeing fixed search"); + isc_mem_free(mctx, fixedsearch); + fixedsearch = NULL; + } s = ISC_LIST_HEAD(server_list); while (s != NULL) { debug("freeing global server %p", s); diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index 0818cf0b0f1..3a3c8f389c2 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.10 2000/10/20 21:54:13 gson Exp $ */ +/* $Id: nslookup.c,v 1.20.2.11 2000/10/30 17:21:45 mws Exp $ */ #include @@ -578,9 +578,7 @@ show_settings(isc_boolean_t full, isc_boolean_t serv_only) { printf("\t timeout = %d\t\tretry = %d\tport = %d\n", timeout, tries, port); printf("\t querytype = %-8s\tclass = %s\n", deftype, defclass); -#if 0 printf("\t domain = %s\n", fixeddomain); -#endif } @@ -650,13 +648,12 @@ setoption(char *opt) { } else if (strncasecmp(opt, "qu=", 3) == 0) { if (testtype(&opt[3])) safecpy(deftype, &opt[3], MXRD); -#if 0 - /* XXXMWS domain= doesn't work now. */ } else if (strncasecmp(opt, "domain=", 7) == 0) { safecpy(fixeddomain, &opt[7], MXNAME); + usesearch = ISC_TRUE; } else if (strncasecmp(opt, "do=", 3) == 0) { safecpy(fixeddomain, &opt[3], MXNAME); -#endif + usesearch = ISC_TRUE; } else if (strncasecmp(opt, "port=", 5) == 0) { port = atoi(&opt[5]); } else if (strncasecmp(opt, "po=", 3) == 0) { @@ -673,6 +670,10 @@ setoption(char *opt) { defname = ISC_TRUE; } else if (strncasecmp(opt, "nodef", 5) == 0) { defname = ISC_FALSE; + } else if (strncasecmp(opt, "vc", 3) == 0) { + tcpmode = ISC_TRUE; + } else if (strncasecmp(opt, "novc", 5) == 0) { + tcpmode = ISC_FALSE; } else if (strncasecmp(opt, "deb", 3) == 0) { short_form = ISC_FALSE; } else if (strncasecmp(opt, "nodeb", 5) == 0) {