[Git][NTPsec/ntpsec][master] 2 commits: Hide needlessly exposed syslog_file variable.

Eric S. Raymond gitlab at mg.gitlab.com
Mon Nov 13 14:00:53 UTC 2017


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


Commits:
c29b5b83 by Eric S. Raymond at 2017-11-13T09:00:45-05:00
Hide needlessly exposed syslog_file variable.

It was exposed in only one place, in ntpd.c, and there was no way for that
test to ever fire as nothing before it in flow of control ever set the
variable.

- - - - -
57c39a0b by Eric S. Raymond at 2017-11-13T09:00:45-05:00
Address GitLab issue #410: ntpq error message needs work

- - - - -


4 changed files:

- include/ntp_syslog.h
- libntp/msyslog.c
- ntpd/ntpd.c
- pylib/packet.py


Changes:

=====================================
include/ntp_syslog.h
=====================================
--- a/include/ntp_syslog.h
+++ b/include/ntp_syslog.h
@@ -14,8 +14,6 @@ extern bool	syslogit;	/* log to syslogit */
 extern bool	termlogit;	/* duplicate to stdout/err */
 extern bool	termlogit_pid;
 extern bool	msyslog_include_timestamp;
-extern FILE *	syslog_file;	/* if syslogit is false, log to
-				   this file and not syslog */
 
 /*
  * syslog output control


=====================================
libntp/msyslog.c
=====================================
--- a/libntp/msyslog.c
+++ b/libntp/msyslog.c
@@ -27,7 +27,8 @@ bool    syslogit = true;        /* log messages to syslog */
 bool    termlogit = true;       /* duplicate to stdout/err */
 bool	termlogit_pid = true;
 bool	msyslog_include_timestamp = true;
-FILE *	syslog_file;
+
+static FILE *	syslog_file;
 static char *	syslog_fname;
 static char *	syslog_abs_fname;
 


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -612,11 +612,6 @@ ntpdmain(
 		 */
 		termlogit = false;    /* do not use stderr after fork */
 		closelog();
-		if (syslog_file != NULL) {
-			fclose(syslog_file);
-			syslog_file = NULL;
-			syslogit = true;
-		}
 		close_all_except(waitsync_fd_to_close);
 		INSIST(0 == open("/dev/null", 0) && 1 == dup2(0, 1) \
 			&& 2 == dup2(0, 2));


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -656,6 +656,7 @@ SERR_BADASSOC = "***Association ID {0} unknown to server\n"
 SERR_UNKNOWNVAR = "***A request variable unknown to the server\n"
 SERR_BADVALUE = "***Server indicates a request variable was bad\n"
 SERR_UNSPEC = "***Server returned an unspecified error\n"
+SERR_SOCKET = "***Socket error; probably ntpd is not running\n"
 SERR_TIMEOUT = "***Request timed out\n"
 SERR_INCOMPLETE = "***Response from server was incomplete\n"
 SERR_TOOMUCH = "***Buffer size exceeded for returned data\n"
@@ -1061,7 +1062,7 @@ class ControlSession:
                 rawdata = polybytes(self.sock.recv(4096))
             except socket.error:
                 # usually, errno 111: connection refused
-                raise ControlException(SERR_UNSPEC)
+                raise ControlException(SERR_SOCKET)
 
             warndbg("Received %d octets\n" % len(rawdata), 3)
             rpkt = ControlPacket(self)



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/608c977b794ef9d32f19cf31a76874796994432b...57c39a0b9976a3bc1b8be4d1e24ead5c8a6f6f4d

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/608c977b794ef9d32f19cf31a76874796994432b...57c39a0b9976a3bc1b8be4d1e24ead5c8a6f6f4d
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20171113/5cf549d8/attachment.html>


More information about the vc mailing list