|
|
@ -1,4 +1,4 @@ |
|
|
|
From b4f723b7fd4c3a56f8b0e08da5998fa31bac5673 Mon Sep 17 00:00:00 2001 |
|
|
|
From cb6da547c5b532d6e8d241cb993c831605d0d45f Mon Sep 17 00:00:00 2001 |
|
|
|
From: Brent Cook <busterb@gmail.com> |
|
|
|
Date: Wed, 31 Dec 2014 08:26:41 -0600 |
|
|
|
Subject: [PATCH 07/12] add -p option to create a pid file |
|
|
@ -8,9 +8,9 @@ This is used in both the Gentoo and Debian ports. |
|
|
|
Origin: https://bugs.gentoo.org/show_bug.cgi?id=493082 |
|
|
|
---
|
|
|
|
src/usr.sbin/ntpd/ntpd.8 | 4 ++++ |
|
|
|
src/usr.sbin/ntpd/ntpd.c | 35 +++++++++++++++++++++++++++++------ |
|
|
|
src/usr.sbin/ntpd/ntpd.c | 35 +++++++++++++++++++++++++++++++---- |
|
|
|
src/usr.sbin/ntpd/ntpd.h | 1 + |
|
|
|
3 files changed, 34 insertions(+), 6 deletions(-) |
|
|
|
3 files changed, 36 insertions(+), 4 deletions(-) |
|
|
|
|
|
|
|
diff --git a/src/usr.sbin/ntpd/ntpd.8 b/src/usr.sbin/ntpd/ntpd.8
|
|
|
|
index dcfb6d2..1b885a1 100644
|
|
|
@ -35,7 +35,7 @@ index dcfb6d2..1b885a1 100644 |
|
|
|
Do not set the time immediately at startup. |
|
|
|
This is the default. |
|
|
|
diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c
|
|
|
|
index 0f43b1f..e31db98 100644
|
|
|
|
index b6eb98e..608e6fd 100644
|
|
|
|
--- a/src/usr.sbin/ntpd/ntpd.c
|
|
|
|
+++ b/src/usr.sbin/ntpd/ntpd.c
|
|
|
|
@@ -87,6 +87,18 @@ sighdlr(int sig)
|
|
|
@ -66,17 +66,17 @@ index 0f43b1f..e31db98 100644 |
|
|
|
__progname); |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
@@ -134,7 +146,7 @@ main(int argc, char *argv[])
|
|
|
|
@@ -132,7 +144,7 @@ main(int argc, char *argv[])
|
|
|
|
|
|
|
|
log_init(1, LOG_DAEMON); /* log to stderr until daemonized */ |
|
|
|
memset(&lconf, 0, sizeof(lconf)); |
|
|
|
|
|
|
|
- while ((ch = getopt(argc, argv, "df:nsSv")) != -1) {
|
|
|
|
+ while ((ch = getopt(argc, argv, "df:np:sSv")) != -1) {
|
|
|
|
switch (ch) { |
|
|
|
case 'd': |
|
|
|
lconf.debug = 1; |
|
|
|
@@ -146,6 +158,9 @@ main(int argc, char *argv[])
|
|
|
|
case 'n': |
|
|
|
lconf.debug = 2; |
|
|
|
@@ -144,6 +156,9 @@ main(int argc, char *argv[])
|
|
|
|
lconf.debug = 2; |
|
|
|
lconf.noaction = 1; |
|
|
|
break; |
|
|
|
+ case 'p':
|
|
|
@ -85,12 +85,16 @@ index 0f43b1f..e31db98 100644 |
|
|
|
case 's': |
|
|
|
lconf.settime = 1; |
|
|
|
break; |
|
|
|
@@ -190,9 +205,11 @@ main(int argc, char *argv[])
|
|
|
|
@@ -191,10 +206,16 @@ main(int argc, char *argv[])
|
|
|
|
reset_adjtime(); |
|
|
|
if (!lconf.settime) { |
|
|
|
log_init(lconf.debug, LOG_DAEMON); |
|
|
|
- if (!lconf.debug)
|
|
|
|
+<<<<<<< 00fff5a8c36c3b3574abf8bd4bb1a558d1f8232d
|
|
|
|
log_verbose(lconf.verbose); |
|
|
|
if (!lconf.debug) |
|
|
|
+=======
|
|
|
|
+ if (!lconf.debug) {
|
|
|
|
+>>>>>>> add -p option to create a pid file
|
|
|
|
if (daemon(1, 0)) |
|
|
|
fatal("daemon"); |
|
|
|
+ writepid(&lconf);
|
|
|
@ -98,8 +102,8 @@ index 0f43b1f..e31db98 100644 |
|
|
|
} else |
|
|
|
timeout = SETTIME_TIMEOUT * 1000; |
|
|
|
|
|
|
|
@@ -271,9 +288,11 @@ main(int argc, char *argv[])
|
|
|
|
log_init(lconf.debug, LOG_DAEMON); |
|
|
|
@@ -273,9 +294,11 @@ main(int argc, char *argv[])
|
|
|
|
log_verbose(lconf.verbose); |
|
|
|
log_warnx("no reply received in time, skipping initial " |
|
|
|
"time setting"); |
|
|
|
- if (!lconf.debug)
|
|
|
@ -111,7 +115,7 @@ index 0f43b1f..e31db98 100644 |
|
|
|
} |
|
|
|
|
|
|
|
if (nfds > 0 && (pfd[PFD_PIPE].revents & POLLOUT)) |
|
|
|
@@ -316,6 +335,8 @@ main(int argc, char *argv[])
|
|
|
|
@@ -318,6 +341,8 @@ main(int argc, char *argv[])
|
|
|
|
msgbuf_clear(&ibuf->w); |
|
|
|
free(ibuf); |
|
|
|
log_info("Terminating"); |
|
|
@ -120,7 +124,7 @@ index 0f43b1f..e31db98 100644 |
|
|
|
return (0); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -398,9 +419,11 @@ dispatch_imsg(struct ntpd_conf *lconf, const char *pw_dir,
|
|
|
|
@@ -401,9 +426,11 @@ dispatch_imsg(struct ntpd_conf *lconf, const char *pw_dir,
|
|
|
|
memcpy(&d, imsg.data, sizeof(d)); |
|
|
|
ntpd_settime(d); |
|
|
|
/* daemonize now */ |
|
|
@ -133,20 +137,11 @@ index 0f43b1f..e31db98 100644 |
|
|
|
lconf->settime = 0; |
|
|
|
timeout = INFTIM; |
|
|
|
break; |
|
|
|
@@ -528,7 +551,7 @@ readfreq(void)
|
|
|
|
freqfp = fopen(DRIFTFILE, "w"); |
|
|
|
return; |
|
|
|
} |
|
|
|
-
|
|
|
|
+
|
|
|
|
freqfp = fdopen(fd, "r+"); |
|
|
|
|
|
|
|
/* if we're adjusting frequency already, don't override */ |
|
|
|
diff --git a/src/usr.sbin/ntpd/ntpd.h b/src/usr.sbin/ntpd/ntpd.h
|
|
|
|
index 7e739c4..864d4c4 100644
|
|
|
|
index dfcaf33..24a3222 100644
|
|
|
|
--- a/src/usr.sbin/ntpd/ntpd.h
|
|
|
|
+++ b/src/usr.sbin/ntpd/ntpd.h
|
|
|
|
@@ -241,6 +241,7 @@ struct ntpd_conf {
|
|
|
|
@@ -243,6 +243,7 @@ struct ntpd_conf {
|
|
|
|
u_int constraint_errors; |
|
|
|
u_int8_t *ca; |
|
|
|
size_t ca_len; |
|
|
@ -155,5 +150,5 @@ index 7e739c4..864d4c4 100644 |
|
|
|
|
|
|
|
struct ctl_show_status { |
|
|
|
--
|
|
|
|
2.6.4 |
|
|
|
2.7.0 |
|
|
|
|