Hi, Please consider attached version of the patch, which works for me.
-- Dnia 2021-02-08, o godz. 16:37:14 <dewelo...@wp.pl> napisał(a): > Dnia 2021-01-16, o godz. 15:11:22 > Joachim Wiberg <troglo...@gmail.com> napisał(a): > > > This patch adds support in ntpd for logging to syslog, regardless if > > running in the foreground or not. > > > > Hi, > > Unfortunately the patch doesn't work in my case. > Everything is still printed to stdout, nothing to syslog. > > $ ntpd -dd -n -s -S ./script > ntpd: bad address 'europe.pool.ntp.org' > ntpd: poll:1s sockets:0 interval:1s > ntpd: bad address 'europe.pool.ntp.org' > ntpd: poll:13s sockets:0 interval:1s > ntpd: bad address 'europe.pool.ntp.org' > ntpd: poll:29s sockets:0 interval:1s > ^Cntpd: bad address 'europe.pool.ntp.org' > > Isn't the condition present at this line: > > OPT_s = (1 << (9+ENABLE_FEATURE_NTP_AUTH)) * ENABLE_FEATURE_NTPD_SERVER, > inconsistent with the string passed to getopt32? > I modified that part as follows and it started working. > OPT_s = (1 << (7+ENABLE_FEATURE_NTP_AUTH)), > OPT_l = (1 << (8+ENABLE_FEATURE_NTP_AUTH)) * ENABLE_FEATURE_NTPD_SERVER, > OPT_I = (1 << (9+ENABLE_FEATURE_NTP_AUTH)) * ENABLE_FEATURE_NTPD_SERVER, > > > Signed-off-by: Joachim Wiberg <troglo...@gmail.com> > > --- > > networking/ntpd.c | 12 +++++++++++- > > 1 file changed, 11 insertions(+), 1 deletion(-) > > > > diff --git a/networking/ntpd.c b/networking/ntpd.c > > index 1f17b08ef..9307cb731 100644 > > --- a/networking/ntpd.c > > +++ b/networking/ntpd.c > > @@ -72,7 +72,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" > > @@ -82,6 +82,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 > > running in foreground, -n" //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)" @@ -107,6 +108,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 > > @@ -389,6 +391,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), > > }; > > @@ -2484,6 +2487,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" > > @@ -2580,6 +2584,12 @@ static NOINLINE void ntp_init(char **argv) > > config_close(parser); > > } > > #endif > > + > > + if (opts & OPT_s) { > > + openlog(applet_name, LOG_PID, LOG_DAEMON); > > + logmode = LOGMODE_SYSLOG; > > + } > > + > > if (peers) { > > #if ENABLE_FEATURE_NTP_AUTH > > while (peers) { > > _______________________________________________ > busybox mailing list > busybox@busybox.net > http://lists.busybox.net/mailman/listinfo/busybox
--- a/networking/ntpd.c +++ b/networking/ntpd.c @@ -72,7 +72,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" @@ -82,6 +82,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 running in foreground, -n" //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)" @@ -107,6 +108,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,8 +382,9 @@ OPT_w = (1 << (4+ENABLE_FEATURE_NTP_AUTH)), OPT_p = (1 << (5+ENABLE_FEATURE_NTP_AUTH)), 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 << (7+ENABLE_FEATURE_NTP_AUTH)), + OPT_l = (1 << (8+ENABLE_FEATURE_NTP_AUTH)) * ENABLE_FEATURE_NTPD_SERVER, + OPT_I = (1 << (9+ENABLE_FEATURE_NTP_AUTH)) * ENABLE_FEATURE_NTPD_SERVER, /* We hijack some bits for other purposes */ OPT_qq = (1 << 31), }; @@ -2475,7 +2478,7 @@ opts = getopt32(argv, "^" "nqNx" /* compat */ IF_FEATURE_NTP_AUTH("k:") /* compat */ - "wp:*S:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */ + "wp:*S:s"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */ IF_FEATURE_NTPD_SERVER("I:") /* compat */ "d" /* compat */ "46aAbgL" /* compat, ignored */ @@ -2573,6 +2576,12 @@ config_close(parser); } #endif + + if (opts & OPT_s) { + openlog(applet_name, LOG_PID, LOG_DAEMON); + logmode = LOGMODE_SYSLOG; + } + if (peers) { #if ENABLE_FEATURE_NTP_AUTH while (peers) {
_______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox