]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Pullup, to make domain= code work under dig and vc option work under
authorMichael Sawyer <source@isc.org>
Mon, 30 Oct 2000 17:21:45 +0000 (17:21 +0000)
committerMichael Sawyer <source@isc.org>
Mon, 30 Oct 2000 17:21:45 +0000 (17:21 +0000)
nslookup.

Reviewed by Brian

bin/dig/dig.c
bin/dig/dighost.c
bin/dig/nslookup.c

index e7a25931d596957d985ac98db1b38ef23a914b43..9da8ccfc7fe1a9ca65d5d16135d82ddeec5d3798 100644 (file)
@@ -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 <config.h>
 #include <stdlib.h>
@@ -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;
index aaf4f3a91e860cfb2b463a52a55d128ad5ffa7eb..bae89e8b671f6180fe54fc2b3f8af6b1da6136ec 100644 (file)
@@ -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);
index 0818cf0b0f12da4e5f1571f01df835224f886f5a..3a3c8f389c2caebda99c5efb6f07bf1a2465bb2f 100644 (file)
@@ -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 <config.h>
 
@@ -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) {