2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

[master] Ensure consistent handling of -4/-6 command line options in all tools

4690.	[bug]		Command line options -4/-6 were handled inconsistently
			between tools. [RT #45632]
This commit is contained in:
Michał Kępień
2017-08-16 11:10:24 +02:00
parent 503223b800
commit d6814700de
11 changed files with 86 additions and 16 deletions

View File

@@ -1714,6 +1714,7 @@ preparse_args(int argc, char **argv) {
int rc;
char **rv;
char *option;
isc_boolean_t ipv4only = ISC_FALSE, ipv6only = ISC_FALSE;
rc = argc;
rv = argv;
@@ -1727,6 +1728,18 @@ preparse_args(int argc, char **argv) {
isc_mem_debugging = ISC_MEM_DEBUGTRACE |
ISC_MEM_DEBUGRECORD;
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];
}
@@ -1884,6 +1897,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv)
int
main(int argc, char *argv[]) {
struct query *query;
isc_result_t result;
isc_sockaddr_t bind_any;
isc_log_t *lctx;
isc_logconfig_t *lcfg;
@@ -1932,7 +1946,12 @@ main(int argc, char *argv[]) {
fatal("a server '@xxx' is required");
ns = 0;
RUNCHECK(bind9_getaddresses(server, port, &dstaddr, 1, &ns));
result = bind9_getaddresses(server, port, &dstaddr, 1, &ns);
if (result != ISC_R_SUCCESS) {
fatal("couldn't get address for '%s': %s",
server, isc_result_totext(result));
}
if (isc_sockaddr_pf(&dstaddr) == PF_INET && have_ipv6) {
isc_net_disableipv6();
have_ipv6 = ISC_FALSE;