]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Change 3813 broke dig/host -4/-6. No CHANGES as this is has not been released
authorMark Andrews <marka@isc.org>
Wed, 12 Aug 2015 02:50:15 +0000 (12:50 +1000)
committerMark Andrews <marka@isc.org>
Wed, 12 Aug 2015 02:50:15 +0000 (12:50 +1000)
bin/dig/dig.c
bin/dig/dighost.c
bin/dig/host.c
bin/dig/include/dig/dig.h
bin/dig/nslookup.c

index 314b41eb97940a2f6f0183499745be6c02761e56..43907909c860c5a12abea72a614d43d3263a2273 100644 (file)
@@ -68,7 +68,8 @@ static isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
        ip6_int = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE,
        multiline = ISC_FALSE, nottl = ISC_FALSE, noclass = ISC_FALSE,
        onesoa = ISC_FALSE, rrcomments = ISC_FALSE, use_usec = ISC_FALSE,
-       nocrypto = ISC_FALSE, ttlunits = ISC_FALSE;
+       nocrypto = ISC_FALSE, ttlunits = ISC_FALSE, ipv4only = ISC_FALSE,
+       ipv6only = ISC_FALSE;
 static isc_uint32_t splitwidth = 0xffffffff;
 
 /*% opcode text */
@@ -1715,11 +1716,22 @@ preparse_args(int argc, char **argv) {
                        continue;
                option = &rv[0][1];
                while (strpbrk(option, single_dash_opts) == &option[0]) {
-                       if (option[0] == 'm') {
+                       switch (option[0]) {
+                       case 'm':
                                memdebugging = ISC_TRUE;
                                isc_mem_debugging = ISC_MEM_DEBUGTRACE |
                                        ISC_MEM_DEBUGRECORD;
-                               return;
+                               break;
+                       case '4':
+                               if (ipv6only)
+                                       fatal("only one of -4 and -6 allowed");
+                               ipv4only = ISC_TRUE;
+                               break;
+                       case '6':
+                               if (ipv4only)
+                                       fatal("only one of -4 and -6 allowed");
+                               ipv6only = ISC_TRUE;
+                               break;
                        }
                        option = &option[1];
                }
@@ -2081,12 +2093,12 @@ main(int argc, char **argv) {
        ISC_LIST_INIT(search_list);
 
        debug("main()");
-       preparse_args(argc, argv);
        progname = argv[0];
+       preparse_args(argc, argv);
        result = isc_app_start();
        check_result(result, "isc_app_start");
        setup_libs();
-       setup_system();
+       setup_system(ipv4only, ipv6only);
        parse_args(ISC_FALSE, ISC_FALSE, argc, argv);
        if (keyfile[0] != 0)
                setup_file_key();
index 36441f0c2d0fa2ec7d65045a26a013d0466e76fd..28ac5ece3e9ef3edf71d5b20cf904a07d7a16739 100644 (file)
@@ -1339,7 +1339,7 @@ create_search_list(lwres_conf_t *confdata) {
  * settings.
  */
 void
-setup_system(void) {
+setup_system(isc_boolean_t ipv4only, isc_boolean_t ipv6only) {
        dig_searchlist_t *domain = NULL;
        lwres_result_t lwresult;
        unsigned int lwresflags;
@@ -1347,6 +1347,24 @@ setup_system(void) {
 
        debug("setup_system()");
 
+       if (ipv4only) {
+               if (have_ipv4) {
+                       isc_net_disableipv6();
+                       have_ipv6 = ISC_FALSE;
+               } else {
+                       fatal("can't find IPv4 networking");
+               }
+       }
+
+       if (ipv6only) {
+               if (have_ipv6) {
+                       isc_net_disableipv4();
+                       have_ipv4 = ISC_FALSE;
+               } else {
+                       fatal("can't find IPv6 networking");
+               }
+       }
+
        lwresflags = LWRES_CONTEXT_SERVERMODE;
        if (have_ipv4)
                lwresflags |= LWRES_CONTEXT_USEIPV4;
index aa8685fa2c3b272837d95e07a98f079d9e2e0a0a..8f30f6740ac5c6eaaa2c0951aae269cba3f71396 100644 (file)
@@ -59,6 +59,7 @@ static int seen_error = -1;
 static isc_boolean_t list_addresses = ISC_TRUE;
 static dns_rdatatype_t list_type = dns_rdatatype_a;
 static isc_boolean_t printed_server = ISC_FALSE;
+static isc_boolean_t ipv4only = ISC_FALSE, ipv6only = ISC_FALSE;
 
 static const char *opcodetext[] = {
        "QUERY",
@@ -628,8 +629,16 @@ pre_parse_args(int argc, char **argv) {
                                isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
                        break;
 
-               case '4': break;
-               case '6': break;
+               case '4':
+                       if (ipv6only)
+                               fatal("only one of -4 and -6 allowed");
+                       ipv4only = ISC_TRUE;
+                       break;
+               case '6':
+                       if (ipv4only)
+                               fatal("only one of -4 and -6 allowed");
+                       ipv6only = ISC_TRUE;
+                       break;
                case 'a': break;
                case 'c': break;
                case 'd': break;
@@ -824,18 +833,10 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
                        /* Handled by pre_parse_args(). */
                        break;
                case '4':
-                       if (have_ipv4) {
-                               isc_net_disableipv6();
-                               have_ipv6 = ISC_FALSE;
-                       } else
-                               fatal("can't find IPv4 networking");
+                       /* Handled by pre_parse_args(). */
                        break;
                case '6':
-                       if (have_ipv6) {
-                               isc_net_disableipv4();
-                               have_ipv4 = ISC_FALSE;
-                       } else
-                               fatal("can't find IPv6 networking");
+                       /* Handled by pre_parse_args(). */
                        break;
                case 's':
                        lookup->servfail_stops = ISC_TRUE;
@@ -895,7 +896,7 @@ main(int argc, char **argv) {
        result = isc_app_start();
        check_result(result, "isc_app_start");
        setup_libs();
-       setup_system();
+       setup_system(ipv4only, ipv6only);
        parse_args(ISC_FALSE, argc, argv);
        if (keyfile[0] != 0)
                setup_file_key();
index a2984a50276f6bc636a51e4b65e61b6495fe9381..478f8377ce21e98a94557bb04c3a0760aa53185f 100644 (file)
@@ -345,7 +345,7 @@ void
 setup_libs(void);
 
 void
-setup_system(void);
+setup_system(isc_boolean_t ipv4only, isc_boolean_t ipv6only);
 
 isc_result_t
 parse_uint(isc_uint32_t *uip, const char *value, isc_uint32_t max,
index 0d364becc284bde0902d3506a403b051002e3cb0..fcca7f8eba6bbe942d3d4258928878d34a36dc0c 100644 (file)
@@ -908,7 +908,7 @@ main(int argc, char **argv) {
        setup_libs();
        progname = argv[0];
 
-       setup_system();
+       setup_system(ISC_FALSE, ISC_FALSE);
        parse_args(argc, argv);
        if (keyfile[0] != 0)
                setup_file_key();