From: Mark Andrews Date: Wed, 6 Jun 2018 03:26:59 +0000 (+1000) Subject: move -T parsing to its own function X-Git-Tag: v9.9.13rc1~10^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af6deb25abfcde7446c9a494f370687f79a12ebe;p=thirdparty%2Fbind9.git move -T parsing to its own function (cherry picked from commit b491ceeb504dbc2d7285033ebf92736d7ba29095) --- diff --git a/bin/named/main.c b/bin/named/main.c index fa1753e32dd..e0cc0785791 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -424,6 +424,84 @@ set_flags(const char *arg, struct flag_def *defs, unsigned int *ret) { *ret = 0; } +static void +parse_T_opt(char *option) { + const char *p; + char *last = NULL; + /* + * force the server to behave (or misbehave) in + * specified ways for testing purposes. + * + * clienttest: make clients single shot with their + * own memory context. + * delay=xxxx: delay client responses by xxxx ms to + * simulate remote servers. + * dscp=x: check that dscp values are as + * expected and assert otherwise. + */ + if (!strcmp(option, "clienttest")) { + ns_g_clienttest = ISC_TRUE; + } else if (!strcmp(option, "dropedns")) { + ns_g_dropedns = ISC_TRUE; + } else if (!strcmp(option, "fixedlocal")) { + ns_g_fixedlocal = ISC_TRUE; + } else if (!strcmp(option, "keepstderr")) { + ns_g_keepstderr = ISC_TRUE; + } else if (!strcmp(option, "noaa")) { + ns_g_noaa = ISC_TRUE; + } else if (!strcmp(option, "noedns")) { + ns_g_noedns = ISC_TRUE; + } else if (!strcmp(option, "nonearest")) { + ns_g_nonearest = ISC_TRUE; + } else if (!strcmp(option, "nosoa")) { + ns_g_nosoa = ISC_TRUE; + } else if (!strcmp(option, "nosyslog")) { + ns_g_nosyslog = ISC_TRUE; + } else if (!strcmp(option, "notcp")) { + ns_g_notcp = ISC_TRUE; + } else if (!strcmp(option, "maxudp512")) { + maxudp = 512; + } else if (!strcmp(option, "maxudp1460")) { + maxudp = 1460; + } else if (!strncmp(option, "maxudp=", 7)) { + maxudp = atoi(option + 7); + } else if (!strncmp(option, "mkeytimers=", 11)) { + p = strtok_r(option + 11, "/", &last); + if (p == NULL) { + ns_main_earlyfatal("bad mkeytimer"); + } + + dns_zone_mkey_hour = atoi(p); + if (dns_zone_mkey_hour == 0) { + ns_main_earlyfatal("bad mkeytimer"); + } + + p = strtok_r(NULL, "/", &last); + if (p == NULL) { + dns_zone_mkey_day = (24 * dns_zone_mkey_hour); + dns_zone_mkey_month = (30 * dns_zone_mkey_day); + return; + } + + dns_zone_mkey_day = atoi(p); + if (dns_zone_mkey_day < dns_zone_mkey_hour) + ns_main_earlyfatal("bad mkeytimer"); + + p = strtok_r(NULL, "/", &last); + if (p == NULL) { + dns_zone_mkey_month = (30 * dns_zone_mkey_day); + return; + } + + dns_zone_mkey_month = atoi(p); + if (dns_zone_mkey_month < dns_zone_mkey_day) { + ns_main_earlyfatal("bad mkeytimer"); + } + } else { + fprintf(stderr, "unknown -T flag '%s\n", option); + } +} + static void parse_command_line(int argc, char *argv[]) { int ch; @@ -532,76 +610,7 @@ parse_command_line(int argc, char *argv[]) { ns_g_chrootdir = isc_commandline_argument; break; case 'T': /* NOT DOCUMENTED */ - /* - * clienttest: make clients single shot with their - * own memory context. - */ - if (!strcmp(isc_commandline_argument, "clienttest")) - ns_g_clienttest = ISC_TRUE; - else if (!strcmp(isc_commandline_argument, "nosoa")) - ns_g_nosoa = ISC_TRUE; - else if (!strcmp(isc_commandline_argument, "noaa")) - ns_g_noaa = ISC_TRUE; - else if (!strcmp(isc_commandline_argument, "maxudp512")) - maxudp = 512; - else if (!strcmp(isc_commandline_argument, "maxudp1460")) - maxudp = 1460; - else if (!strcmp(isc_commandline_argument, "dropedns")) - ns_g_dropedns = ISC_TRUE; - else if (!strcmp(isc_commandline_argument, "noedns")) - ns_g_noedns = ISC_TRUE; - else if (!strncmp(isc_commandline_argument, - "maxudp=", 7)) - maxudp = atoi(isc_commandline_argument + 7); - else if (!strcmp(isc_commandline_argument, "nosyslog")) - ns_g_nosyslog = ISC_TRUE; - else if (!strcmp(isc_commandline_argument, "nonearest")) - ns_g_nonearest = ISC_TRUE; - else if (!strncmp(isc_commandline_argument, - "mkeytimers=", 11)) - { - p = strtok(isc_commandline_argument + 11, "/"); - if (p == NULL) - ns_main_earlyfatal("bad mkeytimer"); - dns_zone_mkey_hour = atoi(p); - if (dns_zone_mkey_hour == 0) - ns_main_earlyfatal("bad mkeytimer"); - - p = strtok(NULL, "/"); - if (p == NULL) { - dns_zone_mkey_day = - (24 * dns_zone_mkey_hour); - dns_zone_mkey_month = - (30 * dns_zone_mkey_day); - break; - } - dns_zone_mkey_day = atoi(p); - if (dns_zone_mkey_day < dns_zone_mkey_hour) - ns_main_earlyfatal("bad mkeytimer"); - - p = strtok(NULL, "/"); - if (p == NULL) { - dns_zone_mkey_month = - (30 * dns_zone_mkey_day); - break; - } - dns_zone_mkey_month = atoi(p); - if (dns_zone_mkey_month < dns_zone_mkey_day) - ns_main_earlyfatal("bad mkeytimer"); - } else if (!strcmp(isc_commandline_argument, "notcp")) { - ns_g_notcp = ISC_TRUE; - } else if (!strcmp(isc_commandline_argument, - "keepstderr")) - { - ns_g_keepstderr = ISC_TRUE; - } else if (!strcmp(isc_commandline_argument, - "fixedlocal")) - { - ns_g_fixedlocal = ISC_TRUE; - } else { - fprintf(stderr, "unknown -T flag '%s\n", - isc_commandline_argument); - } + parse_T_opt(isc_commandline_argument); break; case 'U': ns_g_udpdisp = parse_int(isc_commandline_argument,