From 475bb0e332bb74471b74f0752c168a7d47687853 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 6 Jun 2018 13:26:59 +1000 Subject: [PATCH 1/2] move -T parsing to its own function (cherry picked from commit b491ceeb504dbc2d7285033ebf92736d7ba29095) --- bin/named/main.c | 174 +++++++++++++++++++++++------------------------ 1 file changed, 85 insertions(+), 89 deletions(-) diff --git a/bin/named/main.c b/bin/named/main.c index ab15e935a5..57bddc2d4e 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -466,6 +466,90 @@ parse_fuzz_arg(void) { } } +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")) { + clienttest = ISC_TRUE; + } else if (!strncmp(option, "delay=", 6)) { + delay = atoi(option + 6); + } else if (!strcmp(option, "dropedns")) { + dropedns = ISC_TRUE; + } else if (!strncmp(option, "dscp=", 5)) { + isc_dscp_check_value = atoi(option + 5); + } else if (!strcmp(option, "fixedlocal")) { + fixedlocal = ISC_TRUE; + } else if (!strcmp(option, "keepstderr")) { + named_g_keepstderr = ISC_TRUE; + } else if (!strcmp(option, "noaa")) { + noaa = ISC_TRUE; + } else if (!strcmp(option, "noedns")) { + noedns = ISC_TRUE; + } else if (!strcmp(option, "nonearest")) { + nonearest = ISC_TRUE; + } else if (!strcmp(option, "nosoa")) { + nosoa = ISC_TRUE; + } else if (!strcmp(option, "nosyslog")) { + named_g_nosyslog = ISC_TRUE; + } else if (!strcmp(option, "notcp")) { + 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) { + named_main_earlyfatal("bad mkeytimer"); + } + + dns_zone_mkey_hour = atoi(p); + if (dns_zone_mkey_hour == 0) { + named_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) + named_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) { + named_main_earlyfatal("bad mkeytimer"); + } + } else if (!strncmp(option, "tat=", 4)) { + named_g_tat_interval = atoi(option + 4); + } else { + fprintf(stderr, "unknown -T flag '%s\n", option); + } +} + static void parse_command_line(int argc, char *argv[]) { int ch; @@ -565,95 +649,7 @@ parse_command_line(int argc, char *argv[]) { named_g_chrootdir = isc_commandline_argument; break; case 'T': /* NOT DOCUMENTED */ - /* - * 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(isc_commandline_argument, "clienttest")) - clienttest = ISC_TRUE; - else if (!strcmp(isc_commandline_argument, "nosoa")) - nosoa = ISC_TRUE; - else if (!strcmp(isc_commandline_argument, "noaa")) - 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")) - dropedns = ISC_TRUE; - else if (!strcmp(isc_commandline_argument, "noedns")) - noedns = ISC_TRUE; - else if (!strncmp(isc_commandline_argument, - "maxudp=", 7)) - maxudp = atoi(isc_commandline_argument + 7); - else if (!strncmp(isc_commandline_argument, - "delay=", 6)) - delay = atoi(isc_commandline_argument + 6); - else if (!strcmp(isc_commandline_argument, "nosyslog")) - named_g_nosyslog = ISC_TRUE; - else if (!strcmp(isc_commandline_argument, "nonearest")) - nonearest = ISC_TRUE; - else if (!strncmp(isc_commandline_argument, "dscp=", 5)) - isc_dscp_check_value = - atoi(isc_commandline_argument + 5); - else if (!strncmp(isc_commandline_argument, - "mkeytimers=", 11)) - { - p = strtok(isc_commandline_argument + 11, "/"); - if (p == NULL) - named_main_earlyfatal("bad mkeytimer"); - dns_zone_mkey_hour = atoi(p); - if (dns_zone_mkey_hour == 0) - named_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) - named_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) - named_main_earlyfatal("bad mkeytimer"); - } else if (!strcmp(isc_commandline_argument, "notcp")) - notcp = ISC_TRUE; - else if (!strncmp(isc_commandline_argument, "tat=", 4)) - { - named_g_tat_interval = - atoi(isc_commandline_argument + 4); - } else if (!strcmp(isc_commandline_argument, - "keepstderr")) - { - named_g_keepstderr = ISC_TRUE; - } else if (!strcmp(isc_commandline_argument, - "fixedlocal")) - { - fixedlocal = ISC_TRUE; - } else { - fprintf(stderr, "unknown -T flag '%s\n", - isc_commandline_argument); - } + parse_T_opt(isc_commandline_argument); break; case 'U': named_g_udpdisp = parse_int(isc_commandline_argument, From 937e700bd5b19335dee422782905ac5c33395d65 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 6 Jun 2018 13:30:28 +1000 Subject: [PATCH 2/2] add CHANGES (cherry picked from commit ef7401e4a7c9f304a6ad33a6d0111665f24212d9) --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index dc175bc03e..5bdff892b2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4962. [cleanup] Move 'named -T' processing to its own function. + [GL #316] + 4958. [bug] Remove redundant space from NSEC3 record. [GL #281] 4955. [cleanup] Silence cppcheck warnings in lib/dns/master.c.