From a18259d9b9f596aee1a9bd0b6f2c31f98db6d7a5 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sun, 6 Dec 2015 22:47:02 -0600 Subject: [PATCH] portability fixes --- include/unistd.h | 2 ++ ...initialize-setproctitle-where-needed.patch | 20 +++++++++++++------ ...-when-constraint-support-is-disabled.patch | 2 +- ...-updating-the-realtime-clock-on-sync.patch | 6 +++--- .../0012-Deal-with-missing-SO_TIMESTAMP.patch | 2 +- update.sh | 2 +- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/include/unistd.h b/include/unistd.h index 05ac5ec..c112298 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -8,6 +8,8 @@ #ifndef LIBCOMPAT_UNISTD_H #define LIBCOMPAT_UNISTD_H +#define pledge(request, paths) 0 + #ifndef HAVE_GETENTROPY int getentropy(void *buf, size_t buflen); #endif diff --git a/patches/0009-initialize-setproctitle-where-needed.patch b/patches/0009-initialize-setproctitle-where-needed.patch index 5322fba..65582a4 100644 --- a/patches/0009-initialize-setproctitle-where-needed.patch +++ b/patches/0009-initialize-setproctitle-where-needed.patch @@ -1,4 +1,4 @@ -From 3f56ed57c9f7dcf2c77d29fadb307d10664c5075 Mon Sep 17 00:00:00 2001 +From 0c286469c195738efc45001b1fcd4f8b4044a141 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Mon, 12 Jan 2015 06:18:31 -0600 Subject: [PATCH 09/12] initialize setproctitle where needed @@ -6,11 +6,11 @@ Subject: [PATCH 09/12] initialize setproctitle where needed We need to save a copy of argv and __progname to avoid setproctitle clobbering them. --- - src/usr.sbin/ntpd/ntpd.c | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) + src/usr.sbin/ntpd/ntpd.c | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c -index 40570ee..b86d6ed 100644 +index 40570ee..3d0ceb2 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/usr.sbin/ntpd/ntpd.c @@ -116,6 +116,13 @@ usage(void) @@ -27,14 +27,13 @@ index 40570ee..b86d6ed 100644 int main(int argc, char *argv[]) { -@@ -145,6 +152,19 @@ main(int argc, char *argv[]) +@@ -145,6 +152,18 @@ main(int argc, char *argv[]) log_init(1); /* log to stderr until daemonized */ + __progname = get_progname(argv[0]); + +#ifndef HAVE_SETPROCTITLE -+ int i; + /* Prepare for later setproctitle emulation */ + saved_argv = calloc(argc + 1, sizeof(*saved_argv)); + for (i = 0; i < argc; i++) @@ -47,6 +46,15 @@ index 40570ee..b86d6ed 100644 while ((ch = getopt(argc, argv, "df:np:sSv")) != -1) { switch (ch) { case 'd': +@@ -549,7 +568,7 @@ readfreq(void) + freqfp = fopen(DRIFTFILE, "w"); + return; + } +- ++ + freqfp = fdopen(fd, "r+"); + + /* if we're adjusting frequency already, don't override */ -- 2.6.3 diff --git a/patches/0010-Notify-the-user-when-constraint-support-is-disabled.patch b/patches/0010-Notify-the-user-when-constraint-support-is-disabled.patch index 3300e72..f1536cc 100644 --- a/patches/0010-Notify-the-user-when-constraint-support-is-disabled.patch +++ b/patches/0010-Notify-the-user-when-constraint-support-is-disabled.patch @@ -1,4 +1,4 @@ -From bdbcdad24473d94d2871650e65adba694e078a7b Mon Sep 17 00:00:00 2001 +From c685d444684c047721ce4c3789aa50eab7ed7a91 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Fri, 27 Mar 2015 23:14:15 -0500 Subject: [PATCH 10/12] Notify the user when constraint support is disabled. diff --git a/patches/0011-add-a-method-for-updating-the-realtime-clock-on-sync.patch b/patches/0011-add-a-method-for-updating-the-realtime-clock-on-sync.patch index 587fb5e..44fb2ad 100644 --- a/patches/0011-add-a-method-for-updating-the-realtime-clock-on-sync.patch +++ b/patches/0011-add-a-method-for-updating-the-realtime-clock-on-sync.patch @@ -1,4 +1,4 @@ -From c826fa9409c17c67c347707fb146b22915815449 Mon Sep 17 00:00:00 2001 +From 4a446e2cfe1792cd75af53b515fe0b71b6c97b0f Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Mon, 4 May 2015 04:27:29 -0500 Subject: [PATCH 11/12] add a method for updating the realtime clock on sync @@ -9,7 +9,7 @@ from Christian Weisgerber 1 file changed, 2 insertions(+) diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c -index b86d6ed..7cccb75 100644 +index 3d0ceb2..eef7d2c 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/usr.sbin/ntpd/ntpd.c @@ -54,6 +54,7 @@ const char *ctl_lookup_option(char *, const char **); @@ -20,7 +20,7 @@ index b86d6ed..7cccb75 100644 volatile sig_atomic_t quit = 0; volatile sig_atomic_t reconfig = 0; -@@ -487,6 +488,7 @@ ntpd_adjtime(double d) +@@ -486,6 +487,7 @@ ntpd_adjtime(double d) else if (!firstadj && olddelta.tv_sec == 0 && olddelta.tv_usec == 0) synced = 1; firstadj = 0; diff --git a/patches/0012-Deal-with-missing-SO_TIMESTAMP.patch b/patches/0012-Deal-with-missing-SO_TIMESTAMP.patch index 2d0fe32..7ccd9c7 100644 --- a/patches/0012-Deal-with-missing-SO_TIMESTAMP.patch +++ b/patches/0012-Deal-with-missing-SO_TIMESTAMP.patch @@ -1,4 +1,4 @@ -From 38933e5e9b3aa2d1b6d2b6fcb609494694fdfe44 Mon Sep 17 00:00:00 2001 +From 585ee6ed92a06261aea08b05963789652f32a997 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sun, 6 Dec 2015 22:35:38 -0600 Subject: [PATCH 12/12] Deal with missing SO_TIMESTAMP diff --git a/update.sh b/update.sh index 039398a..a85df84 100755 --- a/update.sh +++ b/update.sh @@ -45,7 +45,7 @@ for i in explicit_bzero.c strlcpy.c strlcat.c; do done $CP_LIBC $libc_src/stdlib/reallocarray.c compat $CP_LIBC $libc_src/stdlib/strtonum.c compat -$CP $libc_src/crypt/arc4random.c compat +$CP_LIBC $libc_src/crypt/arc4random.c compat $CP_LIBC $libc_src/crypt/arc4random_uniform.c compat $CP_LIBC $libc_src/crypt/chacha_private.h compat $CP_LIBC $libc_src/hash/md5.c compat