[Git][NTPsec/ntpsec][master] 3 commits: Don't open listening sockets in replay mode. Also, some verbosity reduction.

Eric S. Raymond gitlab at mg.gitlab.com
Thu Dec 10 06:26:38 UTC 2015


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
ccbed939 by Eric S. Raymond at 2015-12-09T21:38:56Z
Don't open listening sockets in replay mode.  Also, some verbosity reduction.

- - - - -
550a3f20 by Eric S. Raymond at 2015-12-10T01:04:03Z
Revert "Cut verbosity by changing where capture mode is set."

Turns out to have been the wrong fix.

- - - - -
b91fe307 by Eric S. Raymond at 2015-12-10T01:25:34Z
Set up verbosity and fork suppression correctly for capture and replay.

- - - - -


5 changed files:

- ntpd/ntp_config.c
- ntpd/ntp_intercept.c
- ntpd/ntp_io.c
- ntpd/ntp_loopfilter.c
- ntpd/ntpd.c


Changes:

=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -2430,7 +2430,7 @@ config_access(
 					    ? "source"
 					    : "default";
 			const char *kod_warn = "KOD does nothing without LIMITED.";
-			/* FIXME: should probly just drop this */
+
 			if (intercept_get_mode() == none)
 			    fprintf(stderr, "restrict %s: %s\n", kod_where, kod_warn);
 			msyslog(LOG_WARNING, "restrict %s: %s", kod_where, kod_warn);
@@ -4278,7 +4278,7 @@ config_ntpd(
 	config_trap(ptree);
 	config_vars(ptree);
 
-	if (!saveconfigquit)
+	if (!saveconfigquit && intercept_get_mode() != replay)
 		io_open_sockets();
 
 	config_other_modes(ptree);
@@ -4403,7 +4403,7 @@ getconfig(const char *explicit_config)
 		) {
 		msyslog(LOG_INFO, "getconfig: Couldn't open <%s>: %m", config_file);
 #ifndef SYS_WINNT
-		if (!saveconfigquit)
+		if (!saveconfigquit && intercept_get_mode() != replay)
 			io_open_sockets();
 
 		return NULL;
@@ -4416,7 +4416,7 @@ getconfig(const char *explicit_config)
 			 * a configuration file.
 			 */
 			msyslog(LOG_INFO, "getconfig: Couldn't open <%s>: %m", alt_config_file);
-			if (!saveconfigquit)
+			if (!saveconfigquit && intercept_get_mode() != replay)
 				io_open_sockets();
 
 			return NULL;


=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -125,15 +125,20 @@ void intercept_set_mode(intercept_mode newmode)
     if (mode != none) {
 	syslogit = false;
 	hashprefix = true;
-	termlogit = (debug > 0);
     }
 }
 
 void intercept_argparse(int *argc, char ***argv)
 {
+    int i;
+    for (i = 1; i < *argc; i++)
+	if (strcmp((*argv)[i], "-y") == 0)
+	    intercept_set_mode(capture);
+	else if  (strcmp((*argv)[i], "-Y") == 0)
+	    intercept_set_mode(replay);
+
     if (mode == capture)
     {
-	int i;
 	printf("event startup");
 	for (i = 1; i < *argc; i++)
 	    if (strcmp((*argv)[i], "-y") != 0 && strcmp((*argv)[i], "-Y") != 0)


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -1094,12 +1094,12 @@ log_listen_address(
 	)
 {
 	msyslog(LOG_INFO, "%s on %d %s %s",
-		(ep->ignore_packets)
-		    ? "Listen and drop"
-		    : "Listen normally",
-		ep->ifnum,
-		ep->name,
-		sptoa(&ep->sin));
+			(ep->ignore_packets)
+			    ? "Listen and drop"
+			    : "Listen normally",
+			ep->ifnum,
+			ep->name,
+			sptoa(&ep->sin));
 }
 
 


=====================================
ntpd/ntp_loopfilter.c
=====================================
--- a/ntpd/ntp_loopfilter.c
+++ b/ntpd/ntp_loopfilter.c
@@ -499,12 +499,14 @@ local_clock(
 			step_systime(fp_offset, intercept_set_tod);
 			msyslog(LOG_NOTICE, "ntpd: time set %+.6f s",
 			    fp_offset);
-			printf("ntpd: time set %+.6fs\n", fp_offset);
+			if (intercept_get_mode() == none)
+				printf("ntpd: time set %+.6fs\n", fp_offset);
 		} else {
 			adj_systime(fp_offset, intercept_adjtime);
 			msyslog(LOG_NOTICE, "ntpd: time slew %+.6f s",
 			    fp_offset);
-			printf("ntpd: time slew %+.6fs\n", fp_offset);
+			if (intercept_get_mode() == none)
+				printf("ntpd: time slew %+.6fs\n", fp_offset);
 		}
 		record_loop_stats(fp_offset, drift_comp, clock_jitter,
 		    clock_stability, sys_poll);


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -375,10 +375,12 @@ parse_cmdline_opts(
 		/* defer */
 		break;
 	    case 'y':
-		intercept_set_mode(capture);
+		nofork = true;
+		/* further processed by interception code */
 		break;
 	    case 'Y':
-		intercept_set_mode(replay);
+		nofork = true;
+		/* further processed by interception code */
 		break;
 	    case 'z':
 		/* defer */
@@ -580,7 +582,7 @@ ntpdmain(
 		change_logfile(logfilename, false);
 	} else {
 		if (nofork)
-			termlogit = true;
+		    termlogit = (intercept_get_mode() == none || debug > 0);
 		if (saveconfigquit || dumpopts)
 			syslogit = false;
 	}



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/a80eb558fad7046b482430ef6c5601c323cd0f92...b91fe307419b37594c4c518f59366d53692fe3f1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151210/3c80dfac/attachment.html>


More information about the vc mailing list