diff options
-rw-r--r-- | usr.sbin/ntpd/ntpd.c | 16 | ||||
-rw-r--r-- | usr.sbin/ntpd/ntpd.h | 5 |
2 files changed, 13 insertions, 8 deletions
diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c index e9e651b72f1..9a54c524d57 100644 --- a/usr.sbin/ntpd/ntpd.c +++ b/usr.sbin/ntpd/ntpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.103 2016/01/11 15:30:56 deraadt Exp $ */ +/* $OpenBSD: ntpd.c,v 1.104 2016/01/27 21:36:25 bcook Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -132,18 +132,16 @@ main(int argc, char *argv[]) memset(&lconf, 0, sizeof(lconf)); - log_init(1, LOG_DAEMON); /* log to stderr until daemonized */ - while ((ch = getopt(argc, argv, "df:nsSv")) != -1) { switch (ch) { case 'd': - lconf.debug = 1; - log_verbose(1); + lconf.debug = 2; break; case 'f': conffile = optarg; break; case 'n': + lconf.debug = 2; lconf.noaction = 1; break; case 's': @@ -153,7 +151,7 @@ main(int argc, char *argv[]) lconf.settime = 0; break; case 'v': - log_verbose(1); + lconf.verbose++; break; default: usage(); @@ -161,6 +159,9 @@ main(int argc, char *argv[]) } } + /* log to stderr until daemonized */ + log_init(lconf.debug ? lconf.debug : 1, LOG_DAEMON); + argc -= optind; argv += optind; if (argc > 0) @@ -190,6 +191,7 @@ main(int argc, char *argv[]) reset_adjtime(); if (!lconf.settime) { log_init(lconf.debug, LOG_DAEMON); + log_verbose(lconf.verbose); if (!lconf.debug) if (daemon(1, 0)) fatal("daemon"); @@ -269,6 +271,7 @@ main(int argc, char *argv[]) lconf.settime = 0; timeout = INFTIM; log_init(lconf.debug, LOG_DAEMON); + log_verbose(lconf.verbose); log_warnx("no reply received in time, skipping initial " "time setting"); if (!lconf.debug) @@ -395,6 +398,7 @@ dispatch_imsg(struct ntpd_conf *lconf, const char *pw_dir, if (!lconf->settime) break; log_init(lconf->debug, LOG_DAEMON); + log_verbose(lconf->verbose); memcpy(&d, imsg.data, sizeof(d)); ntpd_settime(d); /* daemonize now */ diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h index b950634cb0c..5e9099e023d 100644 --- a/usr.sbin/ntpd/ntpd.h +++ b/usr.sbin/ntpd/ntpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.h,v 1.127 2015/12/19 20:44:35 reyk Exp $ */ +/* $OpenBSD: ntpd.h,v 1.128 2016/01/27 21:36:25 bcook Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -213,9 +213,10 @@ struct ntpd_conf { struct ntp_status status; struct ntp_freq freq; u_int32_t scale; + int debug; + int verbose; u_int8_t listen_all; u_int8_t settime; - u_int8_t debug; u_int8_t noaction; u_int8_t filters; time_t constraint_last; |