From c551d18d1f43e030bfbf0b05ced383a3560b60be Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sat, 19 Jan 2019 05:11:32 -0600 Subject: [PATCH] add adjtimex over adjtime for supported OSes --- ...records-on-IPv4-networks-more-libera.patch | 2 +- ...EAI_NODATA-does-not-exist-everywhere.patch | 2 +- ...ll-in-sin_len-sin6_len-if-they-exist.patch | 2 +- ...heck-if-rdomain-support-is-available.patch | 2 +- ...onf-to-indicate-OS-dependent-options.patch | 2 +- ...ding-default-user-and-file-locations.patch | 2 +- ...07-add-p-option-to-create-a-pid-file.patch | 2 +- ...initialize-setproctitle-where-needed.patch | 2 +- ...-when-constraint-support-is-disabled.patch | 2 +- ...-updating-the-realtime-clock-on-sync.patch | 2 +- .../0011-Deal-with-missing-SO_TIMESTAMP.patch | 2 +- ...012-check-result-of-ftello-ftruncate.patch | 2 +- ...if-we-are-binding-to-an-IPv6-address.patch | 2 +- ...r-adjtime-check-return-value-and-adj.patch | 74 +++++++++++++++++++ 14 files changed, 87 insertions(+), 13 deletions(-) create mode 100644 patches/0014-use-adjtimex-over-adjtime-check-return-value-and-adj.patch diff --git a/patches/0001-Handle-IPv6-DNS-records-on-IPv4-networks-more-libera.patch b/patches/0001-Handle-IPv6-DNS-records-on-IPv4-networks-more-libera.patch index 383786d..59da543 100644 --- a/patches/0001-Handle-IPv6-DNS-records-on-IPv4-networks-more-libera.patch +++ b/patches/0001-Handle-IPv6-DNS-records-on-IPv4-networks-more-libera.patch @@ -1,7 +1,7 @@ From 641fc1e7220515456c33a8991890a91608a5b983 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Tue, 30 Dec 2014 09:10:22 -0600 -Subject: [PATCH 01/13] Handle IPv6 DNS records on IPv4 networks more liberally +Subject: [PATCH 01/14] Handle IPv6 DNS records on IPv4 networks more liberally Rather than fail on IPv4 only networks when seeing an IPv6 DNS record, just give a warning. diff --git a/patches/0002-EAI_NODATA-does-not-exist-everywhere.patch b/patches/0002-EAI_NODATA-does-not-exist-everywhere.patch index 89f93c8..d3371ab 100644 --- a/patches/0002-EAI_NODATA-does-not-exist-everywhere.patch +++ b/patches/0002-EAI_NODATA-does-not-exist-everywhere.patch @@ -1,7 +1,7 @@ From 683cb25dcb78b92c29c5148becece3cf4f0c6a28 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Tue, 30 Dec 2014 09:04:08 -0600 -Subject: [PATCH 02/13] EAI_NODATA does not exist everywhere +Subject: [PATCH 02/14] EAI_NODATA does not exist everywhere FreeBSD says it is deprecated #ifdef's it out. diff --git a/patches/0003-conditionally-fill-in-sin_len-sin6_len-if-they-exist.patch b/patches/0003-conditionally-fill-in-sin_len-sin6_len-if-they-exist.patch index 920a502..6c10cf5 100644 --- a/patches/0003-conditionally-fill-in-sin_len-sin6_len-if-they-exist.patch +++ b/patches/0003-conditionally-fill-in-sin_len-sin6_len-if-they-exist.patch @@ -1,7 +1,7 @@ From 5d2c25bfd0ff11d74ac912313d405247cbaf5ee2 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Tue, 30 Dec 2014 09:02:50 -0600 -Subject: [PATCH 03/13] conditionally fill in sin_len/sin6_len if they exist +Subject: [PATCH 03/14] conditionally fill in sin_len/sin6_len if they exist --- src/usr.sbin/ntpd/parse.y | 8 +++++--- diff --git a/patches/0004-check-if-rdomain-support-is-available.patch b/patches/0004-check-if-rdomain-support-is-available.patch index 048c0ee..690dd43 100644 --- a/patches/0004-check-if-rdomain-support-is-available.patch +++ b/patches/0004-check-if-rdomain-support-is-available.patch @@ -1,7 +1,7 @@ From 546b4b7926dc14f0ea6a60182af23b865e0d18ad Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Tue, 30 Dec 2014 09:05:46 -0600 -Subject: [PATCH 04/13] check if rdomain support is available. +Subject: [PATCH 04/14] check if rdomain support is available. Handle FreeBSD's calling rdomain 'FIB'. - from naddy@openbsd.org diff --git a/patches/0005-update-ntpd.conf-to-indicate-OS-dependent-options.patch b/patches/0005-update-ntpd.conf-to-indicate-OS-dependent-options.patch index 11becbf..357a16c 100644 --- a/patches/0005-update-ntpd.conf-to-indicate-OS-dependent-options.patch +++ b/patches/0005-update-ntpd.conf-to-indicate-OS-dependent-options.patch @@ -1,7 +1,7 @@ From 9395697554026abb8eb35dd6b268acb536b57d1d Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Tue, 30 Dec 2014 09:20:03 -0600 -Subject: [PATCH 05/13] update ntpd.conf to indicate OS-dependent options +Subject: [PATCH 05/14] update ntpd.conf to indicate OS-dependent options Also, clarify listening behavior based on a patch from Dererk diff --git a/patches/0006-allow-overriding-default-user-and-file-locations.patch b/patches/0006-allow-overriding-default-user-and-file-locations.patch index 122df7a..958937a 100644 --- a/patches/0006-allow-overriding-default-user-and-file-locations.patch +++ b/patches/0006-allow-overriding-default-user-and-file-locations.patch @@ -1,7 +1,7 @@ From 00ee3b5aea27bc10b3ad6b732dd582b65c74c795 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Thu, 1 Jan 2015 07:18:11 -0600 -Subject: [PATCH 06/13] allow overriding default user and file locations +Subject: [PATCH 06/14] allow overriding default user and file locations Allow the build process to override the default ntpd file paths and default user. diff --git a/patches/0007-add-p-option-to-create-a-pid-file.patch b/patches/0007-add-p-option-to-create-a-pid-file.patch index 7ec02ef..816140e 100644 --- a/patches/0007-add-p-option-to-create-a-pid-file.patch +++ b/patches/0007-add-p-option-to-create-a-pid-file.patch @@ -1,7 +1,7 @@ From a9008bf22c4f706cf2a4ce12dac9eb282f295933 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Wed, 31 Dec 2014 08:26:41 -0600 -Subject: [PATCH 07/13] add -p option to create a pid file +Subject: [PATCH 07/14] add -p option to create a pid file This is used in both the Gentoo and Debian ports. diff --git a/patches/0008-initialize-setproctitle-where-needed.patch b/patches/0008-initialize-setproctitle-where-needed.patch index 266fbb4..3f97dd1 100644 --- a/patches/0008-initialize-setproctitle-where-needed.patch +++ b/patches/0008-initialize-setproctitle-where-needed.patch @@ -1,7 +1,7 @@ From fb2c22a2d06541415f153e195ce577e475cdf26a Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Mon, 12 Jan 2015 06:18:31 -0600 -Subject: [PATCH 08/13] initialize setproctitle where needed +Subject: [PATCH 08/14] initialize setproctitle where needed We need to save a copy of argv and __progname to avoid setproctitle clobbering them. diff --git a/patches/0009-Notify-the-user-when-constraint-support-is-disabled.patch b/patches/0009-Notify-the-user-when-constraint-support-is-disabled.patch index d44aedd..040b59a 100644 --- a/patches/0009-Notify-the-user-when-constraint-support-is-disabled.patch +++ b/patches/0009-Notify-the-user-when-constraint-support-is-disabled.patch @@ -1,7 +1,7 @@ From 1c8dc7b9bda86123ccc6744142a80520b75e0b9e Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Fri, 27 Mar 2015 23:14:15 -0500 -Subject: [PATCH 09/13] Notify the user when constraint support is disabled. +Subject: [PATCH 09/14] Notify the user when constraint support is disabled. Update the manpage and warn if constraints are configured but ntpd is built without libtls present. diff --git a/patches/0010-add-a-method-for-updating-the-realtime-clock-on-sync.patch b/patches/0010-add-a-method-for-updating-the-realtime-clock-on-sync.patch index 51a2b3b..d45f2d9 100644 --- a/patches/0010-add-a-method-for-updating-the-realtime-clock-on-sync.patch +++ b/patches/0010-add-a-method-for-updating-the-realtime-clock-on-sync.patch @@ -1,7 +1,7 @@ From 6f16675197729ad7cbcb03fa2f95b38a08e92679 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Mon, 4 May 2015 04:27:29 -0500 -Subject: [PATCH 10/13] add a method for updating the realtime clock on sync +Subject: [PATCH 10/14] add a method for updating the realtime clock on sync from Christian Weisgerber --- diff --git a/patches/0011-Deal-with-missing-SO_TIMESTAMP.patch b/patches/0011-Deal-with-missing-SO_TIMESTAMP.patch index f8a0614..91ae38b 100644 --- a/patches/0011-Deal-with-missing-SO_TIMESTAMP.patch +++ b/patches/0011-Deal-with-missing-SO_TIMESTAMP.patch @@ -1,7 +1,7 @@ From b6d55ddfe09268467fa7953037be7383bbab7154 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sun, 6 Dec 2015 22:35:38 -0600 -Subject: [PATCH 11/13] Deal with missing SO_TIMESTAMP +Subject: [PATCH 11/14] Deal with missing SO_TIMESTAMP from Paul B. Henson" diff --git a/patches/0012-check-result-of-ftello-ftruncate.patch b/patches/0012-check-result-of-ftello-ftruncate.patch index 7dc428e..fa0f642 100644 --- a/patches/0012-check-result-of-ftello-ftruncate.patch +++ b/patches/0012-check-result-of-ftello-ftruncate.patch @@ -1,7 +1,7 @@ From b8220a87e4121bd764aa6bf092bd2a2a323c883c Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Mon, 21 Dec 2015 05:53:20 -0600 -Subject: [PATCH 12/13] check result of ftello/ftruncate +Subject: [PATCH 12/14] check result of ftello/ftruncate --- src/usr.sbin/ntpd/ntpd.c | 7 +++++-- diff --git a/patches/0013-set-IPV6_V6ONLY-if-we-are-binding-to-an-IPv6-address.patch b/patches/0013-set-IPV6_V6ONLY-if-we-are-binding-to-an-IPv6-address.patch index 275f1e4..1da56cf 100644 --- a/patches/0013-set-IPV6_V6ONLY-if-we-are-binding-to-an-IPv6-address.patch +++ b/patches/0013-set-IPV6_V6ONLY-if-we-are-binding-to-an-IPv6-address.patch @@ -1,7 +1,7 @@ From 4f01d08765ee2d031e703e3201a07793247fa323 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sat, 13 Aug 2016 14:22:02 -0500 -Subject: [PATCH 13/13] set IPV6_V6ONLY if we are binding to an IPv6 address +Subject: [PATCH 13/14] set IPV6_V6ONLY if we are binding to an IPv6 address --- src/usr.sbin/ntpd/server.c | 9 +++++++++ diff --git a/patches/0014-use-adjtimex-over-adjtime-check-return-value-and-adj.patch b/patches/0014-use-adjtimex-over-adjtime-check-return-value-and-adj.patch new file mode 100644 index 0000000..149d178 --- /dev/null +++ b/patches/0014-use-adjtimex-over-adjtime-check-return-value-and-adj.patch @@ -0,0 +1,74 @@ +From 98f4a4523f158129a49b16a4e0ccc4bb50a62a31 Mon Sep 17 00:00:00 2001 +From: Brent Cook +Date: Sat, 19 Jan 2019 04:25:44 -0600 +Subject: [PATCH 14/14] use adjtimex over adjtime, check return value and + adjust offset as needed + +--- + src/usr.sbin/ntpd/ntpd.c | 31 ++++++++++++++++++++++++++++--- + 1 file changed, 28 insertions(+), 3 deletions(-) + +diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c +index c3b7ab07e1..4d840767b0 100644 +--- a/src/usr.sbin/ntpd/ntpd.c ++++ b/src/usr.sbin/ntpd/ntpd.c +@@ -17,6 +17,9 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef HAVE_ADJTIMEX ++#include ++#endif + #include + #include + #include +@@ -478,21 +481,43 @@ reset_adjtime(void) + int + ntpd_adjtime(double d) + { +- struct timeval tv, olddelta; + int synced = 0; + static int firstadj = 1; ++ double threshold = (double)LOG_NEGLIGIBLE_ADJTIME / 1000; + + d += getoffset(); +- if (d >= (double)LOG_NEGLIGIBLE_ADJTIME / 1000 || +- d <= -1 * (double)LOG_NEGLIGIBLE_ADJTIME / 1000) ++ if (d >= threshold || d <= -1 * threshold) + log_info("adjusting local clock by %fs", d); + else + log_debug("adjusting local clock by %fs", d); ++ ++#ifdef HAVE_ADJTIMEX ++ int rc; ++ ++ long offset = d * 1000000; ++ struct timex tx = { 0 }; ++ tx.offset = offset; ++ tx.modes = ADJ_OFFSET_SINGLESHOT; ++ ++ do { ++ rc = adjtimex(&tx); ++ } while (rc == TIME_ERROR && (tx.offset /= 2) > threshold); ++ ++ if (rc == TIME_ERROR) { ++ log_warn("adjtimex returned TIME_ERROR"); ++ } else if (rc < 0) { ++ log_warn("adjtimex failed"); ++ } else if (tx.offset == offset) { ++ synced = 1; ++ } ++#else ++ struct timeval tv, olddelta; + d_to_tv(d, &tv); + if (adjtime(&tv, &olddelta) == -1) + log_warn("adjtime failed"); + else if (!firstadj && olddelta.tv_sec == 0 && olddelta.tv_usec == 0) + synced = 1; ++#endif + firstadj = 0; + update_time_sync_status(synced); + return (synced); +-- +2.20.1 +