mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +00:00
4824. [port] Add iOS hooks to dig. [RT #42011]
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -1,3 +1,5 @@
|
|||||||
|
4824. [port] Add iOS hooks to dig. [RT #42011]
|
||||||
|
|
||||||
4823. [test] Refactor reclimit system test to improve its
|
4823. [test] Refactor reclimit system test to improve its
|
||||||
reliability and speed. [RT #46632]
|
reliability and speed. [RT #46632]
|
||||||
|
|
||||||
|
@@ -109,6 +109,11 @@ print_usage(FILE *fp) {
|
|||||||
" [ host [@local-server] {local-d-opt} [...]]\n", fp);
|
" [ host [@local-server] {local-d-opt} [...]]\n", fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
static void usage(void) {
|
||||||
|
fprintf(stderr, "Press <Help> for complete list of options\n");
|
||||||
|
}
|
||||||
|
#else
|
||||||
ISC_PLATFORM_NORETURN_PRE static void
|
ISC_PLATFORM_NORETURN_PRE static void
|
||||||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||||
|
|
||||||
@@ -119,6 +124,7 @@ usage(void) {
|
|||||||
"for complete list of options\n", stderr);
|
"for complete list of options\n", stderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*% version */
|
/*% version */
|
||||||
static void
|
static void
|
||||||
@@ -818,8 +824,10 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
goto invalid_option;
|
goto invalid_option;
|
||||||
result = parse_uint(&num, value, COMMSIZE,
|
result = parse_uint(&num, value, COMMSIZE,
|
||||||
"buffer size");
|
"buffer size");
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse buffer size");
|
warn("Couldn't parse buffer size");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
lookup->udpsize = num;
|
lookup->udpsize = num;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -864,8 +872,10 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
n = strlcpy(hexcookie, value,
|
n = strlcpy(hexcookie, value,
|
||||||
sizeof(hexcookie));
|
sizeof(hexcookie));
|
||||||
if (n >= sizeof(hexcookie))
|
if (n >= sizeof(hexcookie)) {
|
||||||
fatal("COOKIE data too large");
|
warn("COOKIE data too large");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
lookup->cookie = hexcookie;
|
lookup->cookie = hexcookie;
|
||||||
} else
|
} else
|
||||||
lookup->cookie = NULL;
|
lookup->cookie = NULL;
|
||||||
@@ -916,8 +926,10 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
goto need_value;
|
goto need_value;
|
||||||
result = parse_uint(&num, value, 0x3f, "DSCP");
|
result = parse_uint(&num, value, 0x3f, "DSCP");
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse DSCP value");
|
warn("Couldn't parse DSCP value");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
lookup->dscp = num;
|
lookup->dscp = num;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -946,9 +958,11 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
value,
|
value,
|
||||||
255,
|
255,
|
||||||
"edns");
|
"edns");
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse "
|
warn("Couldn't parse "
|
||||||
"edns");
|
"edns");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
lookup->edns = num;
|
lookup->edns = num;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
@@ -965,9 +979,11 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
value,
|
value,
|
||||||
0xffff,
|
0xffff,
|
||||||
"ednsflags");
|
"ednsflags");
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse "
|
warn("Couldn't parse "
|
||||||
"ednsflags");
|
"ednsflags");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
lookup->ednsflags = num;
|
lookup->ednsflags = num;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
@@ -980,10 +996,12 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
lookup->ednsoptscnt = 0;
|
lookup->ednsoptscnt = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (value == NULL)
|
if (value == NULL) {
|
||||||
fatal("ednsopt no "
|
warn("ednsopt no "
|
||||||
"code point "
|
"code point "
|
||||||
"specified");
|
"specified");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
code = next_token(&value, ":");
|
code = next_token(&value, ":");
|
||||||
save_opt(lookup, code, value);
|
save_opt(lookup, code, value);
|
||||||
break;
|
break;
|
||||||
@@ -1098,8 +1116,10 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
if (!state)
|
if (!state)
|
||||||
goto invalid_option;
|
goto invalid_option;
|
||||||
result = parse_uint(&num, value, MAXNDOTS, "ndots");
|
result = parse_uint(&num, value, MAXNDOTS, "ndots");
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse ndots");
|
warn("Couldn't parse ndots");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
ndots = num;
|
ndots = num;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
@@ -1161,8 +1181,10 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result = parse_uint(&num, value, 15, "opcode");
|
result = parse_uint(&num, value, 15, "opcode");
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse opcode");
|
warn("Couldn't parse opcode");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
lookup->opcode = (dns_opcode_t)num;
|
lookup->opcode = (dns_opcode_t)num;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1176,8 +1198,10 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
goto need_value;
|
goto need_value;
|
||||||
result = parse_uint(&num, value, 512, "padding");
|
result = parse_uint(&num, value, 512, "padding");
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse padding");
|
warn("Couldn't parse padding");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
lookup->padding = (isc_uint16_t)num;
|
lookup->padding = (isc_uint16_t)num;
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
@@ -1216,8 +1240,10 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
goto invalid_option;
|
goto invalid_option;
|
||||||
result = parse_uint(&lookup->retries, value,
|
result = parse_uint(&lookup->retries, value,
|
||||||
MAXTRIES - 1, "retries");
|
MAXTRIES - 1, "retries");
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse retries");
|
warn("Couldn't parse retries");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
lookup->retries++;
|
lookup->retries++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1300,8 +1326,10 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
*/
|
*/
|
||||||
if (splitwidth)
|
if (splitwidth)
|
||||||
splitwidth += 3;
|
splitwidth += 3;
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse split");
|
warn("Couldn't parse split");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 't': /* stats */
|
case 't': /* stats */
|
||||||
FULLCHECK("stats");
|
FULLCHECK("stats");
|
||||||
@@ -1325,8 +1353,10 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
lookup->ecs_addr = NULL;
|
lookup->ecs_addr = NULL;
|
||||||
}
|
}
|
||||||
result = parse_netprefix(&lookup->ecs_addr, value);
|
result = parse_netprefix(&lookup->ecs_addr, value);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse client");
|
warn("Couldn't parse client");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto invalid_option;
|
goto invalid_option;
|
||||||
@@ -1349,8 +1379,10 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
goto invalid_option;
|
goto invalid_option;
|
||||||
result = parse_uint(&timeout, value, MAXTIMEOUT,
|
result = parse_uint(&timeout, value, MAXTIMEOUT,
|
||||||
"timeout");
|
"timeout");
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse timeout");
|
warn("Couldn't parse timeout");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
if (timeout == 0)
|
if (timeout == 0)
|
||||||
timeout = 1;
|
timeout = 1;
|
||||||
break;
|
break;
|
||||||
@@ -1386,8 +1418,10 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
goto invalid_option;
|
goto invalid_option;
|
||||||
result = parse_uint(&lookup->retries, value,
|
result = parse_uint(&lookup->retries, value,
|
||||||
MAXTRIES, "tries");
|
MAXTRIES, "tries");
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
fatal("Couldn't parse tries");
|
warn("Couldn't parse tries");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
if (lookup->retries == 0)
|
if (lookup->retries == 0)
|
||||||
lookup->retries = 1;
|
lookup->retries = 1;
|
||||||
break;
|
break;
|
||||||
@@ -1444,11 +1478,19 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
default:
|
default:
|
||||||
invalid_option:
|
invalid_option:
|
||||||
need_value:
|
need_value:
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
exit_or_usage:
|
||||||
|
#endif
|
||||||
fprintf(stderr, "Invalid option: +%s\n",
|
fprintf(stderr, "Invalid option: +%s\n",
|
||||||
option);
|
option);
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if ! TARGET_OS_IPHONE
|
||||||
|
exit_or_usage:
|
||||||
|
digexit();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
|
@@ -375,6 +375,46 @@ get_reverse(char *reverse, size_t len, char *value, isc_boolean_t ip6_int,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void (*dighost_pre_exit_hook)(void) = NULL;
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
void
|
||||||
|
warn(const char *format, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
fflush(stdout);
|
||||||
|
fprintf(stderr, ";; Warning: ");
|
||||||
|
va_start(args, format);
|
||||||
|
vfprintf(stderr, format, args);
|
||||||
|
va_end(args);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void
|
||||||
|
warn(const char *format, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
fflush(stdout);
|
||||||
|
fprintf(stderr, "%s: ", progname);
|
||||||
|
va_start(args, format);
|
||||||
|
vfprintf(stderr, format, args);
|
||||||
|
va_end(args);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
digexit(void) {
|
||||||
|
if (exitcode < 10)
|
||||||
|
exitcode = 10;
|
||||||
|
if (fatalexit != 0)
|
||||||
|
exitcode = fatalexit;
|
||||||
|
if (dighost_pre_exit_hook != NULL) {
|
||||||
|
dighost_pre_exit_hook();
|
||||||
|
}
|
||||||
|
exit(exitcode);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fatal(const char *format, ...) {
|
fatal(const char *format, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -385,11 +425,7 @@ fatal(const char *format, ...) {
|
|||||||
vfprintf(stderr, format, args);
|
vfprintf(stderr, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
if (exitcode < 10)
|
digexit();
|
||||||
exitcode = 10;
|
|
||||||
if (fatalexit != 0)
|
|
||||||
exitcode = fatalexit;
|
|
||||||
exit(exitcode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2161,9 +2197,13 @@ setup_lookup(dig_lookup_t *lookup) {
|
|||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
dns_message_puttempname(lookup->sendmsg,
|
dns_message_puttempname(lookup->sendmsg,
|
||||||
&lookup->name);
|
&lookup->name);
|
||||||
fatal("'%s' is not a legal name "
|
warn("'%s' is not a legal name "
|
||||||
"(%s)", lookup->textname,
|
"(%s)", lookup->textname,
|
||||||
isc_result_totext(result));
|
isc_result_totext(result));
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
check_next_lookup(current_lookup);
|
||||||
|
return (ISC_FALSE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dns_name_format(lookup->name, store, sizeof(store));
|
dns_name_format(lookup->name, store, sizeof(store));
|
||||||
|
@@ -26,6 +26,10 @@
|
|||||||
#include <isc/sockaddr.h>
|
#include <isc/sockaddr.h>
|
||||||
#include <isc/socket.h>
|
#include <isc/socket.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <TargetConditionals.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MXSERV 20
|
#define MXSERV 20
|
||||||
#define MXNAME (DNS_NAME_MAXTEXT+1)
|
#define MXNAME (DNS_NAME_MAXTEXT+1)
|
||||||
#define MXRD 32
|
#define MXRD 32
|
||||||
@@ -282,6 +286,13 @@ ISC_PLATFORM_NORETURN_PRE void
|
|||||||
fatal(const char *format, ...)
|
fatal(const char *format, ...)
|
||||||
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
||||||
|
|
||||||
|
void
|
||||||
|
warn(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
||||||
|
|
||||||
|
ISC_PLATFORM_NORETURN_PRE void
|
||||||
|
digexit(void)
|
||||||
|
ISC_PLATFORM_NORETURN_POST;
|
||||||
|
|
||||||
void
|
void
|
||||||
debug(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
debug(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
||||||
|
|
||||||
@@ -384,6 +395,9 @@ extern void
|
|||||||
extern void
|
extern void
|
||||||
(*dighost_shutdown)(void);
|
(*dighost_shutdown)(void);
|
||||||
|
|
||||||
|
extern void
|
||||||
|
(*dighost_pre_exit_hook)(void);
|
||||||
|
|
||||||
void save_opt(dig_lookup_t *lookup, char *code, char *value);
|
void save_opt(dig_lookup_t *lookup, char *code, char *value);
|
||||||
|
|
||||||
void setup_file_key(void);
|
void setup_file_key(void);
|
||||||
|
Reference in New Issue
Block a user