From: Harlan Stenn Date: Sat, 20 Jan 2018 07:19:41 +0000 (-0800) Subject: Improve saveconfig output X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bd1d61425cff2ba671a37fcaacec38fb1fa8c40;p=thirdparty%2Fntp.git Improve saveconfig output bk: 5a62ed8dIkl2Xx6fkF4XJiGthKuVCA --- diff --git a/ChangeLog b/ChangeLog index 66770aabd..4f55f0d3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -80,6 +80,7 @@ * Distribute testconf.yml. HStenn. * Add DPRINTF(2,...) lines to receive() for packet drops. HStenn. * Rename the configuration flag fifo variables. HStenn. +* Improve saveconfig output. HStenn. --- (4.2.8p10) 2017/03/21 Released by Harlan Stenn diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index af24de699..7e56a36b9 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -555,7 +555,10 @@ dump_config_tree( ptree->source.value.s); } - /* For options I didn't find documentation I'll just output its name and the cor. value */ + /* + * For options without documentation we just output the name + * and its data value + */ atrv = HEAD_PFIFO(ptree->vars); for ( ; atrv != NULL; atrv = atrv->link) { switch (atrv->type) { @@ -923,9 +926,11 @@ dump_config_tree( for (rest_node = HEAD_PFIFO(ptree->restrict_opts); rest_node != NULL; rest_node = rest_node->link) { + int is_default = 0; if (NULL == rest_node->addr) { s = "default"; + /* Don't need to set is_default=1 here */ flag_tok_fifo = HEAD_PFIFO(rest_node->flag_tok_fifo); for ( ; flag_tok_fifo != NULL; flag_tok_fifo = flag_tok_fifo->link) { if (T_Source == flag_tok_fifo->i) { @@ -934,10 +939,29 @@ dump_config_tree( } } } else { - s = rest_node->addr->address; + char *ap = rest_node->addr->address; + char *mp; + + if (rest_node->mask) + mp = rest_node->mask->address; + + if ( rest_node->addr->type == AF_INET + && !strcmp(ap, "0.0.0.0") + && !strcmp(mp, "0.0.0.0")) { + is_default = 1; + s = "-4 default"; + } else if ( rest_node->mask + && rest_node->mask->type == AF_INET6 + && !strcmp(ap, "::") + && !strcmp(mp, "::")) { + is_default = 1; + s = "-6 default"; + } else { + s = ap; + } } fprintf(df, "restrict %s", s); - if (rest_node->mask != NULL) + if (rest_node->mask != NULL && !is_default) fprintf(df, " mask %s", rest_node->mask->address); fprintf(df, " ippeerlimit %d", rest_node->ippeerlimit); @@ -2817,6 +2841,9 @@ config_rlimit( case T_Memlock: /* What if we HAVE_OPT(SAVECONFIGQUIT) ? */ + if (HAVE_OPT( SAVECONFIGQUIT )) { + break; + } if (rlimit_av->value.i == -1) { # if defined(HAVE_MLOCKALL) if (cur_memlock != 0) { @@ -5149,6 +5176,9 @@ ntp_rlimit( switch (rl_what) { # ifdef RLIMIT_MEMLOCK case RLIMIT_MEMLOCK: + if (HAVE_OPT( SAVECONFIGQUIT )) { + break; + } /* * The default RLIMIT_MEMLOCK is very low on Linux systems. * Unless we increase this limit malloc calls are likely to