[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] ntpd: support logging to syslog
From:       Joachim Nilsson <troglobit () gmail ! com>
Date:       2020-05-09 11:12:51
Message-ID: 20200509111251.2430853-1-troglobit () gmail ! com
[Download RAW message or body]

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
---
 networking/ntpd.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/networking/ntpd.c b/networking/ntpd.c
index 0f12409f9..3635dc016 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -73,7 +73,7 @@
 //kbuild:lib-$(CONFIG_NTPD) += ntpd.o
 
 //usage:#define ntpd_trivial_usage
-//usage:	"[-dnqNw"IF_FEATURE_NTPD_SERVER("l] [-I IFACE")"] [-S PROG]"
+//usage:	"[-dnqsNw"IF_FEATURE_NTPD_SERVER("l] [-I IFACE")"] [-S PROG]"
 //usage:	IF_NOT_FEATURE_NTP_AUTH(" [-p PEER]...")
 //usage:	IF_FEATURE_NTP_AUTH(" [-k KEYFILE] [-p [keyno:N:]PEER]...")
 //usage:#define ntpd_full_usage "\n\n"
@@ -83,6 +83,7 @@
 //usage:     "\n	-q	Quit after clock is set"
 //usage:     "\n	-N	Run at high priority"
 //usage:     "\n	-w	Do not set time (only query peers), implies -n"
+//usage:     "\n	-s	Log to syslog, even if -n is given"
 //usage:     "\n	-S PROG	Run PROG after stepping time, stratum change, and every 11 min"
 //usage:	IF_NOT_FEATURE_NTP_AUTH(
 //usage:     "\n	-p PEER	Obtain time from PEER (may be repeated)"
@@ -108,6 +109,7 @@
 
 #include "libbb.h"
 #include <math.h>
+#include <syslog.h>
 #include <netinet/ip.h> /* For IPTOS_DSCP_AF21 definition */
 #include <sys/timex.h>
 #ifndef IPTOS_DSCP_AF21
@@ -380,6 +382,7 @@ enum {
 	OPT_S = (1 << (6+ENABLE_FEATURE_NTP_AUTH)),
 	OPT_l = (1 << (7+ENABLE_FEATURE_NTP_AUTH)) * ENABLE_FEATURE_NTPD_SERVER,
 	OPT_I = (1 << (8+ENABLE_FEATURE_NTP_AUTH)) * ENABLE_FEATURE_NTPD_SERVER,
+	OPT_s = (1 << (9+ENABLE_FEATURE_NTP_AUTH)) * ENABLE_FEATURE_NTPD_SERVER,
 	/* We hijack some bits for other purposes */
 	OPT_qq = (1 << 31),
 };
@@ -2444,6 +2447,7 @@ static NOINLINE void ntp_init(char **argv)
 			IF_FEATURE_NTP_AUTH("k:")  /* compat */
 			"wp:*S:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */
 			IF_FEATURE_NTPD_SERVER("I:") /* compat */
+			"s"    /* NOT compat */
 			"d" /* compat */
 			"46aAbgL" /* compat, ignored */
 				"\0"
@@ -2540,6 +2544,13 @@ static NOINLINE void ntp_init(char **argv)
 		config_close(parser);
 	}
 #endif
+
+	/* Regardless of OPT_n we enable syslog here */
+	if (opts & OPT_s) {
+		openlog(applet_name, LOG_PID, LOG_DAEMON);
+		logmode = LOGMODE_SYSLOG;
+	}
+
 	if (peers) {
 #if ENABLE_FEATURE_NTP_AUTH
 		while (peers) {
-- 
2.25.1

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic