|
|
@ -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 */ |
|
|
|