[Git][NTPsec/ntpsec][master] 3 commits: Boolification.
Eric S. Raymond
gitlab at mg.gitlab.com
Wed Dec 9 20:43:43 UTC 2015
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
302c2377 by Eric S. Raymond at 2015-12-09T15:43:07Z
Boolification.
- - - - -
168d8ad6 by Eric S. Raymond at 2015-12-09T15:43:07Z
Localize some globals that don't need to be exposed.
- - - - -
1561ae3f by Eric S. Raymond at 2015-12-09T15:43:07Z
Save configuration as part of the capture log.
- - - - -
3 changed files:
- include/ntpd.h
- ntpd/ntp_config.c
- ntpd/ntp_intercept.c
Changes:
=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -57,7 +57,7 @@ extern void win_time_stepped(void);
extern char *keysdir; /* crypto keys and leaptable directory */
extern char * saveconfigdir; /* ntpq saveconfig output directory */
-extern void getconfig (const char *);
+extern const char *getconfig (const char *);
extern void ctl_clr_stats (void);
extern bool ctlclrtrap (sockaddr_u *, struct interface *, int);
extern u_short ctlpeerstatus (struct peer *);
=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -146,7 +146,6 @@ char * saveconfigdir;
bool config_priority_override = false;
int config_priority;
-const char *config_file;
static char default_ntp_signd_socket[] =
#ifdef MSSNTP_PATH
MSSNTP_PATH;
@@ -156,14 +155,8 @@ static char default_ntp_signd_socket[] =
char *ntp_signd_socket = default_ntp_signd_socket;
#ifdef HAVE_NETINFO_NI_H
struct netinfo_config_state *config_netinfo = NULL;
-int check_netinfo = true;
+bool check_netinfo = true;
#endif /* HAVE_NETINFO_NI_H */
-#ifdef SYS_WINNT
-char *alt_config_file;
-LPTSTR temp;
-char config_file_storage[MAX_PATH];
-char alt_config_file_storage[MAX_PATH];
-#endif /* SYS_WINNT */
#ifdef HAVE_NETINFO_NI_H
/*
@@ -4348,17 +4341,20 @@ config_remotely(
/*
* getconfig() - process startup configuration file e.g /etc/ntp.conf
*/
-void
+const char *
getconfig(const char *explicit_config)
{
char line[256];
+ const char *config_file;
-#ifdef FREE_CFG_T
- atexit(free_all_config_trees);
-#endif
#ifndef SYS_WINNT
config_file = CONFIG_FILE;
#else
+ char *alt_config_file;
+ LPTSTR temp;
+ char config_file_storage[MAX_PATH];
+ char alt_config_file_storage[MAX_PATH];
+
temp = CONFIG_FILE;
if (!ExpandEnvironmentStringsA(temp, config_file_storage,
sizeof(config_file_storage))) {
@@ -4376,6 +4372,13 @@ getconfig(const char *explicit_config)
alt_config_file = alt_config_file_storage;
#endif /* SYS_WINNT */
+ if (explicit_config) {
+#ifdef HAVE_NETINFO_NI_H
+ check_netinfo = false;
+#endif
+ config_file = explicit_config;
+ }
+
/*
* install a non default variable with this daemon version
*/
@@ -4389,13 +4392,6 @@ getconfig(const char *explicit_config)
*/
set_tod_using = &ntpd_set_tod_using;
- if (explicit_config) {
-#ifdef HAVE_NETINFO_NI_H
- check_netinfo = false;
-#endif
- config_file = explicit_config;
- }
-
init_syntax_tree(&cfgt);
if (
!lex_init_stack(config_file, "r")
@@ -4409,7 +4405,7 @@ getconfig(const char *explicit_config)
if (!saveconfigquit)
io_open_sockets();
- return;
+ return NULL;
#else
/* Under WinNT try alternate_config_file name, first NTP.CONF, then NTP.INI */
@@ -4422,13 +4418,16 @@ getconfig(const char *explicit_config)
if (!saveconfigquit)
io_open_sockets();
- return;
+ return NULL;
}
cfgt.source.value.s = estrdup(alt_config_file);
#endif /* SYS_WINNT */
} else
cfgt.source.value.s = estrdup(config_file);
+#ifdef FREE_CFG_T
+ atexit(free_all_config_trees);
+#endif
/*** BULK OF THE PARSER ***/
#ifdef DEBUG
@@ -4448,6 +4447,8 @@ getconfig(const char *explicit_config)
if (config_netinfo)
free_netinfo_config(config_netinfo);
#endif /* HAVE_NETINFO_NI_H */
+
+ return config_file;
}
=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -176,9 +176,10 @@ static bool pump(const char *fn, const char *lead, const char *trail, FILE *ofp)
void intercept_getconfig(const char *configfile)
{
if (mode != replay)
- getconfig(configfile);
+ /* this can be null if the default config doesn't exist */
+ configfile = getconfig(configfile);
- if (mode == capture)
+ if (configfile != NULL && mode != none)
pump(configfile, "startconfig\n", "endconfig\n", stdout);
if (mode == replay) {
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/499c37918dabe8c276ee332f3d1556b0332b39fc...1561ae3f64df155805cd6b1d5a9c6d474dafdb41
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151209/b7fcf4a0/attachment.html>
More information about the vc
mailing list