From: Harlan Stenn Date: Tue, 30 Dec 2014 00:28:06 +0000 (+0000) Subject: [Bug 2715] mdnstries option for ntp.conf from NetBSD X-Git-Tag: NTP_4_2_8P1_BETA3~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f9acd64871b476fe397d7d1ff6dd5d983b0af47;p=thirdparty%2Fntp.git [Bug 2715] mdnstries option for ntp.conf from NetBSD bk: 54a1f196WqAsMXwFMln3RWCI3B5RQg --- diff --git a/ChangeLog b/ChangeLog index 918890d7b..94fa2af0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * [Bug 2706] libparse/info_trimble.c build dependencies are broken. * [Bug 2713] variable type/cast, parameter name, general cleanup from NetBSD. * [Bug 2714] libevent may need to be built independently of any build of sntp. +* [Bug 2715] mdnstries option for ntp.conf from NetBSD. --- (4.2.8p1-beta2) 2014/12/27 Released by Harlan Stenn diff --git a/ntpd/keyword-gen.c b/ntpd/keyword-gen.c index d4f77588d..bb593aba2 100644 --- a/ntpd/keyword-gen.c +++ b/ntpd/keyword-gen.c @@ -97,6 +97,7 @@ struct key_tok ntp_keywords[] = { { "iburst", T_Iburst, FOLLBY_TOKEN }, { "key", T_Key, FOLLBY_TOKEN }, { "maxpoll", T_Maxpoll, FOLLBY_TOKEN }, +{ "mdnstries", T_Mdnstries, FOLLBY_TOKEN }, { "minpoll", T_Minpoll, FOLLBY_TOKEN }, { "mode", T_Mode, FOLLBY_TOKEN }, { "noselect", T_Noselect, FOLLBY_TOKEN }, @@ -357,7 +358,7 @@ generate_fsm(void) fprintf(stderr, "keyword-gen sst[%u] too small " "for keyword '%s' id %d\n", - COUNTOF(sst), + (int)COUNTOF(sst), ntp_keywords[i].key, token); exit(4); diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 0f48983f8..3bb9a1535 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -128,6 +128,8 @@ typedef struct peer_resolved_ctx_tag { #define ISEOL(c) ((c) == '#' || (c) == '\n' || (c) == '\0') #define ISSPACE(c) ((c) == ' ' || (c) == '\t') +#define _UC(str) ((char *)(intptr_t)(str)) + /* * Definitions of things either imported from or exported to outside */ @@ -316,6 +318,7 @@ static void config_ntpd(config_tree *); static void config_other_modes(config_tree *); static void config_auth(config_tree *); static void config_access(config_tree *); +static void config_mdnstries(config_tree *); static void config_phone(config_tree *); static void config_setvar(config_tree *); static void config_ttl(config_tree *); @@ -355,6 +358,7 @@ static u_int32 get_logmask(const char *); #ifndef SIM static int getnetnum(const char *num, sockaddr_u *addr, int complain, enum gnn_type a_type); + #endif @@ -392,6 +396,7 @@ init_syntax_tree( ) { ZERO(*ptree); + ptree->mdnstries = 5; } @@ -502,7 +507,7 @@ dump_config_tree( int_node *counter_set; string_node *str_node; - const char *s; + const char *s = NULL; char *s1; char *s2; char timestamp[80]; @@ -1105,7 +1110,7 @@ create_attr_rangeval( attr_val * create_attr_sval( int attr, - char *s + const char *s ) { attr_val *my_val; @@ -1114,7 +1119,7 @@ create_attr_sval( my_val->attr = attr; if (NULL == s) /* free() hates NULL */ s = estrdup(""); - my_val->value.s = s; + my_val->value.s = _UC(s); my_val->type = T_String; return my_val; @@ -1329,7 +1334,7 @@ create_unpeer_node( * We treat all valid 16-bit numbers as association IDs. */ pch = addr->address; - while (*pch && isdigit(*pch)) + while (*pch && isdigit((unsigned char)*pch)) pch++; if (!*pch @@ -2457,12 +2462,12 @@ config_access( /* It would be swell if we could identify the line number */ if ((RES_KOD & flags) && !(RES_LIMITED & flags)) { - char *kod_where = (my_node->addr) + const char *kod_where = (my_node->addr) ? my_node->addr->address : (mflags & RESM_SOURCE) ? "source" : "default"; - char *kod_warn = "KOD does nothing without LIMITED."; + const char *kod_warn = "KOD does nothing without LIMITED."; fprintf(stderr, "restrict %s: %s\n", kod_where, kod_warn); msyslog(LOG_WARNING, "restrict %s: %s", kod_where, kod_warn); @@ -3033,7 +3038,7 @@ config_phone( config_tree *ptree ) { - int i; + size_t i; string_node * sn; i = 0; @@ -3045,13 +3050,23 @@ config_phone( sys_phone[i] = NULL; } else { msyslog(LOG_INFO, - "phone: Number of phone entries exceeds %lu. Ignoring phone %s...", - (u_long)(COUNTOF(sys_phone) - 1), sn->s); + "phone: Number of phone entries exceeds %zu. Ignoring phone %s...", + (COUNTOF(sys_phone) - 1), sn->s); } } } #endif /* !SIM */ +static void +config_mdnstries( + config_tree *ptree + ) +{ +#ifdef HAVE_DNSREGISTRATION + extern int mdnstries; + mdnstries = ptree->mdnstries; +#endif /* HAVE_DNSREGISTRATION */ +} #ifdef FREE_CFG_T static void @@ -3110,7 +3125,7 @@ config_ttl( config_tree *ptree ) { - int i = 0; + size_t i = 0; int_node *curr_ttl; curr_ttl = HEAD_PFIFO(ptree->ttl); @@ -3119,8 +3134,8 @@ config_ttl( sys_ttl[i++] = (u_char)curr_ttl->i; else msyslog(LOG_INFO, - "ttl: Number of TTL entries exceeds %lu. Ignoring TTL %d...", - (u_long)COUNTOF(sys_ttl), curr_ttl->i); + "ttl: Number of TTL entries exceeds %zu. Ignoring TTL %d...", + COUNTOF(sys_ttl), curr_ttl->i); } sys_ttlmax = i - 1; } @@ -4286,6 +4301,7 @@ config_ntpd( config_system_opts(ptree); config_logconfig(ptree); config_phone(ptree); + config_mdnstries(ptree); config_setvar(ptree); config_ttl(ptree); config_trap(ptree); @@ -4886,7 +4902,7 @@ ntp_rlimit( int rl_what, rlim_t rl_value, int rl_scale, - char * rl_sstr + const char * rl_sstr ) { struct rlimit rl; diff --git a/ntpd/ntp_parser.y b/ntpd/ntp_parser.y index e75bffe4f..c55e0697d 100644 --- a/ntpd/ntp_parser.y +++ b/ntpd/ntp_parser.y @@ -159,6 +159,7 @@ %token T_Maxdist %token T_Maxmem %token T_Maxpoll +%token T_Mdnstries %token T_Mem %token T_Memlock %token T_Minclock @@ -526,6 +527,8 @@ other_mode_command { CONCAT_G_FIFOS(cfgt.manycastserver, $2); } | T_Multicastclient address_list { CONCAT_G_FIFOS(cfgt.multicastclient, $2); } + | T_Mdnstries T_Integer + { cfgt.mdnstries = $2; } ;