|
@ -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> |
|
|
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> |
|
@ -132,18 +132,16 @@ main(int argc, char *argv[]) |
|
|
|
|
|
|
|
|
memset(&lconf, 0, sizeof(lconf)); |
|
|
memset(&lconf, 0, sizeof(lconf)); |
|
|
|
|
|
|
|
|
log_init(1, LOG_DAEMON); /* log to stderr until daemonized */ |
|
|
|
|
|
|
|
|
|
|
|
while ((ch = getopt(argc, argv, "df:nsSv")) != -1) { |
|
|
while ((ch = getopt(argc, argv, "df:nsSv")) != -1) { |
|
|
switch (ch) { |
|
|
switch (ch) { |
|
|
case 'd': |
|
|
case 'd': |
|
|
lconf.debug = 1; |
|
|
|
|
|
log_verbose(1); |
|
|
|
|
|
|
|
|
lconf.debug = 2; |
|
|
break; |
|
|
break; |
|
|
case 'f': |
|
|
case 'f': |
|
|
conffile = optarg; |
|
|
conffile = optarg; |
|
|
break; |
|
|
break; |
|
|
case 'n': |
|
|
case 'n': |
|
|
|
|
|
lconf.debug = 2; |
|
|
lconf.noaction = 1; |
|
|
lconf.noaction = 1; |
|
|
break; |
|
|
break; |
|
|
case 's': |
|
|
case 's': |
|
@ -153,7 +151,7 @@ main(int argc, char *argv[]) |
|
|
lconf.settime = 0; |
|
|
lconf.settime = 0; |
|
|
break; |
|
|
break; |
|
|
case 'v': |
|
|
case 'v': |
|
|
log_verbose(1); |
|
|
|
|
|
|
|
|
lconf.verbose++; |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
usage(); |
|
|
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; |
|
|
argc -= optind; |
|
|
argv += optind; |
|
|
argv += optind; |
|
|
if (argc > 0) |
|
|
if (argc > 0) |
|
@ -190,6 +191,7 @@ main(int argc, char *argv[]) |
|
|
reset_adjtime(); |
|
|
reset_adjtime(); |
|
|
if (!lconf.settime) { |
|
|
if (!lconf.settime) { |
|
|
log_init(lconf.debug, LOG_DAEMON); |
|
|
log_init(lconf.debug, LOG_DAEMON); |
|
|
|
|
|
log_verbose(lconf.verbose); |
|
|
if (!lconf.debug) |
|
|
if (!lconf.debug) |
|
|
if (daemon(1, 0)) |
|
|
if (daemon(1, 0)) |
|
|
fatal("daemon"); |
|
|
fatal("daemon"); |
|
@ -269,6 +271,7 @@ main(int argc, char *argv[]) |
|
|
lconf.settime = 0; |
|
|
lconf.settime = 0; |
|
|
timeout = INFTIM; |
|
|
timeout = INFTIM; |
|
|
log_init(lconf.debug, LOG_DAEMON); |
|
|
log_init(lconf.debug, LOG_DAEMON); |
|
|
|
|
|
log_verbose(lconf.verbose); |
|
|
log_warnx("no reply received in time, skipping initial " |
|
|
log_warnx("no reply received in time, skipping initial " |
|
|
"time setting"); |
|
|
"time setting"); |
|
|
if (!lconf.debug) |
|
|
if (!lconf.debug) |
|
@ -395,6 +398,7 @@ dispatch_imsg(struct ntpd_conf *lconf, const char *pw_dir, |
|
|
if (!lconf->settime) |
|
|
if (!lconf->settime) |
|
|
break; |
|
|
break; |
|
|
log_init(lconf->debug, LOG_DAEMON); |
|
|
log_init(lconf->debug, LOG_DAEMON); |
|
|
|
|
|
log_verbose(lconf->verbose); |
|
|
memcpy(&d, imsg.data, sizeof(d)); |
|
|
memcpy(&d, imsg.data, sizeof(d)); |
|
|
ntpd_settime(d); |
|
|
ntpd_settime(d); |
|
|
/* daemonize now */ |
|
|
/* daemonize now */ |
|
|