]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] host recognizes /etc/resolv.conf options
authorEvan Hunt <each@isc.org>
Fri, 18 Apr 2014 00:04:51 +0000 (17:04 -0700)
committerEvan Hunt <each@isc.org>
Fri, 18 Apr 2014 00:04:51 +0000 (17:04 -0700)
3813. [func] "host" now recognizes the "timeout", "attempts" and
"debug" options when set in /etc/resolv.conf.
(Thanks to Adam Tkac at RedHat.) [RT #21885]

CHANGES
bin/dig/dig.c
bin/dig/dighost.c
bin/dig/host.c
bin/dig/host.docbook
bin/dig/include/dig/dig.h
bin/dig/nslookup.c
lib/lwres/include/lwres/lwres.h
lib/lwres/lwconfig.c

diff --git a/CHANGES b/CHANGES
index 94ea37ccb66a6d2fd944283cb63ae34b934753be..498856f45374cefa695b28c2e456afb43046057f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+3813.  [func]          "host" now recognizes the "timeout", "attempts" and
+                       "debug" options when set in /etc/resolv.conf.
+                       (Thanks to Adam Tkac at RedHat.) [RT #21885]
+
 3812.  [func]          Dig now supports sending arbitary EDNS options from
                        the command line (+ednsopt=code[:value]). [RT #35584]
 
index e9a537b5a2c1aa729794c66b3b7096d06c69c968..bf3aa2fd9119d64bd9af82354f5b74bdffe42c2c 100644 (file)
@@ -1974,8 +1974,8 @@ main(int argc, char **argv) {
        result = isc_app_start();
        check_result(result, "isc_app_start");
        setup_libs();
-       parse_args(ISC_FALSE, ISC_FALSE, argc, argv);
        setup_system();
+       parse_args(ISC_FALSE, ISC_FALSE, argc, argv);
        if (domainopt[0] != '\0') {
                set_search_domain(domainopt);
                usesearch = ISC_TRUE;
index cfc796164421a94aa7b4998b64483de9fa355a7c..cb0bcd2d4cd7c59eaf9f709bd1864853557c79e7 100644 (file)
@@ -126,7 +126,8 @@ isc_boolean_t
        showsearch = ISC_FALSE,
        qr = ISC_FALSE,
        is_dst_up = ISC_FALSE,
-       keep_open = ISC_FALSE;
+       keep_open = ISC_FALSE,
+       verbose = ISC_FALSE;
 in_port_t port = 53;
 unsigned int timeout = 0;
 unsigned int extrabytes;
@@ -1330,10 +1331,24 @@ setup_system(void) {
                }
        }
 
+       if (lwconf->resdebug) {
+               verbose = ISC_TRUE;
+               debug("verbose is on");
+       }
        if (ndots == -1) {
                ndots = lwconf->ndots;
                debug("ndots is %d.", ndots);
        }
+       if (lwconf->attempts) {
+               tries = lwconf->attempts + 1;
+               if (tries < 2)
+                       tries = 2;
+               debug("tries is %d.", tries);
+       }
+       if (lwconf->timeout) {
+               timeout = lwconf->timeout;
+               debug("timeout is %d.", timeout);
+       }
 
        /* If user doesn't specify server use nameservers from resolv.conf. */
        if (ISC_LIST_EMPTY(server_list))
index 391ed802cb51dc268f9d8dba1f9f1a1d6d664e2d..460094b3ffcd8f435c5d707cae7fc05fc0913153 100644 (file)
@@ -681,6 +681,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
 
        lookup->servfail_stops = ISC_FALSE;
        lookup->comments = ISC_FALSE;
+       short_form = !verbose;
 
        while ((c = isc_commandline_parse(argc, argv, optstring)) != -1) {
                switch (c) {
@@ -891,8 +892,8 @@ main(int argc, char **argv) {
        result = isc_app_start();
        check_result(result, "isc_app_start");
        setup_libs();
-       parse_args(ISC_FALSE, argc, argv);
        setup_system();
+       parse_args(ISC_FALSE, argc, argv);
        result = isc_app_onrun(mctx, global_task, onrun_callback, NULL);
        check_result(result, "isc_app_onrun");
        isc_app_run();
index 30fc441044efb8ea738836b5a3941378621e1ead..430a1c6f3786e6d1aa16c36cb3974f1a7d42527a 100644 (file)
       options are equivalent.  They have been provided for backwards
       compatibility.  In previous versions, the <option>-d</option> option
       switched on debugging traces and <option>-v</option> enabled verbose
-      output.
+      output.  Verbose output can also be enabled by setting the
+      <parameter>debug</parameter> option in
+      <filename>/etc/resolv.conf</filename>.
     </para>
 
     <para>
       indicates
       how many times <command>host</command> will repeat a query
       that does
-      not get answered.  The default number of retries is 1.  If
+      not get answered.  If
       <parameter>number</parameter> is negative or zero, the
       number of
-      retries will default to 1.
+      retries will default to 1.  The default value is 1, or
+      the value of the <parameter>attempts</parameter> option in
+      <filename>/etc/resolv.conf</filename>, if set.
     </para>
 
     <para>
       will
       effectively wait forever for a reply.  The time to wait for a response
       will be set to the number of seconds given by the hardware's maximum
-      value for an integer quantity.
+      value for an integer quantity.  By default, <command>host</command>
+      will wait for 5 seconds for UDP responses and 10 seconds for TCP
+      connections.  These defaults can be overridden by the
+      <parameter>timeout</parameter> option in
+      <filename>/etc/resolv.conf</filename>.
     </para>
 
     <para>
index e5effffe56ef78c5571ba78686216c0c863f672c..a95fb0aa74e97dffe7878f26006eb3deb76fe8f6 100644 (file)
@@ -292,6 +292,7 @@ extern isc_boolean_t keep_open;
 extern char *progname;
 extern int tries;
 extern int fatalexit;
+extern isc_boolean_t verbose;
 #ifdef WITH_IDN
 extern int idnoptions;
 #endif
index 051ed34b9415ac5d5620fc5286025e6a13795f5c..ed58ce61bf064c0cf9ed603e316d155928c3de26 100644 (file)
@@ -909,9 +909,8 @@ main(int argc, char **argv) {
        setup_libs();
        progname = argv[0];
 
-       parse_args(argc, argv);
-
        setup_system();
+       parse_args(argc, argv);
        if (domainopt[0] != '\0')
                set_search_domain(domainopt);
        if (in_use)
index 6912448cf9ee86d9ef589b782925b013e0dad540..c83240cefb1feb21129f57b7ffa016db6254b5d7 100644 (file)
@@ -243,6 +243,8 @@ typedef struct {
        lwres_uint8_t   resdebug;      /*%< non-zero if 'options debug' set */
        lwres_uint8_t   ndots;         /*%< set to n in 'options ndots:n' */
        lwres_uint8_t   no_tld_query;  /*%< non-zero if 'options no_tld_query' */
+       lwres_int32_t   attempts;      /*%< set to n in 'options attempts:n' */
+       lwres_int32_t   timeout;       /*%< set to n in 'options timeout:n' */
 } lwres_conf_t;
 
 #define LWRES_ADDRTYPE_V4              0x00000001U     /*%< ipv4 */
index 62630238e1211b084b7191ec6202fd7642b5ecd5..52f3c8ce2029214e36e4807260f84e10edf66dbb 100644 (file)
@@ -237,6 +237,8 @@ lwres_conf_init(lwres_context_t *ctx) {
        confdata->resdebug = 0;
        confdata->ndots = 1;
        confdata->no_tld_query = 0;
+       confdata->attempts = 0;
+       confdata->timeout = 0;
 
        for (i = 0; i < LWRES_CONFMAXNAMESERVERS; i++)
                lwres_resetaddr(&confdata->nameservers[i]);
@@ -289,6 +291,8 @@ lwres_conf_clear(lwres_context_t *ctx) {
        confdata->resdebug = 0;
        confdata->ndots = 1;
        confdata->no_tld_query = 0;
+       confdata->attempts = 0;
+       confdata->timeout = 0;
 }
 
 static lwres_result_t
@@ -530,6 +534,8 @@ static lwres_result_t
 lwres_conf_parseoption(lwres_context_t *ctx,  FILE *fp) {
        int delim;
        long ndots;
+       long attempts;
+       long timeout;
        char *p;
        char word[LWRES_CONFMAXLINELEN];
        lwres_conf_t *confdata;
@@ -546,6 +552,8 @@ lwres_conf_parseoption(lwres_context_t *ctx,  FILE *fp) {
                        confdata->resdebug = 1;
                } else if (strcmp("no_tld_query", word) == 0) {
                        confdata->no_tld_query = 1;
+               } else if (strcmp("debug", word) == 0) {
+                       confdata->resdebug = 1;
                } else if (strncmp("ndots:", word, 6) == 0) {
                        ndots = strtol(word + 6, &p, 10);
                        if (*p != '\0') /* Bad string. */
@@ -553,6 +561,18 @@ lwres_conf_parseoption(lwres_context_t *ctx,  FILE *fp) {
                        if (ndots < 0 || ndots > 0xff) /* Out of range. */
                                return (LWRES_R_FAILURE);
                        confdata->ndots = (lwres_uint8_t)ndots;
+               } else if (strncmp("timeout:", word, 8) == 0) {
+                       timeout = strtol(word + 8, &p, 10);
+                       if (*p != '\0') /* Bad string. */
+                               return (LWRES_R_FAILURE);
+                       confdata->timeout = (lwres_int32_t)timeout;
+               } else if (strncmp("attempts:", word, 9) == 0) {
+                       attempts = strtol(word + 9, &p, 10);
+                       if (*p != '\0') /* Bad string. */
+                               return (LWRES_R_FAILURE);
+                       if (attempts < 0) /* Out of range. */
+                               return (LWRES_R_FAILURE);
+                       confdata->attempts = (lwres_int32_t)attempts;
                }
 
                if (delim == EOF || delim == '\n')
@@ -717,6 +737,12 @@ lwres_conf_print(lwres_context_t *ctx, FILE *fp) {
        if (confdata->no_tld_query)
                fprintf(fp, "options no_tld_query\n");
 
+       if (confdata->attempts)
+               fprintf(fp, "options attempts:%d\n", confdata->attempts);
+
+       if (confdata->timeout)
+               fprintf(fp, "options timeout:%d\n", confdata->timeout);
+
        return (LWRES_R_SUCCESS);
 }