From 7f75ffcaf080a76219d87712774a4eccd1967479b2c2a7674fab573c6b8627dd Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 14:31:56 +0000 Subject: [PATCH 01/30] - Update clknetsim to snapshot 0a11a35. OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=123 --- chrony.changes | 5 +++++ chrony.spec | 2 +- clknetsim-0a11a35.tar.gz | 3 +++ clknetsim-5d1dc05.tar.gz | 3 --- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 clknetsim-0a11a35.tar.gz delete mode 100644 clknetsim-5d1dc05.tar.gz diff --git a/chrony.changes b/chrony.changes index b015acc..c72ce79 100644 --- a/chrony.changes +++ b/chrony.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon May 27 14:27:18 UTC 2024 - Reinhard Max + +- Update clknetsim to snapshot 0a11a35. + ------------------------------------------------------------------- Mon Feb 26 10:33:53 UTC 2024 - Dominique Leuenberger diff --git a/chrony.spec b/chrony.spec index f2275e5..1f4e37a 100644 --- a/chrony.spec +++ b/chrony.spec @@ -33,7 +33,7 @@ %bcond_without testsuite %define _systemdutildir %(pkg-config --variable systemdutildir systemd) -%global clknetsim_ver 5d1dc05 +%global clknetsim_ver 0a11a35 #Compat macro for new _fillupdir macro introduced in Nov 2017 %if ! %{defined _fillupdir} %define _fillupdir %{_localstatedir}/adm/fillup-templates diff --git a/clknetsim-0a11a35.tar.gz b/clknetsim-0a11a35.tar.gz new file mode 100644 index 0000000..848705a --- /dev/null +++ b/clknetsim-0a11a35.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ef3d546932c7b848109474f782bd0c0a54b6dff9c199c7d524d535972b112b2 +size 51432 diff --git a/clknetsim-5d1dc05.tar.gz b/clknetsim-5d1dc05.tar.gz deleted file mode 100644 index 6abbd73..0000000 --- a/clknetsim-5d1dc05.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:26ffb69047e1839ec7bdd92bc55140a31edb2d8b6d97fbb6f19e1c9ccf601d99 -size 51356 From d71c555c6c979de8194a7a7ca02ae1615944bd26fb6b5cfe52a55b74abbd2d2d Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 15:23:00 +0000 Subject: [PATCH 02/30] PoC for running tests multiple times OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=124 --- chrony.spec | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chrony.spec b/chrony.spec index 1f4e37a..7e24c64 100644 --- a/chrony.spec +++ b/chrony.spec @@ -297,6 +297,11 @@ find %{buildroot} -type f | xargs sed -i ' export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" make %{?_smp_mflags} -C test/simulation/clknetsim +cd test/simulation +for i in $(seq 20); do + ./124-tai &> /dev/null && break +done +exit 1 make %{?_smp_mflags} quickcheck %endif %endif From a482345361d75018f06bc5a0e5f157beaf93624f05ed4d372e1d3a972811d6ed Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 15:25:44 +0000 Subject: [PATCH 03/30] PoC for running tests multiple times OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=125 --- chrony.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrony.spec b/chrony.spec index 7e24c64..dde5580 100644 --- a/chrony.spec +++ b/chrony.spec @@ -298,7 +298,7 @@ export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" make %{?_smp_mflags} -C test/simulation/clknetsim cd test/simulation -for i in $(seq 20); do +for i in $(seq 50); do ./124-tai &> /dev/null && break done exit 1 From 07694b8c6c14d0fb02b98ea24ac012234f18658521cc5a51f66defc853648778 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 15:36:02 +0000 Subject: [PATCH 04/30] - Add 6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch to fix test 124-tai on some architectures (bsc#1225362). OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=126 --- ...fe2f16fa49963e47e84f4a6dd9069735062e.patch | 166 ++++++++++++++++++ chrony.changes | 4 +- chrony.spec | 7 +- 3 files changed, 171 insertions(+), 6 deletions(-) create mode 100644 6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch diff --git a/6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch b/6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch new file mode 100644 index 0000000..b29ba8f --- /dev/null +++ b/6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch @@ -0,0 +1,166 @@ +From 6cf9fe2f16fa49963e47e84f4a6dd9069735062e Mon Sep 17 00:00:00 2001 +From: Miroslav Lichvar +Date: Wed, 7 Feb 2024 15:48:43 +0100 +Subject: [PATCH] test: improve 113-leapsecond and 124-tai tests + +Use leapseclist instead of leapsectz and test also negative leap +seconds. Add a test for leapsectz when the date command indicates +right/UTC is available on the system and mktime() works as expected. +Check TAI offset in the server's log. +--- + test/simulation/113-leapsecond | 88 +++++++++++++++++++++++----------- + test/simulation/124-tai | 12 ++++- + 2 files changed, 70 insertions(+), 30 deletions(-) + +diff --git a/test/simulation/113-leapsecond b/test/simulation/113-leapsecond +index 394440b7..63da734d 100755 +--- a/test/simulation/113-leapsecond ++++ b/test/simulation/113-leapsecond +@@ -8,54 +8,86 @@ check_config_h 'FEAT_REFCLOCK 1' || test_skip + + export CLKNETSIM_START_DATE=$(TZ=UTC date -d 'Dec 30 2008 0:00:00' +'%s') + +-leap=$[2 * 24 * 3600] + limit=$[4 * 24 * 3600] + client_start=$[2 * 3600] +-server_conf="refclock SHM 0 dpoll 10 poll 10 +-leapsectz right/UTC" + refclock_jitter=1e-9 +-refclock_offset="(* -1.0 (equal 0.1 (max (sum 1.0) $leap) $leap))" + +-for leapmode in system step slew; do +- client_conf="leapsecmode $leapmode" +- if [ $leapmode = slew ]; then +- max_sync_time=$[$leap + 12] +- else +- max_sync_time=$[$leap] +- fi ++for dir in "+1" "-1"; do ++ leap=$[2 * 24 * 3600 + 1 + $dir] ++ server_conf="refclock SHM 0 dpoll 10 poll 10 ++ leapseclist tmp/leap.list" ++ refclock_offset="(* $dir (equal 0.1 (max (sum 1.0) $leap) $leap))" ++ ++ cat > tmp/leap.list <<-EOF ++ #$ 3676924800 ++ #@ 3928521600 ++ 3345062400 33 # 1 Jan 2006 ++ 3439756800 $[33 - $dir] # 1 Jan 2009 $( ++ [ "$dir" = "+1" ] && echo -e "\n3471292800 33\n3502828800 34") ++ 3550089600 35 # 1 Jul 2012 ++ EOF ++ ++ for leapmode in system step slew; do ++ client_conf="leapsecmode $leapmode" ++ if [ $leapmode = slew ]; then ++ max_sync_time=$[2 * 24 * 3600 + 13] ++ else ++ max_sync_time=$[2 * 24 * 3600 + 1] ++ fi ++ min_sync_time=$[$max_sync_time - 2] ++ ++ run_test || test_fail ++ check_chronyd_exit || test_fail ++ check_source_selection || test_fail ++ check_packet_interval || test_fail ++ check_sync || test_fail ++ check_file_messages "System clock TAI offset set to" 1 1 log.1 || test_fail ++ check_file_messages "System clock TAI offset set to 33" 1 1 log.1 || test_fail ++ done ++ ++ client_server_options="trust" ++ client_conf="refclock SHM 0 dpoll 10 poll 10 delay 1e-3" ++ min_sync_time=$[$leap - 2] ++ max_sync_time=$[$leap] + + run_test || test_fail + check_chronyd_exit || test_fail + check_source_selection || test_fail + check_packet_interval || test_fail + check_sync || test_fail +-done + +-client_server_options="trust" +-client_conf="refclock SHM 0 dpoll 10 poll 10 delay 1e-3" ++ client_server_options="" ++ client_conf="leapsecmode system" ++ min_sync_time=230000 ++ max_sync_time=240000 + +-run_test || test_fail +-check_chronyd_exit || test_fail +-check_source_selection || test_fail +-check_packet_interval || test_fail +-check_sync || test_fail ++ for smoothmode in "" "leaponly"; do ++ server_conf="refclock SHM 0 dpoll 10 poll 10 ++ leapseclist tmp/leap.list ++ leapsecmode slew ++ smoothtime 400 0.001 $smoothmode" + +-client_server_options="" +-client_conf="leapsecmode system" +-min_sync_time=230000 +-max_sync_time=240000 ++ run_test || test_fail ++ check_chronyd_exit || test_fail ++ check_source_selection || test_fail ++ check_packet_interval || test_fail ++ check_sync || test_fail ++ done ++done + +-for smoothmode in "" "leaponly"; do ++if TZ=right/UTC date -d 'Dec 31 2008 23:59:60' 2> /dev/null | grep :60; then + server_conf="refclock SHM 0 dpoll 10 poll 10 +- leapsectz right/UTC +- leapsecmode slew +- smoothtime 400 0.001 $smoothmode" ++ leapsectz right/UTC" ++ refclock_offset="(* -1 (equal 0.1 (max (sum 1.0) $leap) $leap))" ++ client_conf="leapsecmode system" ++ min_sync_time=$[$leap - 2] ++ max_sync_time=$[$leap] + + run_test || test_fail + check_chronyd_exit || test_fail + check_source_selection || test_fail + check_packet_interval || test_fail + check_sync || test_fail +-done ++fi + + test_pass +diff --git a/test/simulation/124-tai b/test/simulation/124-tai +index 97064f7c..0192e10f 100755 +--- a/test/simulation/124-tai ++++ b/test/simulation/124-tai +@@ -18,10 +18,18 @@ servers=0 + refclock_offset="(+ -34 (equal 0.1 (max (sum 1.0) $leap) $leap))" + client_conf=" + refclock SHM 0 dpoll 0 poll 0 tai +-leapsectz right/UTC ++leapseclist tmp/leap.list + leapsecmode ignore + maxchange 1e-3 1 0" + ++cat > tmp/leap.list <<-EOF ++ #$ 3676924800 ++ #@ 3928521600 ++ 3345062400 33 # 1 Jan 2006 ++ 3439756800 34 # 1 Jan 2009 ++ 3550089600 35 # 1 Jul 2012 ++EOF ++ + run_test || test_fail + check_chronyd_exit || test_fail + check_source_selection || test_fail +@@ -33,7 +41,7 @@ time_offset=-1000 + refclock_offset="(+ -34)" + client_conf=" + refclock SHM 0 dpoll 0 poll 0 tai +-leapsectz right/UTC ++leapseclist tmp/leap.list + makestep 1 1 + maxchange 1e-3 1 0" + diff --git a/chrony.changes b/chrony.changes index c72ce79..af372d9 100644 --- a/chrony.changes +++ b/chrony.changes @@ -1,7 +1,9 @@ ------------------------------------------------------------------- -Mon May 27 14:27:18 UTC 2024 - Reinhard Max +Mon May 27 15:34:40 UTC 2024 - Reinhard Max - Update clknetsim to snapshot 0a11a35. +- Add 6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch to fix test + 124-tai on some architectures (bsc#1225362). ------------------------------------------------------------------- Mon Feb 26 10:33:53 UTC 2024 - Dominique Leuenberger diff --git a/chrony.spec b/chrony.spec index dde5580..4271394 100644 --- a/chrony.spec +++ b/chrony.spec @@ -70,6 +70,7 @@ Patch2: chrony-logrotate.patch Patch3: chrony-service-ordering.patch Patch7: chrony-htonl.patch Patch8: chrony.nm-dispatcher.dhcp.patch +Patch9: 6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch BuildRequires: NetworkManager-devel BuildRequires: bison BuildRequires: findutils @@ -181,6 +182,7 @@ e.g. because the servers will be set via DHCP. %patch -P 3 %patch -P 7 %patch -P 8 +%patch -P 9 # Remove pool statements from the default /etc/chrony.conf. They will # be provided by branding packages in /etc/chrony.d/pool.conf . @@ -297,11 +299,6 @@ find %{buildroot} -type f | xargs sed -i ' export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" make %{?_smp_mflags} -C test/simulation/clknetsim -cd test/simulation -for i in $(seq 50); do - ./124-tai &> /dev/null && break -done -exit 1 make %{?_smp_mflags} quickcheck %endif %endif From 3ad4c0e418dd012d339cbf746b1ffddbc676b05f71b54574f3fae7c82bdfbc6a Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 15:38:05 +0000 Subject: [PATCH 05/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=127 --- chrony.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrony.spec b/chrony.spec index 4271394..afdaf20 100644 --- a/chrony.spec +++ b/chrony.spec @@ -182,7 +182,7 @@ e.g. because the servers will be set via DHCP. %patch -P 3 %patch -P 7 %patch -P 8 -%patch -P 9 +%patch -P 9 -p1 # Remove pool statements from the default /etc/chrony.conf. They will # be provided by branding packages in /etc/chrony.d/pool.conf . From 0b8ee621e599d249fe3da88136edbca26d03fd5fe8e11885a130b820613007ed Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 16:07:09 +0000 Subject: [PATCH 06/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=128 --- ...6f8f5630071e2a532f58f9513757d94ac7d5.patch | 419 ++++++++++++++++++ ...9a86077c629eb6f998c4f824bb9b9c4e60ce.patch | 88 ++++ ...3b9f1c076b3b26d0ad031eb95a51e6842abd.patch | 317 +++++++++++++ ...77d1bd634298b1b54059e212d6f7d402fa26.patch | 150 +++++++ ...0279b0fdd64c1d67d479de5e60ee068b9499.patch | 59 +++ chrony.spec | 13 +- 6 files changed, 1045 insertions(+), 1 deletion(-) create mode 100644 017d6f8f5630071e2a532f58f9513757d94ac7d5.patch create mode 100644 02ae9a86077c629eb6f998c4f824bb9b9c4e60ce.patch create mode 100644 53823b9f1c076b3b26d0ad031eb95a51e6842abd.patch create mode 100644 637b77d1bd634298b1b54059e212d6f7d402fa26.patch create mode 100644 83f90279b0fdd64c1d67d479de5e60ee068b9499.patch diff --git a/017d6f8f5630071e2a532f58f9513757d94ac7d5.patch b/017d6f8f5630071e2a532f58f9513757d94ac7d5.patch new file mode 100644 index 0000000..0d70531 --- /dev/null +++ b/017d6f8f5630071e2a532f58f9513757d94ac7d5.patch @@ -0,0 +1,419 @@ +From 017d6f8f5630071e2a532f58f9513757d94ac7d5 Mon Sep 17 00:00:00 2001 +From: Patrick Oppenlander +Date: Thu, 8 Feb 2024 14:36:25 +1100 +Subject: [PATCH] reference: move leap second source into leapdb + +Separate out source of leap second data into a new module in preparation +for supporting more sources such as leap-seconds.list. +--- + Makefile.in | 2 +- + leapdb.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + leapdb.h | 37 +++++++++++++ + main.c | 3 ++ + reference.c | 99 +++-------------------------------- + 5 files changed, 194 insertions(+), 94 deletions(-) + create mode 100644 leapdb.c + create mode 100644 leapdb.h + +diff --git a/Makefile.in b/Makefile.in +index 101e0c69..318109bb 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -37,7 +37,7 @@ GETDATE_CFLAGS = @GETDATE_CFLAGS@ + + EXTRA_OBJS = @EXTRA_OBJS@ + +-OBJS = array.o cmdparse.o conf.o local.o logging.o main.o memory.o quantiles.o \ ++OBJS = array.o cmdparse.o conf.o leapdb.o local.o logging.o main.o memory.o quantiles.o \ + reference.o regress.o rtc.o samplefilt.o sched.o socket.o sources.o sourcestats.o \ + stubs.o smooth.o sys.o sys_null.o tempcomp.o util.o $(EXTRA_OBJS) + +diff --git a/leapdb.c b/leapdb.c +new file mode 100644 +index 00000000..676a0d5d +--- /dev/null ++++ b/leapdb.c +@@ -0,0 +1,147 @@ ++/* ++ chronyd/chronyc - Programs for keeping computer clocks accurate. ++ ++ ********************************************************************** ++ * Copyright (C) Miroslav Lichvar 2009-2018, 2020, 2022 ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of version 2 of the GNU General Public License as ++ * published by the Free Software Foundation. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ * ++ ********************************************************************** ++ ++ ======================================================================= ++ ++ This module provides leap second information. */ ++ ++#include "config.h" ++ ++#include "sysincl.h" ++ ++#include "conf.h" ++#include "leapdb.h" ++#include "logging.h" ++ ++/* ================================================== */ ++ ++/* Name of a system timezone containing leap seconds occuring at midnight */ ++static char *leap_tzname; ++ ++/* ================================================== */ ++ ++static NTP_Leap ++get_tz_leap(time_t when, int *tai_offset) ++{ ++ static time_t last_tz_leap_check; ++ static NTP_Leap tz_leap; ++ static int tz_tai_offset; ++ ++ struct tm stm, *tm; ++ time_t t; ++ char *tz_env, tz_orig[128]; ++ ++ *tai_offset = tz_tai_offset; ++ ++ /* Do this check at most twice a day */ ++ when = when / (12 * 3600) * (12 * 3600); ++ if (last_tz_leap_check == when) ++ return tz_leap; ++ ++ last_tz_leap_check = when; ++ tz_leap = LEAP_Normal; ++ tz_tai_offset = 0; ++ ++ tm = gmtime(&when); ++ if (!tm) ++ return tz_leap; ++ ++ stm = *tm; ++ ++ /* Temporarily switch to the timezone containing leap seconds */ ++ tz_env = getenv("TZ"); ++ if (tz_env) { ++ if (strlen(tz_env) >= sizeof (tz_orig)) ++ return tz_leap; ++ strcpy(tz_orig, tz_env); ++ } ++ setenv("TZ", leap_tzname, 1); ++ tzset(); ++ ++ /* Get the TAI-UTC offset, which started at the epoch at 10 seconds */ ++ t = mktime(&stm); ++ if (t != -1) ++ tz_tai_offset = t - when + 10; ++ ++ /* Set the time to 23:59:60 and see how it overflows in mktime() */ ++ stm.tm_sec = 60; ++ stm.tm_min = 59; ++ stm.tm_hour = 23; ++ ++ t = mktime(&stm); ++ ++ if (tz_env) ++ setenv("TZ", tz_orig, 1); ++ else ++ unsetenv("TZ"); ++ tzset(); ++ ++ if (t == -1) ++ return tz_leap; ++ ++ if (stm.tm_sec == 60) ++ tz_leap = LEAP_InsertSecond; ++ else if (stm.tm_sec == 1) ++ tz_leap = LEAP_DeleteSecond; ++ ++ *tai_offset = tz_tai_offset; ++ ++ return tz_leap; ++} ++ ++/* ================================================== */ ++ ++void ++LDB_Initialise(void) ++{ ++ int tai_offset; ++ ++ leap_tzname = CNF_GetLeapSecTimezone(); ++ if (leap_tzname) { ++ /* Check that the timezone has good data for Jun 30 2012 and Dec 31 2012 */ ++ if (get_tz_leap(1341014400, &tai_offset) == LEAP_InsertSecond && tai_offset == 34 && ++ get_tz_leap(1356912000, &tai_offset) == LEAP_Normal && tai_offset == 35) { ++ LOG(LOGS_INFO, "Using %s timezone to obtain leap second data", leap_tzname); ++ } else { ++ LOG(LOGS_WARN, "Timezone %s failed leap second check, ignoring", leap_tzname); ++ leap_tzname = NULL; ++ } ++ } ++} ++ ++/* ================================================== */ ++ ++NTP_Leap ++LDB_GetLeap(time_t when, int *tai_offset) ++{ ++ *tai_offset = 0; ++ if (leap_tzname) ++ return get_tz_leap(when, tai_offset); ++ return LEAP_Normal; ++} ++ ++/* ================================================== */ ++ ++void ++LDB_Finalise(void) ++{ ++ /* Nothing to do */ ++} +diff --git a/leapdb.h b/leapdb.h +new file mode 100644 +index 00000000..eab24141 +--- /dev/null ++++ b/leapdb.h +@@ -0,0 +1,37 @@ ++/* ++ chronyd/chronyc - Programs for keeping computer clocks accurate. ++ ++ ********************************************************************** ++ * Copyright (C) Patrick Oppenlander 2023 ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of version 2 of the GNU General Public License as ++ * published by the Free Software Foundation. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ * ++ ********************************************************************** ++ ++ ======================================================================= ++ ++ This module provides leap second information. ++ ++ */ ++ ++#ifndef GOT_LEAPDB_H ++#define GOT_LEAPDB_H ++ ++#include "ntp.h" ++ ++extern void LDB_Initialise(void); ++extern NTP_Leap LDB_GetLeap(time_t when, int *tai_offset); ++extern void LDB_Finalise(void); ++ ++#endif /* GOT_LEAPDB_H */ +diff --git a/main.c b/main.c +index 21d0fe7f..cb240640 100644 +--- a/main.c ++++ b/main.c +@@ -32,6 +32,7 @@ + + #include "main.h" + #include "sched.h" ++#include "leapdb.h" + #include "local.h" + #include "sys.h" + #include "ntp_io.h" +@@ -134,6 +135,7 @@ MAI_CleanupAndExit(void) + RCL_Finalise(); + SRC_Finalise(); + REF_Finalise(); ++ LDB_Finalise(); + RTC_Finalise(); + SYS_Finalise(); + +@@ -655,6 +657,7 @@ int main + if (!geteuid()) + LOG(LOGS_WARN, "Running with root privileges"); + ++ LDB_Initialise(); + REF_Initialise(); + SST_Initialise(); + NSR_Initialise(); +diff --git a/reference.c b/reference.c +index 97dfbe98..1ac6cb93 100644 +--- a/reference.c ++++ b/reference.c +@@ -33,6 +33,7 @@ + #include "reference.h" + #include "util.h" + #include "conf.h" ++#include "leapdb.h" + #include "logging.h" + #include "local.h" + #include "sched.h" +@@ -122,9 +123,6 @@ static int leap_in_progress; + /* Timer for the leap second handler */ + static SCH_TimeoutID leap_timeout_id; + +-/* Name of a system timezone containing leap seconds occuring at midnight */ +-static char *leap_tzname; +- + /* ================================================== */ + + static LOG_FileID logfileid; +@@ -155,7 +153,6 @@ static int ref_adjustments; + + /* ================================================== */ + +-static NTP_Leap get_tz_leap(time_t when, int *tai_offset); + static void update_leap_status(NTP_Leap leap, time_t now, int reset); + + /* ================================================== */ +@@ -195,7 +192,6 @@ REF_Initialise(void) + FILE *in; + double file_freq_ppm, file_skew_ppm; + double our_frequency_ppm; +- int tai_offset; + + mode = REF_ModeNormal; + are_we_synchronised = 0; +@@ -260,18 +256,6 @@ REF_Initialise(void) + if (leap_mode == REF_LeapModeSystem && !LCL_CanSystemLeap()) + leap_mode = REF_LeapModeStep; + +- leap_tzname = CNF_GetLeapSecTimezone(); +- if (leap_tzname) { +- /* Check that the timezone has good data for Jun 30 2012 and Dec 31 2012 */ +- if (get_tz_leap(1341014400, &tai_offset) == LEAP_InsertSecond && tai_offset == 34 && +- get_tz_leap(1356912000, &tai_offset) == LEAP_Normal && tai_offset == 35) { +- LOG(LOGS_INFO, "Using %s timezone to obtain leap second data", leap_tzname); +- } else { +- LOG(LOGS_WARN, "Timezone %s failed leap second check, ignoring", leap_tzname); +- leap_tzname = NULL; +- } +- } +- + CNF_GetMakeStep(&make_step_limit, &make_step_threshold); + CNF_GetMaxChange(&max_offset_delay, &max_offset_ignore, &max_offset); + CNF_GetMailOnChange(&do_mail_change, &mail_change_threshold, &mail_change_user); +@@ -593,77 +577,6 @@ is_leap_second_day(time_t when) + + /* ================================================== */ + +-static NTP_Leap +-get_tz_leap(time_t when, int *tai_offset) +-{ +- static time_t last_tz_leap_check; +- static NTP_Leap tz_leap; +- static int tz_tai_offset; +- +- struct tm stm, *tm; +- time_t t; +- char *tz_env, tz_orig[128]; +- +- *tai_offset = tz_tai_offset; +- +- /* Do this check at most twice a day */ +- when = when / (12 * 3600) * (12 * 3600); +- if (last_tz_leap_check == when) +- return tz_leap; +- +- last_tz_leap_check = when; +- tz_leap = LEAP_Normal; +- tz_tai_offset = 0; +- +- tm = gmtime(&when); +- if (!tm) +- return tz_leap; +- +- stm = *tm; +- +- /* Temporarily switch to the timezone containing leap seconds */ +- tz_env = getenv("TZ"); +- if (tz_env) { +- if (strlen(tz_env) >= sizeof (tz_orig)) +- return tz_leap; +- strcpy(tz_orig, tz_env); +- } +- setenv("TZ", leap_tzname, 1); +- tzset(); +- +- /* Get the TAI-UTC offset, which started at the epoch at 10 seconds */ +- t = mktime(&stm); +- if (t != -1) +- tz_tai_offset = t - when + 10; +- +- /* Set the time to 23:59:60 and see how it overflows in mktime() */ +- stm.tm_sec = 60; +- stm.tm_min = 59; +- stm.tm_hour = 23; +- +- t = mktime(&stm); +- +- if (tz_env) +- setenv("TZ", tz_orig, 1); +- else +- unsetenv("TZ"); +- tzset(); +- +- if (t == -1) +- return tz_leap; +- +- if (stm.tm_sec == 60) +- tz_leap = LEAP_InsertSecond; +- else if (stm.tm_sec == 1) +- tz_leap = LEAP_DeleteSecond; +- +- *tai_offset = tz_tai_offset; +- +- return tz_leap; +-} +- +-/* ================================================== */ +- + static void + leap_end_timeout(void *arg) + { +@@ -751,16 +664,16 @@ set_leap_timeout(time_t now) + static void + update_leap_status(NTP_Leap leap, time_t now, int reset) + { +- NTP_Leap tz_leap; ++ NTP_Leap ldb_leap; + int leap_sec, tai_offset; + + leap_sec = 0; + tai_offset = 0; + +- if (leap_tzname && now) { +- tz_leap = get_tz_leap(now, &tai_offset); ++ if (now) { ++ ldb_leap = LDB_GetLeap(now, &tai_offset); + if (leap == LEAP_Normal) +- leap = tz_leap; ++ leap = ldb_leap; + } + + if (leap == LEAP_InsertSecond || leap == LEAP_DeleteSecond) { +@@ -1398,7 +1311,7 @@ REF_GetTaiOffset(struct timespec *ts) + { + int tai_offset; + +- get_tz_leap(ts->tv_sec, &tai_offset); ++ LDB_GetLeap(ts->tv_sec, &tai_offset); + + return tai_offset; + } diff --git a/02ae9a86077c629eb6f998c4f824bb9b9c4e60ce.patch b/02ae9a86077c629eb6f998c4f824bb9b9c4e60ce.patch new file mode 100644 index 0000000..52068d8 --- /dev/null +++ b/02ae9a86077c629eb6f998c4f824bb9b9c4e60ce.patch @@ -0,0 +1,88 @@ +From 02ae9a86077c629eb6f998c4f824bb9b9c4e60ce Mon Sep 17 00:00:00 2001 +From: Patrick Oppenlander +Date: Thu, 8 Feb 2024 14:36:26 +1100 +Subject: [PATCH] leapdb: make twice per day check logic common + +We want to do the twice per day check regardless of the data source. +Move the check up one level from get_tz_leap() into LDB_GetLeap(). +--- + leapdb.c | 41 ++++++++++++++++++++--------------------- + 1 file changed, 20 insertions(+), 21 deletions(-) + +diff --git a/leapdb.c b/leapdb.c +index 676a0d5..32f753a 100644 +--- a/leapdb.c ++++ b/leapdb.c +@@ -41,24 +41,10 @@ static char *leap_tzname; + static NTP_Leap + get_tz_leap(time_t when, int *tai_offset) + { +- static time_t last_tz_leap_check; +- static NTP_Leap tz_leap; +- static int tz_tai_offset; +- + struct tm stm, *tm; + time_t t; + char *tz_env, tz_orig[128]; +- +- *tai_offset = tz_tai_offset; +- +- /* Do this check at most twice a day */ +- when = when / (12 * 3600) * (12 * 3600); +- if (last_tz_leap_check == when) +- return tz_leap; +- +- last_tz_leap_check = when; +- tz_leap = LEAP_Normal; +- tz_tai_offset = 0; ++ NTP_Leap tz_leap = LEAP_Normal; + + tm = gmtime(&when); + if (!tm) +@@ -79,7 +65,7 @@ get_tz_leap(time_t when, int *tai_offset) + /* Get the TAI-UTC offset, which started at the epoch at 10 seconds */ + t = mktime(&stm); + if (t != -1) +- tz_tai_offset = t - when + 10; ++ *tai_offset = t - when + 10; + + /* Set the time to 23:59:60 and see how it overflows in mktime() */ + stm.tm_sec = 60; +@@ -102,8 +88,6 @@ get_tz_leap(time_t when, int *tai_offset) + else if (stm.tm_sec == 1) + tz_leap = LEAP_DeleteSecond; + +- *tai_offset = tz_tai_offset; +- + return tz_leap; + } + +@@ -132,10 +116,25 @@ LDB_Initialise(void) + NTP_Leap + LDB_GetLeap(time_t when, int *tai_offset) + { +- *tai_offset = 0; ++ static time_t last_ldb_leap_check; ++ static NTP_Leap ldb_leap; ++ static int ldb_tai_offset; ++ ++ /* Do this check at most twice a day */ ++ when = when / (12 * 3600) * (12 * 3600); ++ if (last_ldb_leap_check == when) ++ goto out; ++ ++ last_ldb_leap_check = when; ++ ldb_leap = LEAP_Normal; ++ ldb_tai_offset = 0; ++ + if (leap_tzname) +- return get_tz_leap(when, tai_offset); +- return LEAP_Normal; ++ ldb_leap = get_tz_leap(when, &ldb_tai_offset); ++ ++out: ++ *tai_offset = ldb_tai_offset; ++ return ldb_leap; + } + + /* ================================================== */ diff --git a/53823b9f1c076b3b26d0ad031eb95a51e6842abd.patch b/53823b9f1c076b3b26d0ad031eb95a51e6842abd.patch new file mode 100644 index 0000000..475a14b --- /dev/null +++ b/53823b9f1c076b3b26d0ad031eb95a51e6842abd.patch @@ -0,0 +1,317 @@ +From 53823b9f1c076b3b26d0ad031eb95a51e6842abd Mon Sep 17 00:00:00 2001 +From: Patrick Oppenlander +Date: Thu, 8 Feb 2024 14:36:28 +1100 +Subject: [PATCH] leapdb: support leap-seconds.list as second source + +The existing implementation of getting leap second information from a +timezone in get_tz_leap() relies on non-portable C library behaviour. + +Specifically, mktime is not required to return '60' in the tm_sec field +when a leap second is inserted leading to "Timezone right/UTC failed +leap second check, ignoring" errors on musl based systems. + +This patch adds support for getting leap second information from the +leap-seconds.list file included with tzdata and adds a new configuration +directive leapseclist to switch on the feature. +--- + conf.c | 14 +++++ + conf.h | 1 + + doc/chrony.conf.adoc | 20 +++++-- + leapdb.c | 126 +++++++++++++++++++++++++++++++++++++++++-- + refclock.c | 4 +- + 5 files changed, 155 insertions(+), 10 deletions(-) + +diff --git a/conf.c b/conf.c +index 73fe774a..6eae11c9 100644 +--- a/conf.c ++++ b/conf.c +@@ -249,6 +249,9 @@ static REF_LeapMode leapsec_mode = REF_LeapModeSystem; + /* Name of a system timezone containing leap seconds occuring at midnight */ + static char *leapsec_tz = NULL; + ++/* File name of leap seconds list, usually /usr/share/zoneinfo/leap-seconds.list */ ++static char *leapsec_list = NULL; ++ + /* Name of the user to which will be dropped root privileges. */ + static char *user; + +@@ -471,6 +474,7 @@ CNF_Finalise(void) + Free(hwclock_file); + Free(keys_file); + Free(leapsec_tz); ++ Free(leapsec_list); + Free(logdir); + Free(bind_ntp_iface); + Free(bind_acq_iface); +@@ -620,6 +624,8 @@ CNF_ParseLine(const char *filename, int number, char *line) + parse_leapsecmode(p); + } else if (!strcasecmp(command, "leapsectz")) { + parse_string(p, &leapsec_tz); ++ } else if (!strcasecmp(command, "leapseclist")) { ++ parse_string(p, &leapsec_list); + } else if (!strcasecmp(command, "local")) { + parse_local(p); + } else if (!strcasecmp(command, "lock_all")) { +@@ -2389,6 +2395,14 @@ CNF_GetLeapSecTimezone(void) + + /* ================================================== */ + ++char * ++CNF_GetLeapSecList(void) ++{ ++ return leapsec_list; ++} ++ ++/* ================================================== */ ++ + int + CNF_GetSchedPriority(void) + { +diff --git a/conf.h b/conf.h +index 58ebdeb0..4c0a7879 100644 +--- a/conf.h ++++ b/conf.h +@@ -91,6 +91,7 @@ extern char *CNF_GetNtpSigndSocket(void); + extern char *CNF_GetPidFile(void); + extern REF_LeapMode CNF_GetLeapSecMode(void); + extern char *CNF_GetLeapSecTimezone(void); ++extern char *CNF_GetLeapSecList(void); + + /* Value returned in ppm, as read from file */ + extern double CNF_GetMaxUpdateSkew(void); +diff --git a/doc/chrony.conf.adoc b/doc/chrony.conf.adoc +index eeaa5010..bd296bc6 100644 +--- a/doc/chrony.conf.adoc ++++ b/doc/chrony.conf.adoc +@@ -680,9 +680,10 @@ trusted and required source. + *tai*::: + This option indicates that the reference clock keeps time in TAI instead of UTC + and that *chronyd* should correct its offset by the current TAI-UTC offset. The +-<> directive must be used with this option and the +-database must be kept up to date in order for this correction to work as +-expected. This option does not make sense with PPS refclocks. ++<> or <> directive must be ++used with this option and the database must be kept up to date in order for ++this correction to work as expected. This option does not make sense with PPS ++refclocks. + *local*::: + This option specifies that the reference clock is an unsynchronised clock which + is more stable than the system clock (e.g. TCXO, OCXO, or atomic clock) and +@@ -1269,6 +1270,19 @@ $ TZ=right/UTC date -d 'Dec 31 2008 23:59:60' + Wed Dec 31 23:59:60 UTC 2008 + ---- + ++[[leapseclist]]*leapseclist* _file_:: ++This directive specifies the path to a file containing a list of leap seconds ++and TAI-UTC offsets in NIST/IERS format. It is recommended to use ++the file _leap-seconds.list_ usually included with the system timezone ++database. The behaviour of this directive is otherwise equivalent to ++<>. +++ ++An example of this directive is: +++ ++---- ++leapseclist /usr/share/zoneinfo/leap-seconds.list ++---- ++ + [[makestep]]*makestep* _threshold_ _limit_:: + Normally *chronyd* will cause the system to gradually correct any time offset, + by slowing down or speeding up the clock as required. In certain situations, +diff --git a/leapdb.c b/leapdb.c +index aa49b3c4..e748e001 100644 +--- a/leapdb.c ++++ b/leapdb.c +@@ -3,6 +3,7 @@ + + ********************************************************************** + * Copyright (C) Miroslav Lichvar 2009-2018, 2020, 2022 ++ * Copyright (C) Patrick Oppenlander 2023, 2024 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as +@@ -30,11 +31,20 @@ + #include "conf.h" + #include "leapdb.h" + #include "logging.h" ++#include "util.h" + + /* ================================================== */ + +-/* Name of a system timezone containing leap seconds occuring at midnight */ +-static char *leap_tzname; ++/* Source of leap second data */ ++enum { ++ SRC_NONE, ++ SRC_TIMEZONE, ++ SRC_LIST, ++} leap_src; ++ ++/* Offset between leap-seconds.list timestamp epoch and Unix epoch. ++ leap-seconds.list epoch is 1 Jan 1900, 00:00:00 */ ++#define LEAP_SEC_LIST_OFFSET 2208988800 + + /* ================================================== */ + +@@ -59,7 +69,7 @@ get_tz_leap(time_t when, int *tai_offset) + return tz_leap; + strcpy(tz_orig, tz_env); + } +- setenv("TZ", leap_tzname, 1); ++ setenv("TZ", CNF_GetLeapSecTimezone(), 1); + tzset(); + + /* Get the TAI-UTC offset, which started at the epoch at 10 seconds */ +@@ -93,6 +103,91 @@ get_tz_leap(time_t when, int *tai_offset) + + /* ================================================== */ + ++static NTP_Leap ++get_list_leap(time_t when, int *tai_offset) ++{ ++ FILE *f; ++ char line[1024]; ++ NTP_Leap ret_leap = LEAP_Normal; ++ int ret_tai_offset = 0, prev_lsl_tai_offset = 10; ++ int64_t lsl_updated = 0, lsl_expiry = 0; ++ const char *leap_sec_list = CNF_GetLeapSecList(); ++ ++ if (!(f = UTI_OpenFile(NULL, leap_sec_list, NULL, 'r', 0))) { ++ LOG(LOGS_ERR, "Failed to open leap seconds list %s", leap_sec_list); ++ goto out; ++ } ++ ++ /* Leap second happens at midnight */ ++ when = (when / (24 * 3600) + 1) * (24 * 3600); ++ ++ /* leap-seconds.list timestamps are relative to 1 Jan 1900, 00:00:00 */ ++ when += LEAP_SEC_LIST_OFFSET; ++ ++ while (fgets(line, sizeof line, f) > 0) { ++ int64_t lsl_when; ++ int lsl_tai_offset; ++ char *p; ++ ++ /* Ignore blank lines */ ++ for (p = line; *p && isspace(*p); ++p) ++ ; ++ if (!*p) ++ continue; ++ ++ if (*line == '#') { ++ /* Update time line starts with #$ */ ++ if (line[1] == '$' && sscanf(line + 2, "%"SCNd64, &lsl_updated) != 1) ++ goto error; ++ /* Expiration time line starts with #@ */ ++ if (line[1] == '@' && sscanf(line + 2, "%"SCNd64, &lsl_expiry) != 1) ++ goto error; ++ /* Comment or a special comment we don't care about */ ++ continue; ++ } ++ ++ /* Leap entry */ ++ if (sscanf(line, "%"SCNd64" %d", &lsl_when, &lsl_tai_offset) != 2) ++ goto error; ++ ++ if (when == lsl_when) { ++ if (lsl_tai_offset > prev_lsl_tai_offset) ++ ret_leap = LEAP_InsertSecond; ++ else if (lsl_tai_offset < prev_lsl_tai_offset) ++ ret_leap = LEAP_DeleteSecond; ++ /* When is rounded to the end of the day, so offset hasn't changed yet! */ ++ ret_tai_offset = prev_lsl_tai_offset; ++ } else if (when > lsl_when) { ++ ret_tai_offset = lsl_tai_offset; ++ } ++ ++ prev_lsl_tai_offset = lsl_tai_offset; ++ } ++ ++ /* Make sure the file looks sensible */ ++ if (!feof(f) || !lsl_updated || !lsl_expiry) ++ goto error; ++ ++ if (when >= lsl_expiry) ++ LOG(LOGS_WARN, "Leap second list %s needs update", leap_sec_list); ++ ++ goto out; ++ ++error: ++ if (f) ++ fclose(f); ++ LOG(LOGS_ERR, "Failed to parse leap seconds list %s", leap_sec_list); ++ return LEAP_Normal; ++ ++out: ++ if (f) ++ fclose(f); ++ *tai_offset = ret_tai_offset; ++ return ret_leap; ++} ++ ++/* ================================================== */ ++ + static int + check_leap_source(NTP_Leap (*src)(time_t when, int *tai_offset)) + { +@@ -111,14 +206,27 @@ check_leap_source(NTP_Leap (*src)(time_t when, int *tai_offset)) + void + LDB_Initialise(void) + { ++ const char *leap_tzname, *leap_sec_list; ++ + leap_tzname = CNF_GetLeapSecTimezone(); + if (leap_tzname && !check_leap_source(get_tz_leap)) { + LOG(LOGS_WARN, "Timezone %s failed leap second check, ignoring", leap_tzname); + leap_tzname = NULL; + } + +- if (leap_tzname) ++ leap_sec_list = CNF_GetLeapSecList(); ++ if (leap_sec_list && !check_leap_source(get_list_leap)) { ++ LOG(LOGS_WARN, "Leap second list %s failed check, ignoring", leap_sec_list); ++ leap_sec_list = NULL; ++ } ++ ++ if (leap_sec_list) { ++ LOG(LOGS_INFO, "Using leap second list %s", leap_sec_list); ++ leap_src = SRC_LIST; ++ } else if (leap_tzname) { + LOG(LOGS_INFO, "Using %s timezone to obtain leap second data", leap_tzname); ++ leap_src = SRC_TIMEZONE; ++ } + } + + /* ================================================== */ +@@ -139,8 +247,16 @@ LDB_GetLeap(time_t when, int *tai_offset) + ldb_leap = LEAP_Normal; + ldb_tai_offset = 0; + +- if (leap_tzname) ++ switch (leap_src) { ++ case SRC_NONE: ++ break; ++ case SRC_TIMEZONE: + ldb_leap = get_tz_leap(when, &ldb_tai_offset); ++ break; ++ case SRC_LIST: ++ ldb_leap = get_list_leap(when, &ldb_tai_offset); ++ break; ++ } + + out: + *tai_offset = ldb_tai_offset; +diff --git a/refclock.c b/refclock.c +index 84f7439c..44ba6d5c 100644 +--- a/refclock.c ++++ b/refclock.c +@@ -166,8 +166,8 @@ RCL_AddRefclock(RefclockParameters *params) + if (!inst->driver->init && !inst->driver->poll) + LOG_FATAL("refclock driver %s is not compiled in", params->driver_name); + +- if (params->tai && !CNF_GetLeapSecTimezone()) +- LOG_FATAL("refclock tai option requires leapsectz"); ++ if (params->tai && !CNF_GetLeapSecList() && !CNF_GetLeapSecTimezone()) ++ LOG_FATAL("refclock tai option requires leapseclist or leapsectz"); + + inst->data = NULL; + inst->driver_parameter = Strdup(params->driver_parameter); diff --git a/637b77d1bd634298b1b54059e212d6f7d402fa26.patch b/637b77d1bd634298b1b54059e212d6f7d402fa26.patch new file mode 100644 index 0000000..a2a07ab --- /dev/null +++ b/637b77d1bd634298b1b54059e212d6f7d402fa26.patch @@ -0,0 +1,150 @@ +From 637b77d1bd634298b1b54059e212d6f7d402fa26 Mon Sep 17 00:00:00 2001 +From: Patrick Oppenlander +Date: Thu, 8 Feb 2024 14:36:29 +1100 +Subject: [PATCH] test: add leapdb unit test + +--- + test/unit/leapdb.c | 104 ++++++++++++++++++++++++++++++++++++++++++ + test/unit/leapdb.list | 22 +++++++++ + 2 files changed, 126 insertions(+) + create mode 100644 test/unit/leapdb.c + create mode 100644 test/unit/leapdb.list + +diff --git a/test/unit/leapdb.c b/test/unit/leapdb.c +new file mode 100644 +index 0000000..509fc39 +--- /dev/null ++++ b/test/unit/leapdb.c +@@ -0,0 +1,104 @@ ++/* ++ ********************************************************************** ++ * Copyright (C) Patrick Oppenlander 2023 ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of version 2 of the GNU General Public License as ++ * published by the Free Software Foundation. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ * ++ ********************************************************************** ++ */ ++ ++#include ++#include "test.h" ++ ++struct test_vector { ++ time_t when; ++ int tai_offset; ++ NTP_Leap leap; ++ int fake; ++} tests[] = { ++ /* leapdb.list is a cut down version of leap-seconds.list */ ++ {3439756800, 34, LEAP_InsertSecond, 0}, /* 1 Jan 2009 */ ++ {3550089600, 35, LEAP_InsertSecond, 0}, /* 1 Jul 2012 */ ++ {3644697600, 36, LEAP_InsertSecond, 0}, /* 1 Jul 2015 */ ++ {3692217600, 37, LEAP_InsertSecond, 0}, /* 1 Jan 2017 */ ++ {3786825600, 36, LEAP_DeleteSecond, 1}, /* 1 Jan 2020 fake in leapdb.list */ ++}; ++ ++static void ++test_leap_source(NTP_Leap (*fn)(time_t when, int *tai_offset), ++ int skip_fakes) ++{ ++ int prev_tai_offset = 34; ++ for (int i = 0; i < sizeof tests / sizeof tests[0]; ++i) { ++ struct test_vector *t = tests + i; ++ ++ NTP_Leap leap; ++ int tai_offset = -1; ++ ++ /* Our unit test leapdb.list contains a fake entry removing a leap second. ++ * Skip this when testing with the right/UTC timezone using mktime(). */ ++ if (skip_fakes && t->fake) ++ continue; ++ ++ /* One second before leap second */ ++ leap = fn(t->when - LEAP_SEC_LIST_OFFSET - 1, &tai_offset); ++ TEST_CHECK(leap == t->leap); ++ TEST_CHECK(tai_offset = prev_tai_offset); ++ ++ /* Exactly on leap second */ ++ leap = fn(t->when - LEAP_SEC_LIST_OFFSET, &tai_offset); ++ TEST_CHECK(leap == LEAP_Normal); ++ TEST_CHECK(tai_offset == t->tai_offset); ++ ++ /* One second after leap second */ ++ leap = fn(t->when - LEAP_SEC_LIST_OFFSET + 1, &tai_offset); ++ TEST_CHECK(leap == LEAP_Normal); ++ TEST_CHECK(tai_offset == t->tai_offset); ++ ++ prev_tai_offset = t->tai_offset; ++ } ++} ++ ++void ++test_unit(void) ++{ ++ char conf[][100] = { ++ "leapsectz right/UTC", ++ "leapseclist leapdb.list" ++ }; ++ ++ CNF_Initialise(0, 0); ++ for (int i = 0; i < sizeof conf / sizeof conf[0]; i++) ++ CNF_ParseLine(NULL, i + 1, conf[i]); ++ LDB_Initialise(); ++ ++ if (check_leap_source(get_tz_leap)) { ++ DEBUG_LOG("testing get_tz_leap"); ++ test_leap_source(get_tz_leap, 1); ++ } else { ++ DEBUG_LOG("Skipping get_tz_leap test. Either the right/UTC timezone is " ++ "missing, or mktime() doesn't support leap seconds."); ++ } ++ ++ DEBUG_LOG("testing get_list_leap"); ++ TEST_CHECK(check_leap_source(get_list_leap)); ++ test_leap_source(get_list_leap, 0); ++ ++ /* This exercises the twice-per-day logic */ ++ DEBUG_LOG("testing LDB_GetLeap"); ++ test_leap_source(LDB_GetLeap, 1); ++ ++ LDB_Finalise(); ++ CNF_Finalise(); ++} +diff --git a/test/unit/leapdb.list b/test/unit/leapdb.list +new file mode 100644 +index 0000000..5dc2188 +--- /dev/null ++++ b/test/unit/leapdb.list +@@ -0,0 +1,22 @@ ++# ++# Cut down version of leap-seconds.list for unit test. ++# ++# Blank lines need to be ignored, so include a few for testing. ++# Whitespace errors on non-blank lines below are copied from the original file. ++# ++ ++# Leap second data update time ++#$ 3676924800 ++# ++# File update time ++#@ 3928521600 ++ ++3439756800 34 # 1 Jan 2009 ++3550089600 35 # 1 Jul 2012 ++3644697600 36 # 1 Jul 2015 ++3692217600 37 # 1 Jan 2017 ++3786825600 36 # 1 Jan 2020 (fake entry to test negative leap second) ++ ++# FIPS 180-1 hash ++# NOTE! this value has not been recomputed for this unit test file. ++#h 16edd0f0 3666784f 37db6bdd e74ced87 59af48f1 diff --git a/83f90279b0fdd64c1d67d479de5e60ee068b9499.patch b/83f90279b0fdd64c1d67d479de5e60ee068b9499.patch new file mode 100644 index 0000000..2a40be8 --- /dev/null +++ b/83f90279b0fdd64c1d67d479de5e60ee068b9499.patch @@ -0,0 +1,59 @@ +From 83f90279b0fdd64c1d67d479de5e60ee068b9499 Mon Sep 17 00:00:00 2001 +From: Patrick Oppenlander +Date: Thu, 8 Feb 2024 14:36:27 +1100 +Subject: [PATCH] leapdb: move source check into separate function + +The sanity checks are valid for all possible sources of leap second +information, so move them into a separate function check_leap_source(). +--- + leapdb.c | 32 +++++++++++++++++++++----------- + 1 file changed, 21 insertions(+), 11 deletions(-) + +diff --git a/leapdb.c b/leapdb.c +index 32f753a..aa49b3c 100644 +--- a/leapdb.c ++++ b/leapdb.c +@@ -93,22 +93,32 @@ get_tz_leap(time_t when, int *tai_offset) + + /* ================================================== */ + ++static int ++check_leap_source(NTP_Leap (*src)(time_t when, int *tai_offset)) ++{ ++ int tai_offset = 0; ++ ++ /* Check that the leap second source has good data for Jun 30 2012 and Dec 31 2012 */ ++ if (src(1341014400, &tai_offset) == LEAP_InsertSecond && tai_offset == 34 && ++ src(1356912000, &tai_offset) == LEAP_Normal && tai_offset == 35) ++ return 1; ++ ++ return 0; ++} ++ ++/* ================================================== */ ++ + void + LDB_Initialise(void) + { +- int tai_offset; +- + leap_tzname = CNF_GetLeapSecTimezone(); +- if (leap_tzname) { +- /* Check that the timezone has good data for Jun 30 2012 and Dec 31 2012 */ +- if (get_tz_leap(1341014400, &tai_offset) == LEAP_InsertSecond && tai_offset == 34 && +- get_tz_leap(1356912000, &tai_offset) == LEAP_Normal && tai_offset == 35) { +- LOG(LOGS_INFO, "Using %s timezone to obtain leap second data", leap_tzname); +- } else { +- LOG(LOGS_WARN, "Timezone %s failed leap second check, ignoring", leap_tzname); +- leap_tzname = NULL; +- } ++ if (leap_tzname && !check_leap_source(get_tz_leap)) { ++ LOG(LOGS_WARN, "Timezone %s failed leap second check, ignoring", leap_tzname); ++ leap_tzname = NULL; + } ++ ++ if (leap_tzname) ++ LOG(LOGS_INFO, "Using %s timezone to obtain leap second data", leap_tzname); + } + + /* ================================================== */ diff --git a/chrony.spec b/chrony.spec index afdaf20..e09a654 100644 --- a/chrony.spec +++ b/chrony.spec @@ -70,7 +70,12 @@ Patch2: chrony-logrotate.patch Patch3: chrony-service-ordering.patch Patch7: chrony-htonl.patch Patch8: chrony.nm-dispatcher.dhcp.patch -Patch9: 6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch +Patch9: 017d6f8f5630071e2a532f58f9513757d94ac7d5.patch +Patch10: 02ae9a86077c629eb6f998c4f824bb9b9c4e60ce.patch +Patch11: 83f90279b0fdd64c1d67d479de5e60ee068b9499.patch +Patch12: 53823b9f1c076b3b26d0ad031eb95a51e6842abd.patch +Patch13: 637b77d1bd634298b1b54059e212d6f7d402fa26.patch +Patch14: 6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch BuildRequires: NetworkManager-devel BuildRequires: bison BuildRequires: findutils @@ -87,6 +92,7 @@ BuildRequires: pps-tools-devel BuildRequires: sysuser-tools BuildRequires: timezone BuildRequires: pkgconfig(systemd) +BuildRequires: rubygem(asciidoctor) Recommends: logrotate Requires(post): %fillup_prereq %if %{with sysusers} @@ -183,6 +189,11 @@ e.g. because the servers will be set via DHCP. %patch -P 7 %patch -P 8 %patch -P 9 -p1 +%patch -P 10 -p1 +%patch -P 11 -p1 +%patch -P 12 -p1 +%patch -P 13 -p1 +%patch -P 14 -p1 # Remove pool statements from the default /etc/chrony.conf. They will # be provided by branding packages in /etc/chrony.d/pool.conf . From 8c6b8f79345941f33ab351ed5a76fe2d7a727dd2e814146fe5675024881a8c95 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 16:19:12 +0000 Subject: [PATCH 07/30] revert OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=129 --- ...6f8f5630071e2a532f58f9513757d94ac7d5.patch | 419 ------------------ ...9a86077c629eb6f998c4f824bb9b9c4e60ce.patch | 88 ---- ...3b9f1c076b3b26d0ad031eb95a51e6842abd.patch | 317 ------------- ...77d1bd634298b1b54059e212d6f7d402fa26.patch | 150 ------- ...fe2f16fa49963e47e84f4a6dd9069735062e.patch | 166 ------- ...0279b0fdd64c1d67d479de5e60ee068b9499.patch | 59 --- chrony.changes | 2 - chrony.spec | 13 - 8 files changed, 1214 deletions(-) delete mode 100644 017d6f8f5630071e2a532f58f9513757d94ac7d5.patch delete mode 100644 02ae9a86077c629eb6f998c4f824bb9b9c4e60ce.patch delete mode 100644 53823b9f1c076b3b26d0ad031eb95a51e6842abd.patch delete mode 100644 637b77d1bd634298b1b54059e212d6f7d402fa26.patch delete mode 100644 6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch delete mode 100644 83f90279b0fdd64c1d67d479de5e60ee068b9499.patch diff --git a/017d6f8f5630071e2a532f58f9513757d94ac7d5.patch b/017d6f8f5630071e2a532f58f9513757d94ac7d5.patch deleted file mode 100644 index 0d70531..0000000 --- a/017d6f8f5630071e2a532f58f9513757d94ac7d5.patch +++ /dev/null @@ -1,419 +0,0 @@ -From 017d6f8f5630071e2a532f58f9513757d94ac7d5 Mon Sep 17 00:00:00 2001 -From: Patrick Oppenlander -Date: Thu, 8 Feb 2024 14:36:25 +1100 -Subject: [PATCH] reference: move leap second source into leapdb - -Separate out source of leap second data into a new module in preparation -for supporting more sources such as leap-seconds.list. ---- - Makefile.in | 2 +- - leapdb.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - leapdb.h | 37 +++++++++++++ - main.c | 3 ++ - reference.c | 99 +++-------------------------------- - 5 files changed, 194 insertions(+), 94 deletions(-) - create mode 100644 leapdb.c - create mode 100644 leapdb.h - -diff --git a/Makefile.in b/Makefile.in -index 101e0c69..318109bb 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -37,7 +37,7 @@ GETDATE_CFLAGS = @GETDATE_CFLAGS@ - - EXTRA_OBJS = @EXTRA_OBJS@ - --OBJS = array.o cmdparse.o conf.o local.o logging.o main.o memory.o quantiles.o \ -+OBJS = array.o cmdparse.o conf.o leapdb.o local.o logging.o main.o memory.o quantiles.o \ - reference.o regress.o rtc.o samplefilt.o sched.o socket.o sources.o sourcestats.o \ - stubs.o smooth.o sys.o sys_null.o tempcomp.o util.o $(EXTRA_OBJS) - -diff --git a/leapdb.c b/leapdb.c -new file mode 100644 -index 00000000..676a0d5d ---- /dev/null -+++ b/leapdb.c -@@ -0,0 +1,147 @@ -+/* -+ chronyd/chronyc - Programs for keeping computer clocks accurate. -+ -+ ********************************************************************** -+ * Copyright (C) Miroslav Lichvar 2009-2018, 2020, 2022 -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of version 2 of the GNU General Public License as -+ * published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -+ * -+ ********************************************************************** -+ -+ ======================================================================= -+ -+ This module provides leap second information. */ -+ -+#include "config.h" -+ -+#include "sysincl.h" -+ -+#include "conf.h" -+#include "leapdb.h" -+#include "logging.h" -+ -+/* ================================================== */ -+ -+/* Name of a system timezone containing leap seconds occuring at midnight */ -+static char *leap_tzname; -+ -+/* ================================================== */ -+ -+static NTP_Leap -+get_tz_leap(time_t when, int *tai_offset) -+{ -+ static time_t last_tz_leap_check; -+ static NTP_Leap tz_leap; -+ static int tz_tai_offset; -+ -+ struct tm stm, *tm; -+ time_t t; -+ char *tz_env, tz_orig[128]; -+ -+ *tai_offset = tz_tai_offset; -+ -+ /* Do this check at most twice a day */ -+ when = when / (12 * 3600) * (12 * 3600); -+ if (last_tz_leap_check == when) -+ return tz_leap; -+ -+ last_tz_leap_check = when; -+ tz_leap = LEAP_Normal; -+ tz_tai_offset = 0; -+ -+ tm = gmtime(&when); -+ if (!tm) -+ return tz_leap; -+ -+ stm = *tm; -+ -+ /* Temporarily switch to the timezone containing leap seconds */ -+ tz_env = getenv("TZ"); -+ if (tz_env) { -+ if (strlen(tz_env) >= sizeof (tz_orig)) -+ return tz_leap; -+ strcpy(tz_orig, tz_env); -+ } -+ setenv("TZ", leap_tzname, 1); -+ tzset(); -+ -+ /* Get the TAI-UTC offset, which started at the epoch at 10 seconds */ -+ t = mktime(&stm); -+ if (t != -1) -+ tz_tai_offset = t - when + 10; -+ -+ /* Set the time to 23:59:60 and see how it overflows in mktime() */ -+ stm.tm_sec = 60; -+ stm.tm_min = 59; -+ stm.tm_hour = 23; -+ -+ t = mktime(&stm); -+ -+ if (tz_env) -+ setenv("TZ", tz_orig, 1); -+ else -+ unsetenv("TZ"); -+ tzset(); -+ -+ if (t == -1) -+ return tz_leap; -+ -+ if (stm.tm_sec == 60) -+ tz_leap = LEAP_InsertSecond; -+ else if (stm.tm_sec == 1) -+ tz_leap = LEAP_DeleteSecond; -+ -+ *tai_offset = tz_tai_offset; -+ -+ return tz_leap; -+} -+ -+/* ================================================== */ -+ -+void -+LDB_Initialise(void) -+{ -+ int tai_offset; -+ -+ leap_tzname = CNF_GetLeapSecTimezone(); -+ if (leap_tzname) { -+ /* Check that the timezone has good data for Jun 30 2012 and Dec 31 2012 */ -+ if (get_tz_leap(1341014400, &tai_offset) == LEAP_InsertSecond && tai_offset == 34 && -+ get_tz_leap(1356912000, &tai_offset) == LEAP_Normal && tai_offset == 35) { -+ LOG(LOGS_INFO, "Using %s timezone to obtain leap second data", leap_tzname); -+ } else { -+ LOG(LOGS_WARN, "Timezone %s failed leap second check, ignoring", leap_tzname); -+ leap_tzname = NULL; -+ } -+ } -+} -+ -+/* ================================================== */ -+ -+NTP_Leap -+LDB_GetLeap(time_t when, int *tai_offset) -+{ -+ *tai_offset = 0; -+ if (leap_tzname) -+ return get_tz_leap(when, tai_offset); -+ return LEAP_Normal; -+} -+ -+/* ================================================== */ -+ -+void -+LDB_Finalise(void) -+{ -+ /* Nothing to do */ -+} -diff --git a/leapdb.h b/leapdb.h -new file mode 100644 -index 00000000..eab24141 ---- /dev/null -+++ b/leapdb.h -@@ -0,0 +1,37 @@ -+/* -+ chronyd/chronyc - Programs for keeping computer clocks accurate. -+ -+ ********************************************************************** -+ * Copyright (C) Patrick Oppenlander 2023 -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of version 2 of the GNU General Public License as -+ * published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -+ * -+ ********************************************************************** -+ -+ ======================================================================= -+ -+ This module provides leap second information. -+ -+ */ -+ -+#ifndef GOT_LEAPDB_H -+#define GOT_LEAPDB_H -+ -+#include "ntp.h" -+ -+extern void LDB_Initialise(void); -+extern NTP_Leap LDB_GetLeap(time_t when, int *tai_offset); -+extern void LDB_Finalise(void); -+ -+#endif /* GOT_LEAPDB_H */ -diff --git a/main.c b/main.c -index 21d0fe7f..cb240640 100644 ---- a/main.c -+++ b/main.c -@@ -32,6 +32,7 @@ - - #include "main.h" - #include "sched.h" -+#include "leapdb.h" - #include "local.h" - #include "sys.h" - #include "ntp_io.h" -@@ -134,6 +135,7 @@ MAI_CleanupAndExit(void) - RCL_Finalise(); - SRC_Finalise(); - REF_Finalise(); -+ LDB_Finalise(); - RTC_Finalise(); - SYS_Finalise(); - -@@ -655,6 +657,7 @@ int main - if (!geteuid()) - LOG(LOGS_WARN, "Running with root privileges"); - -+ LDB_Initialise(); - REF_Initialise(); - SST_Initialise(); - NSR_Initialise(); -diff --git a/reference.c b/reference.c -index 97dfbe98..1ac6cb93 100644 ---- a/reference.c -+++ b/reference.c -@@ -33,6 +33,7 @@ - #include "reference.h" - #include "util.h" - #include "conf.h" -+#include "leapdb.h" - #include "logging.h" - #include "local.h" - #include "sched.h" -@@ -122,9 +123,6 @@ static int leap_in_progress; - /* Timer for the leap second handler */ - static SCH_TimeoutID leap_timeout_id; - --/* Name of a system timezone containing leap seconds occuring at midnight */ --static char *leap_tzname; -- - /* ================================================== */ - - static LOG_FileID logfileid; -@@ -155,7 +153,6 @@ static int ref_adjustments; - - /* ================================================== */ - --static NTP_Leap get_tz_leap(time_t when, int *tai_offset); - static void update_leap_status(NTP_Leap leap, time_t now, int reset); - - /* ================================================== */ -@@ -195,7 +192,6 @@ REF_Initialise(void) - FILE *in; - double file_freq_ppm, file_skew_ppm; - double our_frequency_ppm; -- int tai_offset; - - mode = REF_ModeNormal; - are_we_synchronised = 0; -@@ -260,18 +256,6 @@ REF_Initialise(void) - if (leap_mode == REF_LeapModeSystem && !LCL_CanSystemLeap()) - leap_mode = REF_LeapModeStep; - -- leap_tzname = CNF_GetLeapSecTimezone(); -- if (leap_tzname) { -- /* Check that the timezone has good data for Jun 30 2012 and Dec 31 2012 */ -- if (get_tz_leap(1341014400, &tai_offset) == LEAP_InsertSecond && tai_offset == 34 && -- get_tz_leap(1356912000, &tai_offset) == LEAP_Normal && tai_offset == 35) { -- LOG(LOGS_INFO, "Using %s timezone to obtain leap second data", leap_tzname); -- } else { -- LOG(LOGS_WARN, "Timezone %s failed leap second check, ignoring", leap_tzname); -- leap_tzname = NULL; -- } -- } -- - CNF_GetMakeStep(&make_step_limit, &make_step_threshold); - CNF_GetMaxChange(&max_offset_delay, &max_offset_ignore, &max_offset); - CNF_GetMailOnChange(&do_mail_change, &mail_change_threshold, &mail_change_user); -@@ -593,77 +577,6 @@ is_leap_second_day(time_t when) - - /* ================================================== */ - --static NTP_Leap --get_tz_leap(time_t when, int *tai_offset) --{ -- static time_t last_tz_leap_check; -- static NTP_Leap tz_leap; -- static int tz_tai_offset; -- -- struct tm stm, *tm; -- time_t t; -- char *tz_env, tz_orig[128]; -- -- *tai_offset = tz_tai_offset; -- -- /* Do this check at most twice a day */ -- when = when / (12 * 3600) * (12 * 3600); -- if (last_tz_leap_check == when) -- return tz_leap; -- -- last_tz_leap_check = when; -- tz_leap = LEAP_Normal; -- tz_tai_offset = 0; -- -- tm = gmtime(&when); -- if (!tm) -- return tz_leap; -- -- stm = *tm; -- -- /* Temporarily switch to the timezone containing leap seconds */ -- tz_env = getenv("TZ"); -- if (tz_env) { -- if (strlen(tz_env) >= sizeof (tz_orig)) -- return tz_leap; -- strcpy(tz_orig, tz_env); -- } -- setenv("TZ", leap_tzname, 1); -- tzset(); -- -- /* Get the TAI-UTC offset, which started at the epoch at 10 seconds */ -- t = mktime(&stm); -- if (t != -1) -- tz_tai_offset = t - when + 10; -- -- /* Set the time to 23:59:60 and see how it overflows in mktime() */ -- stm.tm_sec = 60; -- stm.tm_min = 59; -- stm.tm_hour = 23; -- -- t = mktime(&stm); -- -- if (tz_env) -- setenv("TZ", tz_orig, 1); -- else -- unsetenv("TZ"); -- tzset(); -- -- if (t == -1) -- return tz_leap; -- -- if (stm.tm_sec == 60) -- tz_leap = LEAP_InsertSecond; -- else if (stm.tm_sec == 1) -- tz_leap = LEAP_DeleteSecond; -- -- *tai_offset = tz_tai_offset; -- -- return tz_leap; --} -- --/* ================================================== */ -- - static void - leap_end_timeout(void *arg) - { -@@ -751,16 +664,16 @@ set_leap_timeout(time_t now) - static void - update_leap_status(NTP_Leap leap, time_t now, int reset) - { -- NTP_Leap tz_leap; -+ NTP_Leap ldb_leap; - int leap_sec, tai_offset; - - leap_sec = 0; - tai_offset = 0; - -- if (leap_tzname && now) { -- tz_leap = get_tz_leap(now, &tai_offset); -+ if (now) { -+ ldb_leap = LDB_GetLeap(now, &tai_offset); - if (leap == LEAP_Normal) -- leap = tz_leap; -+ leap = ldb_leap; - } - - if (leap == LEAP_InsertSecond || leap == LEAP_DeleteSecond) { -@@ -1398,7 +1311,7 @@ REF_GetTaiOffset(struct timespec *ts) - { - int tai_offset; - -- get_tz_leap(ts->tv_sec, &tai_offset); -+ LDB_GetLeap(ts->tv_sec, &tai_offset); - - return tai_offset; - } diff --git a/02ae9a86077c629eb6f998c4f824bb9b9c4e60ce.patch b/02ae9a86077c629eb6f998c4f824bb9b9c4e60ce.patch deleted file mode 100644 index 52068d8..0000000 --- a/02ae9a86077c629eb6f998c4f824bb9b9c4e60ce.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 02ae9a86077c629eb6f998c4f824bb9b9c4e60ce Mon Sep 17 00:00:00 2001 -From: Patrick Oppenlander -Date: Thu, 8 Feb 2024 14:36:26 +1100 -Subject: [PATCH] leapdb: make twice per day check logic common - -We want to do the twice per day check regardless of the data source. -Move the check up one level from get_tz_leap() into LDB_GetLeap(). ---- - leapdb.c | 41 ++++++++++++++++++++--------------------- - 1 file changed, 20 insertions(+), 21 deletions(-) - -diff --git a/leapdb.c b/leapdb.c -index 676a0d5..32f753a 100644 ---- a/leapdb.c -+++ b/leapdb.c -@@ -41,24 +41,10 @@ static char *leap_tzname; - static NTP_Leap - get_tz_leap(time_t when, int *tai_offset) - { -- static time_t last_tz_leap_check; -- static NTP_Leap tz_leap; -- static int tz_tai_offset; -- - struct tm stm, *tm; - time_t t; - char *tz_env, tz_orig[128]; -- -- *tai_offset = tz_tai_offset; -- -- /* Do this check at most twice a day */ -- when = when / (12 * 3600) * (12 * 3600); -- if (last_tz_leap_check == when) -- return tz_leap; -- -- last_tz_leap_check = when; -- tz_leap = LEAP_Normal; -- tz_tai_offset = 0; -+ NTP_Leap tz_leap = LEAP_Normal; - - tm = gmtime(&when); - if (!tm) -@@ -79,7 +65,7 @@ get_tz_leap(time_t when, int *tai_offset) - /* Get the TAI-UTC offset, which started at the epoch at 10 seconds */ - t = mktime(&stm); - if (t != -1) -- tz_tai_offset = t - when + 10; -+ *tai_offset = t - when + 10; - - /* Set the time to 23:59:60 and see how it overflows in mktime() */ - stm.tm_sec = 60; -@@ -102,8 +88,6 @@ get_tz_leap(time_t when, int *tai_offset) - else if (stm.tm_sec == 1) - tz_leap = LEAP_DeleteSecond; - -- *tai_offset = tz_tai_offset; -- - return tz_leap; - } - -@@ -132,10 +116,25 @@ LDB_Initialise(void) - NTP_Leap - LDB_GetLeap(time_t when, int *tai_offset) - { -- *tai_offset = 0; -+ static time_t last_ldb_leap_check; -+ static NTP_Leap ldb_leap; -+ static int ldb_tai_offset; -+ -+ /* Do this check at most twice a day */ -+ when = when / (12 * 3600) * (12 * 3600); -+ if (last_ldb_leap_check == when) -+ goto out; -+ -+ last_ldb_leap_check = when; -+ ldb_leap = LEAP_Normal; -+ ldb_tai_offset = 0; -+ - if (leap_tzname) -- return get_tz_leap(when, tai_offset); -- return LEAP_Normal; -+ ldb_leap = get_tz_leap(when, &ldb_tai_offset); -+ -+out: -+ *tai_offset = ldb_tai_offset; -+ return ldb_leap; - } - - /* ================================================== */ diff --git a/53823b9f1c076b3b26d0ad031eb95a51e6842abd.patch b/53823b9f1c076b3b26d0ad031eb95a51e6842abd.patch deleted file mode 100644 index 475a14b..0000000 --- a/53823b9f1c076b3b26d0ad031eb95a51e6842abd.patch +++ /dev/null @@ -1,317 +0,0 @@ -From 53823b9f1c076b3b26d0ad031eb95a51e6842abd Mon Sep 17 00:00:00 2001 -From: Patrick Oppenlander -Date: Thu, 8 Feb 2024 14:36:28 +1100 -Subject: [PATCH] leapdb: support leap-seconds.list as second source - -The existing implementation of getting leap second information from a -timezone in get_tz_leap() relies on non-portable C library behaviour. - -Specifically, mktime is not required to return '60' in the tm_sec field -when a leap second is inserted leading to "Timezone right/UTC failed -leap second check, ignoring" errors on musl based systems. - -This patch adds support for getting leap second information from the -leap-seconds.list file included with tzdata and adds a new configuration -directive leapseclist to switch on the feature. ---- - conf.c | 14 +++++ - conf.h | 1 + - doc/chrony.conf.adoc | 20 +++++-- - leapdb.c | 126 +++++++++++++++++++++++++++++++++++++++++-- - refclock.c | 4 +- - 5 files changed, 155 insertions(+), 10 deletions(-) - -diff --git a/conf.c b/conf.c -index 73fe774a..6eae11c9 100644 ---- a/conf.c -+++ b/conf.c -@@ -249,6 +249,9 @@ static REF_LeapMode leapsec_mode = REF_LeapModeSystem; - /* Name of a system timezone containing leap seconds occuring at midnight */ - static char *leapsec_tz = NULL; - -+/* File name of leap seconds list, usually /usr/share/zoneinfo/leap-seconds.list */ -+static char *leapsec_list = NULL; -+ - /* Name of the user to which will be dropped root privileges. */ - static char *user; - -@@ -471,6 +474,7 @@ CNF_Finalise(void) - Free(hwclock_file); - Free(keys_file); - Free(leapsec_tz); -+ Free(leapsec_list); - Free(logdir); - Free(bind_ntp_iface); - Free(bind_acq_iface); -@@ -620,6 +624,8 @@ CNF_ParseLine(const char *filename, int number, char *line) - parse_leapsecmode(p); - } else if (!strcasecmp(command, "leapsectz")) { - parse_string(p, &leapsec_tz); -+ } else if (!strcasecmp(command, "leapseclist")) { -+ parse_string(p, &leapsec_list); - } else if (!strcasecmp(command, "local")) { - parse_local(p); - } else if (!strcasecmp(command, "lock_all")) { -@@ -2389,6 +2395,14 @@ CNF_GetLeapSecTimezone(void) - - /* ================================================== */ - -+char * -+CNF_GetLeapSecList(void) -+{ -+ return leapsec_list; -+} -+ -+/* ================================================== */ -+ - int - CNF_GetSchedPriority(void) - { -diff --git a/conf.h b/conf.h -index 58ebdeb0..4c0a7879 100644 ---- a/conf.h -+++ b/conf.h -@@ -91,6 +91,7 @@ extern char *CNF_GetNtpSigndSocket(void); - extern char *CNF_GetPidFile(void); - extern REF_LeapMode CNF_GetLeapSecMode(void); - extern char *CNF_GetLeapSecTimezone(void); -+extern char *CNF_GetLeapSecList(void); - - /* Value returned in ppm, as read from file */ - extern double CNF_GetMaxUpdateSkew(void); -diff --git a/doc/chrony.conf.adoc b/doc/chrony.conf.adoc -index eeaa5010..bd296bc6 100644 ---- a/doc/chrony.conf.adoc -+++ b/doc/chrony.conf.adoc -@@ -680,9 +680,10 @@ trusted and required source. - *tai*::: - This option indicates that the reference clock keeps time in TAI instead of UTC - and that *chronyd* should correct its offset by the current TAI-UTC offset. The --<> directive must be used with this option and the --database must be kept up to date in order for this correction to work as --expected. This option does not make sense with PPS refclocks. -+<> or <> directive must be -+used with this option and the database must be kept up to date in order for -+this correction to work as expected. This option does not make sense with PPS -+refclocks. - *local*::: - This option specifies that the reference clock is an unsynchronised clock which - is more stable than the system clock (e.g. TCXO, OCXO, or atomic clock) and -@@ -1269,6 +1270,19 @@ $ TZ=right/UTC date -d 'Dec 31 2008 23:59:60' - Wed Dec 31 23:59:60 UTC 2008 - ---- - -+[[leapseclist]]*leapseclist* _file_:: -+This directive specifies the path to a file containing a list of leap seconds -+and TAI-UTC offsets in NIST/IERS format. It is recommended to use -+the file _leap-seconds.list_ usually included with the system timezone -+database. The behaviour of this directive is otherwise equivalent to -+<>. -++ -+An example of this directive is: -++ -+---- -+leapseclist /usr/share/zoneinfo/leap-seconds.list -+---- -+ - [[makestep]]*makestep* _threshold_ _limit_:: - Normally *chronyd* will cause the system to gradually correct any time offset, - by slowing down or speeding up the clock as required. In certain situations, -diff --git a/leapdb.c b/leapdb.c -index aa49b3c4..e748e001 100644 ---- a/leapdb.c -+++ b/leapdb.c -@@ -3,6 +3,7 @@ - - ********************************************************************** - * Copyright (C) Miroslav Lichvar 2009-2018, 2020, 2022 -+ * Copyright (C) Patrick Oppenlander 2023, 2024 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as -@@ -30,11 +31,20 @@ - #include "conf.h" - #include "leapdb.h" - #include "logging.h" -+#include "util.h" - - /* ================================================== */ - --/* Name of a system timezone containing leap seconds occuring at midnight */ --static char *leap_tzname; -+/* Source of leap second data */ -+enum { -+ SRC_NONE, -+ SRC_TIMEZONE, -+ SRC_LIST, -+} leap_src; -+ -+/* Offset between leap-seconds.list timestamp epoch and Unix epoch. -+ leap-seconds.list epoch is 1 Jan 1900, 00:00:00 */ -+#define LEAP_SEC_LIST_OFFSET 2208988800 - - /* ================================================== */ - -@@ -59,7 +69,7 @@ get_tz_leap(time_t when, int *tai_offset) - return tz_leap; - strcpy(tz_orig, tz_env); - } -- setenv("TZ", leap_tzname, 1); -+ setenv("TZ", CNF_GetLeapSecTimezone(), 1); - tzset(); - - /* Get the TAI-UTC offset, which started at the epoch at 10 seconds */ -@@ -93,6 +103,91 @@ get_tz_leap(time_t when, int *tai_offset) - - /* ================================================== */ - -+static NTP_Leap -+get_list_leap(time_t when, int *tai_offset) -+{ -+ FILE *f; -+ char line[1024]; -+ NTP_Leap ret_leap = LEAP_Normal; -+ int ret_tai_offset = 0, prev_lsl_tai_offset = 10; -+ int64_t lsl_updated = 0, lsl_expiry = 0; -+ const char *leap_sec_list = CNF_GetLeapSecList(); -+ -+ if (!(f = UTI_OpenFile(NULL, leap_sec_list, NULL, 'r', 0))) { -+ LOG(LOGS_ERR, "Failed to open leap seconds list %s", leap_sec_list); -+ goto out; -+ } -+ -+ /* Leap second happens at midnight */ -+ when = (when / (24 * 3600) + 1) * (24 * 3600); -+ -+ /* leap-seconds.list timestamps are relative to 1 Jan 1900, 00:00:00 */ -+ when += LEAP_SEC_LIST_OFFSET; -+ -+ while (fgets(line, sizeof line, f) > 0) { -+ int64_t lsl_when; -+ int lsl_tai_offset; -+ char *p; -+ -+ /* Ignore blank lines */ -+ for (p = line; *p && isspace(*p); ++p) -+ ; -+ if (!*p) -+ continue; -+ -+ if (*line == '#') { -+ /* Update time line starts with #$ */ -+ if (line[1] == '$' && sscanf(line + 2, "%"SCNd64, &lsl_updated) != 1) -+ goto error; -+ /* Expiration time line starts with #@ */ -+ if (line[1] == '@' && sscanf(line + 2, "%"SCNd64, &lsl_expiry) != 1) -+ goto error; -+ /* Comment or a special comment we don't care about */ -+ continue; -+ } -+ -+ /* Leap entry */ -+ if (sscanf(line, "%"SCNd64" %d", &lsl_when, &lsl_tai_offset) != 2) -+ goto error; -+ -+ if (when == lsl_when) { -+ if (lsl_tai_offset > prev_lsl_tai_offset) -+ ret_leap = LEAP_InsertSecond; -+ else if (lsl_tai_offset < prev_lsl_tai_offset) -+ ret_leap = LEAP_DeleteSecond; -+ /* When is rounded to the end of the day, so offset hasn't changed yet! */ -+ ret_tai_offset = prev_lsl_tai_offset; -+ } else if (when > lsl_when) { -+ ret_tai_offset = lsl_tai_offset; -+ } -+ -+ prev_lsl_tai_offset = lsl_tai_offset; -+ } -+ -+ /* Make sure the file looks sensible */ -+ if (!feof(f) || !lsl_updated || !lsl_expiry) -+ goto error; -+ -+ if (when >= lsl_expiry) -+ LOG(LOGS_WARN, "Leap second list %s needs update", leap_sec_list); -+ -+ goto out; -+ -+error: -+ if (f) -+ fclose(f); -+ LOG(LOGS_ERR, "Failed to parse leap seconds list %s", leap_sec_list); -+ return LEAP_Normal; -+ -+out: -+ if (f) -+ fclose(f); -+ *tai_offset = ret_tai_offset; -+ return ret_leap; -+} -+ -+/* ================================================== */ -+ - static int - check_leap_source(NTP_Leap (*src)(time_t when, int *tai_offset)) - { -@@ -111,14 +206,27 @@ check_leap_source(NTP_Leap (*src)(time_t when, int *tai_offset)) - void - LDB_Initialise(void) - { -+ const char *leap_tzname, *leap_sec_list; -+ - leap_tzname = CNF_GetLeapSecTimezone(); - if (leap_tzname && !check_leap_source(get_tz_leap)) { - LOG(LOGS_WARN, "Timezone %s failed leap second check, ignoring", leap_tzname); - leap_tzname = NULL; - } - -- if (leap_tzname) -+ leap_sec_list = CNF_GetLeapSecList(); -+ if (leap_sec_list && !check_leap_source(get_list_leap)) { -+ LOG(LOGS_WARN, "Leap second list %s failed check, ignoring", leap_sec_list); -+ leap_sec_list = NULL; -+ } -+ -+ if (leap_sec_list) { -+ LOG(LOGS_INFO, "Using leap second list %s", leap_sec_list); -+ leap_src = SRC_LIST; -+ } else if (leap_tzname) { - LOG(LOGS_INFO, "Using %s timezone to obtain leap second data", leap_tzname); -+ leap_src = SRC_TIMEZONE; -+ } - } - - /* ================================================== */ -@@ -139,8 +247,16 @@ LDB_GetLeap(time_t when, int *tai_offset) - ldb_leap = LEAP_Normal; - ldb_tai_offset = 0; - -- if (leap_tzname) -+ switch (leap_src) { -+ case SRC_NONE: -+ break; -+ case SRC_TIMEZONE: - ldb_leap = get_tz_leap(when, &ldb_tai_offset); -+ break; -+ case SRC_LIST: -+ ldb_leap = get_list_leap(when, &ldb_tai_offset); -+ break; -+ } - - out: - *tai_offset = ldb_tai_offset; -diff --git a/refclock.c b/refclock.c -index 84f7439c..44ba6d5c 100644 ---- a/refclock.c -+++ b/refclock.c -@@ -166,8 +166,8 @@ RCL_AddRefclock(RefclockParameters *params) - if (!inst->driver->init && !inst->driver->poll) - LOG_FATAL("refclock driver %s is not compiled in", params->driver_name); - -- if (params->tai && !CNF_GetLeapSecTimezone()) -- LOG_FATAL("refclock tai option requires leapsectz"); -+ if (params->tai && !CNF_GetLeapSecList() && !CNF_GetLeapSecTimezone()) -+ LOG_FATAL("refclock tai option requires leapseclist or leapsectz"); - - inst->data = NULL; - inst->driver_parameter = Strdup(params->driver_parameter); diff --git a/637b77d1bd634298b1b54059e212d6f7d402fa26.patch b/637b77d1bd634298b1b54059e212d6f7d402fa26.patch deleted file mode 100644 index a2a07ab..0000000 --- a/637b77d1bd634298b1b54059e212d6f7d402fa26.patch +++ /dev/null @@ -1,150 +0,0 @@ -From 637b77d1bd634298b1b54059e212d6f7d402fa26 Mon Sep 17 00:00:00 2001 -From: Patrick Oppenlander -Date: Thu, 8 Feb 2024 14:36:29 +1100 -Subject: [PATCH] test: add leapdb unit test - ---- - test/unit/leapdb.c | 104 ++++++++++++++++++++++++++++++++++++++++++ - test/unit/leapdb.list | 22 +++++++++ - 2 files changed, 126 insertions(+) - create mode 100644 test/unit/leapdb.c - create mode 100644 test/unit/leapdb.list - -diff --git a/test/unit/leapdb.c b/test/unit/leapdb.c -new file mode 100644 -index 0000000..509fc39 ---- /dev/null -+++ b/test/unit/leapdb.c -@@ -0,0 +1,104 @@ -+/* -+ ********************************************************************** -+ * Copyright (C) Patrick Oppenlander 2023 -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of version 2 of the GNU General Public License as -+ * published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -+ * -+ ********************************************************************** -+ */ -+ -+#include -+#include "test.h" -+ -+struct test_vector { -+ time_t when; -+ int tai_offset; -+ NTP_Leap leap; -+ int fake; -+} tests[] = { -+ /* leapdb.list is a cut down version of leap-seconds.list */ -+ {3439756800, 34, LEAP_InsertSecond, 0}, /* 1 Jan 2009 */ -+ {3550089600, 35, LEAP_InsertSecond, 0}, /* 1 Jul 2012 */ -+ {3644697600, 36, LEAP_InsertSecond, 0}, /* 1 Jul 2015 */ -+ {3692217600, 37, LEAP_InsertSecond, 0}, /* 1 Jan 2017 */ -+ {3786825600, 36, LEAP_DeleteSecond, 1}, /* 1 Jan 2020 fake in leapdb.list */ -+}; -+ -+static void -+test_leap_source(NTP_Leap (*fn)(time_t when, int *tai_offset), -+ int skip_fakes) -+{ -+ int prev_tai_offset = 34; -+ for (int i = 0; i < sizeof tests / sizeof tests[0]; ++i) { -+ struct test_vector *t = tests + i; -+ -+ NTP_Leap leap; -+ int tai_offset = -1; -+ -+ /* Our unit test leapdb.list contains a fake entry removing a leap second. -+ * Skip this when testing with the right/UTC timezone using mktime(). */ -+ if (skip_fakes && t->fake) -+ continue; -+ -+ /* One second before leap second */ -+ leap = fn(t->when - LEAP_SEC_LIST_OFFSET - 1, &tai_offset); -+ TEST_CHECK(leap == t->leap); -+ TEST_CHECK(tai_offset = prev_tai_offset); -+ -+ /* Exactly on leap second */ -+ leap = fn(t->when - LEAP_SEC_LIST_OFFSET, &tai_offset); -+ TEST_CHECK(leap == LEAP_Normal); -+ TEST_CHECK(tai_offset == t->tai_offset); -+ -+ /* One second after leap second */ -+ leap = fn(t->when - LEAP_SEC_LIST_OFFSET + 1, &tai_offset); -+ TEST_CHECK(leap == LEAP_Normal); -+ TEST_CHECK(tai_offset == t->tai_offset); -+ -+ prev_tai_offset = t->tai_offset; -+ } -+} -+ -+void -+test_unit(void) -+{ -+ char conf[][100] = { -+ "leapsectz right/UTC", -+ "leapseclist leapdb.list" -+ }; -+ -+ CNF_Initialise(0, 0); -+ for (int i = 0; i < sizeof conf / sizeof conf[0]; i++) -+ CNF_ParseLine(NULL, i + 1, conf[i]); -+ LDB_Initialise(); -+ -+ if (check_leap_source(get_tz_leap)) { -+ DEBUG_LOG("testing get_tz_leap"); -+ test_leap_source(get_tz_leap, 1); -+ } else { -+ DEBUG_LOG("Skipping get_tz_leap test. Either the right/UTC timezone is " -+ "missing, or mktime() doesn't support leap seconds."); -+ } -+ -+ DEBUG_LOG("testing get_list_leap"); -+ TEST_CHECK(check_leap_source(get_list_leap)); -+ test_leap_source(get_list_leap, 0); -+ -+ /* This exercises the twice-per-day logic */ -+ DEBUG_LOG("testing LDB_GetLeap"); -+ test_leap_source(LDB_GetLeap, 1); -+ -+ LDB_Finalise(); -+ CNF_Finalise(); -+} -diff --git a/test/unit/leapdb.list b/test/unit/leapdb.list -new file mode 100644 -index 0000000..5dc2188 ---- /dev/null -+++ b/test/unit/leapdb.list -@@ -0,0 +1,22 @@ -+# -+# Cut down version of leap-seconds.list for unit test. -+# -+# Blank lines need to be ignored, so include a few for testing. -+# Whitespace errors on non-blank lines below are copied from the original file. -+# -+ -+# Leap second data update time -+#$ 3676924800 -+# -+# File update time -+#@ 3928521600 -+ -+3439756800 34 # 1 Jan 2009 -+3550089600 35 # 1 Jul 2012 -+3644697600 36 # 1 Jul 2015 -+3692217600 37 # 1 Jan 2017 -+3786825600 36 # 1 Jan 2020 (fake entry to test negative leap second) -+ -+# FIPS 180-1 hash -+# NOTE! this value has not been recomputed for this unit test file. -+#h 16edd0f0 3666784f 37db6bdd e74ced87 59af48f1 diff --git a/6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch b/6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch deleted file mode 100644 index b29ba8f..0000000 --- a/6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch +++ /dev/null @@ -1,166 +0,0 @@ -From 6cf9fe2f16fa49963e47e84f4a6dd9069735062e Mon Sep 17 00:00:00 2001 -From: Miroslav Lichvar -Date: Wed, 7 Feb 2024 15:48:43 +0100 -Subject: [PATCH] test: improve 113-leapsecond and 124-tai tests - -Use leapseclist instead of leapsectz and test also negative leap -seconds. Add a test for leapsectz when the date command indicates -right/UTC is available on the system and mktime() works as expected. -Check TAI offset in the server's log. ---- - test/simulation/113-leapsecond | 88 +++++++++++++++++++++++----------- - test/simulation/124-tai | 12 ++++- - 2 files changed, 70 insertions(+), 30 deletions(-) - -diff --git a/test/simulation/113-leapsecond b/test/simulation/113-leapsecond -index 394440b7..63da734d 100755 ---- a/test/simulation/113-leapsecond -+++ b/test/simulation/113-leapsecond -@@ -8,54 +8,86 @@ check_config_h 'FEAT_REFCLOCK 1' || test_skip - - export CLKNETSIM_START_DATE=$(TZ=UTC date -d 'Dec 30 2008 0:00:00' +'%s') - --leap=$[2 * 24 * 3600] - limit=$[4 * 24 * 3600] - client_start=$[2 * 3600] --server_conf="refclock SHM 0 dpoll 10 poll 10 --leapsectz right/UTC" - refclock_jitter=1e-9 --refclock_offset="(* -1.0 (equal 0.1 (max (sum 1.0) $leap) $leap))" - --for leapmode in system step slew; do -- client_conf="leapsecmode $leapmode" -- if [ $leapmode = slew ]; then -- max_sync_time=$[$leap + 12] -- else -- max_sync_time=$[$leap] -- fi -+for dir in "+1" "-1"; do -+ leap=$[2 * 24 * 3600 + 1 + $dir] -+ server_conf="refclock SHM 0 dpoll 10 poll 10 -+ leapseclist tmp/leap.list" -+ refclock_offset="(* $dir (equal 0.1 (max (sum 1.0) $leap) $leap))" -+ -+ cat > tmp/leap.list <<-EOF -+ #$ 3676924800 -+ #@ 3928521600 -+ 3345062400 33 # 1 Jan 2006 -+ 3439756800 $[33 - $dir] # 1 Jan 2009 $( -+ [ "$dir" = "+1" ] && echo -e "\n3471292800 33\n3502828800 34") -+ 3550089600 35 # 1 Jul 2012 -+ EOF -+ -+ for leapmode in system step slew; do -+ client_conf="leapsecmode $leapmode" -+ if [ $leapmode = slew ]; then -+ max_sync_time=$[2 * 24 * 3600 + 13] -+ else -+ max_sync_time=$[2 * 24 * 3600 + 1] -+ fi -+ min_sync_time=$[$max_sync_time - 2] -+ -+ run_test || test_fail -+ check_chronyd_exit || test_fail -+ check_source_selection || test_fail -+ check_packet_interval || test_fail -+ check_sync || test_fail -+ check_file_messages "System clock TAI offset set to" 1 1 log.1 || test_fail -+ check_file_messages "System clock TAI offset set to 33" 1 1 log.1 || test_fail -+ done -+ -+ client_server_options="trust" -+ client_conf="refclock SHM 0 dpoll 10 poll 10 delay 1e-3" -+ min_sync_time=$[$leap - 2] -+ max_sync_time=$[$leap] - - run_test || test_fail - check_chronyd_exit || test_fail - check_source_selection || test_fail - check_packet_interval || test_fail - check_sync || test_fail --done - --client_server_options="trust" --client_conf="refclock SHM 0 dpoll 10 poll 10 delay 1e-3" -+ client_server_options="" -+ client_conf="leapsecmode system" -+ min_sync_time=230000 -+ max_sync_time=240000 - --run_test || test_fail --check_chronyd_exit || test_fail --check_source_selection || test_fail --check_packet_interval || test_fail --check_sync || test_fail -+ for smoothmode in "" "leaponly"; do -+ server_conf="refclock SHM 0 dpoll 10 poll 10 -+ leapseclist tmp/leap.list -+ leapsecmode slew -+ smoothtime 400 0.001 $smoothmode" - --client_server_options="" --client_conf="leapsecmode system" --min_sync_time=230000 --max_sync_time=240000 -+ run_test || test_fail -+ check_chronyd_exit || test_fail -+ check_source_selection || test_fail -+ check_packet_interval || test_fail -+ check_sync || test_fail -+ done -+done - --for smoothmode in "" "leaponly"; do -+if TZ=right/UTC date -d 'Dec 31 2008 23:59:60' 2> /dev/null | grep :60; then - server_conf="refclock SHM 0 dpoll 10 poll 10 -- leapsectz right/UTC -- leapsecmode slew -- smoothtime 400 0.001 $smoothmode" -+ leapsectz right/UTC" -+ refclock_offset="(* -1 (equal 0.1 (max (sum 1.0) $leap) $leap))" -+ client_conf="leapsecmode system" -+ min_sync_time=$[$leap - 2] -+ max_sync_time=$[$leap] - - run_test || test_fail - check_chronyd_exit || test_fail - check_source_selection || test_fail - check_packet_interval || test_fail - check_sync || test_fail --done -+fi - - test_pass -diff --git a/test/simulation/124-tai b/test/simulation/124-tai -index 97064f7c..0192e10f 100755 ---- a/test/simulation/124-tai -+++ b/test/simulation/124-tai -@@ -18,10 +18,18 @@ servers=0 - refclock_offset="(+ -34 (equal 0.1 (max (sum 1.0) $leap) $leap))" - client_conf=" - refclock SHM 0 dpoll 0 poll 0 tai --leapsectz right/UTC -+leapseclist tmp/leap.list - leapsecmode ignore - maxchange 1e-3 1 0" - -+cat > tmp/leap.list <<-EOF -+ #$ 3676924800 -+ #@ 3928521600 -+ 3345062400 33 # 1 Jan 2006 -+ 3439756800 34 # 1 Jan 2009 -+ 3550089600 35 # 1 Jul 2012 -+EOF -+ - run_test || test_fail - check_chronyd_exit || test_fail - check_source_selection || test_fail -@@ -33,7 +41,7 @@ time_offset=-1000 - refclock_offset="(+ -34)" - client_conf=" - refclock SHM 0 dpoll 0 poll 0 tai --leapsectz right/UTC -+leapseclist tmp/leap.list - makestep 1 1 - maxchange 1e-3 1 0" - diff --git a/83f90279b0fdd64c1d67d479de5e60ee068b9499.patch b/83f90279b0fdd64c1d67d479de5e60ee068b9499.patch deleted file mode 100644 index 2a40be8..0000000 --- a/83f90279b0fdd64c1d67d479de5e60ee068b9499.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 83f90279b0fdd64c1d67d479de5e60ee068b9499 Mon Sep 17 00:00:00 2001 -From: Patrick Oppenlander -Date: Thu, 8 Feb 2024 14:36:27 +1100 -Subject: [PATCH] leapdb: move source check into separate function - -The sanity checks are valid for all possible sources of leap second -information, so move them into a separate function check_leap_source(). ---- - leapdb.c | 32 +++++++++++++++++++++----------- - 1 file changed, 21 insertions(+), 11 deletions(-) - -diff --git a/leapdb.c b/leapdb.c -index 32f753a..aa49b3c 100644 ---- a/leapdb.c -+++ b/leapdb.c -@@ -93,22 +93,32 @@ get_tz_leap(time_t when, int *tai_offset) - - /* ================================================== */ - -+static int -+check_leap_source(NTP_Leap (*src)(time_t when, int *tai_offset)) -+{ -+ int tai_offset = 0; -+ -+ /* Check that the leap second source has good data for Jun 30 2012 and Dec 31 2012 */ -+ if (src(1341014400, &tai_offset) == LEAP_InsertSecond && tai_offset == 34 && -+ src(1356912000, &tai_offset) == LEAP_Normal && tai_offset == 35) -+ return 1; -+ -+ return 0; -+} -+ -+/* ================================================== */ -+ - void - LDB_Initialise(void) - { -- int tai_offset; -- - leap_tzname = CNF_GetLeapSecTimezone(); -- if (leap_tzname) { -- /* Check that the timezone has good data for Jun 30 2012 and Dec 31 2012 */ -- if (get_tz_leap(1341014400, &tai_offset) == LEAP_InsertSecond && tai_offset == 34 && -- get_tz_leap(1356912000, &tai_offset) == LEAP_Normal && tai_offset == 35) { -- LOG(LOGS_INFO, "Using %s timezone to obtain leap second data", leap_tzname); -- } else { -- LOG(LOGS_WARN, "Timezone %s failed leap second check, ignoring", leap_tzname); -- leap_tzname = NULL; -- } -+ if (leap_tzname && !check_leap_source(get_tz_leap)) { -+ LOG(LOGS_WARN, "Timezone %s failed leap second check, ignoring", leap_tzname); -+ leap_tzname = NULL; - } -+ -+ if (leap_tzname) -+ LOG(LOGS_INFO, "Using %s timezone to obtain leap second data", leap_tzname); - } - - /* ================================================== */ diff --git a/chrony.changes b/chrony.changes index af372d9..f82d816 100644 --- a/chrony.changes +++ b/chrony.changes @@ -2,8 +2,6 @@ Mon May 27 15:34:40 UTC 2024 - Reinhard Max - Update clknetsim to snapshot 0a11a35. -- Add 6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch to fix test - 124-tai on some architectures (bsc#1225362). ------------------------------------------------------------------- Mon Feb 26 10:33:53 UTC 2024 - Dominique Leuenberger diff --git a/chrony.spec b/chrony.spec index e09a654..1f4e37a 100644 --- a/chrony.spec +++ b/chrony.spec @@ -70,12 +70,6 @@ Patch2: chrony-logrotate.patch Patch3: chrony-service-ordering.patch Patch7: chrony-htonl.patch Patch8: chrony.nm-dispatcher.dhcp.patch -Patch9: 017d6f8f5630071e2a532f58f9513757d94ac7d5.patch -Patch10: 02ae9a86077c629eb6f998c4f824bb9b9c4e60ce.patch -Patch11: 83f90279b0fdd64c1d67d479de5e60ee068b9499.patch -Patch12: 53823b9f1c076b3b26d0ad031eb95a51e6842abd.patch -Patch13: 637b77d1bd634298b1b54059e212d6f7d402fa26.patch -Patch14: 6cf9fe2f16fa49963e47e84f4a6dd9069735062e.patch BuildRequires: NetworkManager-devel BuildRequires: bison BuildRequires: findutils @@ -92,7 +86,6 @@ BuildRequires: pps-tools-devel BuildRequires: sysuser-tools BuildRequires: timezone BuildRequires: pkgconfig(systemd) -BuildRequires: rubygem(asciidoctor) Recommends: logrotate Requires(post): %fillup_prereq %if %{with sysusers} @@ -188,12 +181,6 @@ e.g. because the servers will be set via DHCP. %patch -P 3 %patch -P 7 %patch -P 8 -%patch -P 9 -p1 -%patch -P 10 -p1 -%patch -P 11 -p1 -%patch -P 12 -p1 -%patch -P 13 -p1 -%patch -P 14 -p1 # Remove pool statements from the default /etc/chrony.conf. They will # be provided by branding packages in /etc/chrony.d/pool.conf . From 73f8ed428c8144d0893f230431efa23fab7111bda1890342bf29bc56ea9c41c5 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 16:31:02 +0000 Subject: [PATCH 08/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=130 --- chrony-tai.patch | 11 +++++++++++ chrony.spec | 2 ++ 2 files changed, 13 insertions(+) create mode 100644 chrony-tai.patch diff --git a/chrony-tai.patch b/chrony-tai.patch new file mode 100644 index 0000000..548482d --- /dev/null +++ b/chrony-tai.patch @@ -0,0 +1,11 @@ +--- test/simulation/124-tai.orig ++++ test/simulation/124-tai +@@ -11,7 +11,7 @@ export CLKNETSIM_START_DATE=$(TZ=UTC dat + leap=$[10 * 60] + limit=$[20 * 60] + min_sync_time=2 +-max_sync_time=15 ++#max_sync_time=15 + refclock_jitter=1e-6 + servers=0 + diff --git a/chrony.spec b/chrony.spec index 1f4e37a..11f67f6 100644 --- a/chrony.spec +++ b/chrony.spec @@ -70,6 +70,7 @@ Patch2: chrony-logrotate.patch Patch3: chrony-service-ordering.patch Patch7: chrony-htonl.patch Patch8: chrony.nm-dispatcher.dhcp.patch +Patch9: chrony-tai.patch BuildRequires: NetworkManager-devel BuildRequires: bison BuildRequires: findutils @@ -181,6 +182,7 @@ e.g. because the servers will be set via DHCP. %patch -P 3 %patch -P 7 %patch -P 8 +%patch -P 9 # Remove pool statements from the default /etc/chrony.conf. They will # be provided by branding packages in /etc/chrony.d/pool.conf . From e6ff124da8e24c9929545af76163369de2f177b0f99973c49dfaa00ac43216dc Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 16:36:25 +0000 Subject: [PATCH 09/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=131 --- chrony.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chrony.spec b/chrony.spec index 11f67f6..a2cb878 100644 --- a/chrony.spec +++ b/chrony.spec @@ -299,6 +299,9 @@ find %{buildroot} -type f | xargs sed -i ' export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" make %{?_smp_mflags} -C test/simulation/clknetsim +pushd test/simulation +./124-tai +popd make %{?_smp_mflags} quickcheck %endif %endif From 865e89fbe6cc84f2174010aab3a035bed6d43f8bc67845719a54006dfb1c7718 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 16:41:02 +0000 Subject: [PATCH 10/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=132 --- chrony.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrony.spec b/chrony.spec index a2cb878..2c9dd6a 100644 --- a/chrony.spec +++ b/chrony.spec @@ -300,7 +300,7 @@ export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" make %{?_smp_mflags} -C test/simulation/clknetsim pushd test/simulation -./124-tai +./124-tai || find popd make %{?_smp_mflags} quickcheck %endif From f3ecb049bd3088606fd067dfcbe4243b4b9443b573182794cf19747b9c9daa03 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 16:47:20 +0000 Subject: [PATCH 11/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=133 --- chrony.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/chrony.spec b/chrony.spec index 2c9dd6a..d996a5c 100644 --- a/chrony.spec +++ b/chrony.spec @@ -300,8 +300,14 @@ export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" make %{?_smp_mflags} -C test/simulation/clknetsim pushd test/simulation -./124-tai || find +./124-tai +for f in tmp/*; do + echo ====$f==== + cat $f +done +echo popd +exit 1 make %{?_smp_mflags} quickcheck %endif %endif From dfab4a06840ba488779627b673b8ae5e6e447986da82215a9a59ee7434033a43 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 16:50:06 +0000 Subject: [PATCH 12/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=134 --- chrony.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrony.spec b/chrony.spec index d996a5c..5b83fe8 100644 --- a/chrony.spec +++ b/chrony.spec @@ -300,7 +300,7 @@ export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" make %{?_smp_mflags} -C test/simulation/clknetsim pushd test/simulation -./124-tai +./124-tai ||: for f in tmp/*; do echo ====$f==== cat $f From 92c3a0f742165ecdcc66f95d241c7810c7accb4dd01d157e7bfd91799f150e3f Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 May 2024 21:39:25 +0000 Subject: [PATCH 13/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=135 --- chrony-tai.patch | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/chrony-tai.patch b/chrony-tai.patch index 548482d..bb1f170 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -1,11 +1,11 @@ --- test/simulation/124-tai.orig +++ test/simulation/124-tai -@@ -11,7 +11,7 @@ export CLKNETSIM_START_DATE=$(TZ=UTC dat - leap=$[10 * 60] - limit=$[20 * 60] - min_sync_time=2 --max_sync_time=15 -+#max_sync_time=15 - refclock_jitter=1e-6 - servers=0 +@@ -27,6 +27,8 @@ check_chronyd_exit || test_fail + check_source_selection || test_fail + check_sync || test_fail ++test_pass ++ + export CLKNETSIM_START_DATE=$(TZ=UTC date -d 'Jan 01 2009 00:10:00' +'%s') + + time_offset=-1000 From 62a06df06f3220e43b438775142fef13b364bf0607117ea985e1f609b7fb9de8 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 11:34:58 +0000 Subject: [PATCH 14/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=136 --- chrony-tai.patch | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/chrony-tai.patch b/chrony-tai.patch index bb1f170..dcb389f 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -9,3 +9,38 @@ export CLKNETSIM_START_DATE=$(TZ=UTC date -d 'Jan 01 2009 00:10:00' +'%s') time_offset=-1000 +--- reference.c.orig ++++ reference.c +@@ -550,6 +550,16 @@ is_step_limit_reached(double offset, dou + } + + /* ================================================== */ ++static unsigned long ++dtul(double x) ++{ ++ union { ++ double a; ++ unsigned long b; ++ } tmp; ++ tmp.a = x; ++ return tmp.b; ++} + + static int + is_offset_ok(double offset) +@@ -562,10 +572,13 @@ is_offset_ok(double offset) + return 1; + } + ++ LOG(LOGS_WARN, "LULU1: %.020f, %016lx ", fabs(offset), dtul(fabs(offset))); ++ LOG(LOGS_WARN, "LULU2: %.020f, %016lx ", max_offset, dtul(max_offset)); ++ LOG(LOGS_WARN, "LULU3: =================================================="); + if (fabs(offset) > max_offset) { + LOG(LOGS_WARN, +- "Adjustment of %.3f seconds exceeds the allowed maximum of %.3f seconds (%s) ", +- -offset, max_offset, !max_offset_ignore ? "exiting" : "ignored"); ++ "Adjustment of %lu seconds exceeds the allowed maximum of %lu seconds (%s) ", ++ (unsigned long)-offset, (unsigned long)max_offset, !max_offset_ignore ? "exiting" : "ignored"); + if (!max_offset_ignore) + end_ref_mode(0); + else if (max_offset_ignore > 0) From 9e7f32d9ae747d2b0153cae78e800e332aeec69104d3e6d3aaf100e49cc72bcd Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 11:50:51 +0000 Subject: [PATCH 15/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=137 --- chrony-tai.patch | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/chrony-tai.patch b/chrony-tai.patch index dcb389f..92bf80d 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -11,30 +11,13 @@ time_offset=-1000 --- reference.c.orig +++ reference.c -@@ -550,6 +550,16 @@ is_step_limit_reached(double offset, dou - } - - /* ================================================== */ -+static unsigned long -+dtul(double x) -+{ -+ union { -+ double a; -+ unsigned long b; -+ } tmp; -+ tmp.a = x; -+ return tmp.b; -+} - - static int - is_offset_ok(double offset) -@@ -562,10 +572,13 @@ is_offset_ok(double offset) +@@ -562,10 +562,13 @@ is_offset_ok(double offset) return 1; } -+ LOG(LOGS_WARN, "LULU1: %.020f, %016lx ", fabs(offset), dtul(fabs(offset))); -+ LOG(LOGS_WARN, "LULU2: %.020f, %016lx ", max_offset, dtul(max_offset)); -+ LOG(LOGS_WARN, "LULU3: =================================================="); ++ LOG(LOGS_WARN, "HERE: %.010f ", fabs(offset)); ++ LOG(LOGS_WARN, "HERE: %.010f ", max_offset); ++ LOG(LOGS_WARN, "HERE: ===================="); if (fabs(offset) > max_offset) { LOG(LOGS_WARN, - "Adjustment of %.3f seconds exceeds the allowed maximum of %.3f seconds (%s) ", From 1058420de5583ae9eb3e2243ea3765108ca061a6f111f9f690ff881b1e162127 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 12:26:07 +0000 Subject: [PATCH 16/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=138 --- chrony-tai.patch | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/chrony-tai.patch b/chrony-tai.patch index 92bf80d..b76d618 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -1,6 +1,14 @@ --- test/simulation/124-tai.orig +++ test/simulation/124-tai -@@ -27,6 +27,8 @@ check_chronyd_exit || test_fail +@@ -20,13 +20,15 @@ client_conf=" + refclock SHM 0 dpoll 0 poll 0 tai + leapsectz right/UTC + leapsecmode ignore +-maxchange 1e-3 1 0" ++maxchange 2e-3 1 0" + + run_test || test_fail + check_chronyd_exit || test_fail check_source_selection || test_fail check_sync || test_fail From a7ddff99ecf94e4dc607cbf78dd70fe61298bfbb27320870af07bfd08d6255bb Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 12:56:21 +0000 Subject: [PATCH 17/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=139 --- chrony-tai.patch | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chrony-tai.patch b/chrony-tai.patch index b76d618..0012a81 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -5,7 +5,7 @@ leapsectz right/UTC leapsecmode ignore -maxchange 1e-3 1 0" -+maxchange 2e-3 1 0" ++maxchange 1.1e-3 1 0" run_test || test_fail check_chronyd_exit || test_fail @@ -17,6 +17,15 @@ export CLKNETSIM_START_DATE=$(TZ=UTC date -d 'Jan 01 2009 00:10:00' +'%s') time_offset=-1000 +@@ -35,7 +37,7 @@ client_conf=" + refclock SHM 0 dpoll 0 poll 0 tai + leapsectz right/UTC + makestep 1 1 +-maxchange 1e-3 1 0" ++maxchange 1.1e-3 1 0" + + run_test || test_fail + check_chronyd_exit || test_fail --- reference.c.orig +++ reference.c @@ -562,10 +562,13 @@ is_offset_ok(double offset) From 62300724ca0f15376c29739e3260b5d9c3f7c3a8b7e6ecda31f44a0fdb595c08 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 13:00:00 +0000 Subject: [PATCH 18/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=140 --- chrony-tai.patch | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/chrony-tai.patch b/chrony-tai.patch index 0012a81..ea07d77 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -1,27 +1,10 @@ --- test/simulation/124-tai.orig +++ test/simulation/124-tai -@@ -20,13 +20,15 @@ client_conf=" +@@ -20,7 +20,7 @@ client_conf=" refclock SHM 0 dpoll 0 poll 0 tai leapsectz right/UTC leapsecmode ignore -maxchange 1e-3 1 0" -+maxchange 1.1e-3 1 0" - - run_test || test_fail - check_chronyd_exit || test_fail - check_source_selection || test_fail - check_sync || test_fail - -+test_pass -+ - export CLKNETSIM_START_DATE=$(TZ=UTC date -d 'Jan 01 2009 00:10:00' +'%s') - - time_offset=-1000 -@@ -35,7 +37,7 @@ client_conf=" - refclock SHM 0 dpoll 0 poll 0 tai - leapsectz right/UTC - makestep 1 1 --maxchange 1e-3 1 0" +maxchange 1.1e-3 1 0" run_test || test_fail From 3eda8d85d9c166f3b308086d18d677e0b147d6e97db17e2233e85189841a55c7 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 13:15:44 +0000 Subject: [PATCH 19/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=141 --- chrony-tai.patch | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/chrony-tai.patch b/chrony-tai.patch index ea07d77..92a5b5e 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -1,14 +1,3 @@ ---- test/simulation/124-tai.orig -+++ test/simulation/124-tai -@@ -20,7 +20,7 @@ client_conf=" - refclock SHM 0 dpoll 0 poll 0 tai - leapsectz right/UTC - leapsecmode ignore --maxchange 1e-3 1 0" -+maxchange 1.1e-3 1 0" - - run_test || test_fail - check_chronyd_exit || test_fail --- reference.c.orig +++ reference.c @@ -562,10 +562,13 @@ is_offset_ok(double offset) From fcfbfc82e7aedefa65b80598c7c074eecace3d28cf738ca6f7e8881424b53374 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 13:23:31 +0000 Subject: [PATCH 20/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=142 --- chrony.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/chrony.spec b/chrony.spec index 5b83fe8..f64e626 100644 --- a/chrony.spec +++ b/chrony.spec @@ -298,6 +298,7 @@ find %{buildroot} -type f | xargs sed -i ' # Set random seed to get deterministic results export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" +export CLKNETSIM_CONNECT_TIMEOUT=100 make %{?_smp_mflags} -C test/simulation/clknetsim pushd test/simulation ./124-tai ||: From 043869cfcef72e423eb51db9af3feac92a9be98670504ca8daeea13d67fd4759 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 13:30:44 +0000 Subject: [PATCH 21/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=143 --- chrony-tai.patch | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/chrony-tai.patch b/chrony-tai.patch index 92a5b5e..904a81e 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -1,18 +1,21 @@ --- reference.c.orig +++ reference.c -@@ -562,10 +562,13 @@ is_offset_ok(double offset) +@@ -562,6 +562,7 @@ is_offset_ok(double offset) return 1; } -+ LOG(LOGS_WARN, "HERE: %.010f ", fabs(offset)); -+ LOG(LOGS_WARN, "HERE: %.010f ", max_offset); -+ LOG(LOGS_WARN, "HERE: ===================="); ++ LOG(LOGS_WARN, "fabs(offset) = %.010f ", fabs(offset)); if (fabs(offset) > max_offset) { LOG(LOGS_WARN, -- "Adjustment of %.3f seconds exceeds the allowed maximum of %.3f seconds (%s) ", -- -offset, max_offset, !max_offset_ignore ? "exiting" : "ignored"); -+ "Adjustment of %lu seconds exceeds the allowed maximum of %lu seconds (%s) ", -+ (unsigned long)-offset, (unsigned long)max_offset, !max_offset_ignore ? "exiting" : "ignored"); - if (!max_offset_ignore) - end_ref_mode(0); - else if (max_offset_ignore > 0) + "Adjustment of %.3f seconds exceeds the allowed maximum of %.3f seconds (%s) ", +--- test/simulation/124-tai.orig ++++ test/simulation/124-tai +@@ -20,7 +20,7 @@ client_conf=" + refclock SHM 0 dpoll 0 poll 0 tai + leapsectz right/UTC + leapsecmode ignore +-maxchange 1e-3 1 0" ++maxchange 1.1e-3 1 0" + + run_test || test_fail + check_chronyd_exit || test_fail From c32e75d5a7c64e6754a72fa110a96b12631d03855861c451d6c17b786f493495 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 13:35:42 +0000 Subject: [PATCH 22/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=144 --- chrony-tai.patch | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/chrony-tai.patch b/chrony-tai.patch index 904a81e..417a08c 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -10,7 +10,7 @@ "Adjustment of %.3f seconds exceeds the allowed maximum of %.3f seconds (%s) ", --- test/simulation/124-tai.orig +++ test/simulation/124-tai -@@ -20,7 +20,7 @@ client_conf=" +@@ -20,13 +20,15 @@ client_conf=" refclock SHM 0 dpoll 0 poll 0 tai leapsectz right/UTC leapsecmode ignore @@ -19,3 +19,11 @@ run_test || test_fail check_chronyd_exit || test_fail + check_source_selection || test_fail + check_sync || test_fail + ++test_pass ++ + export CLKNETSIM_START_DATE=$(TZ=UTC date -d 'Jan 01 2009 00:10:00' +'%s') + + time_offset=-1000 From 63f9a625708c10b8586dcf2bea88098963e96359998a4c721e8f63affd6e595e Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 13:39:20 +0000 Subject: [PATCH 23/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=145 --- chrony-tai.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrony-tai.patch b/chrony-tai.patch index 417a08c..076ea47 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -4,7 +4,7 @@ return 1; } -+ LOG(LOGS_WARN, "fabs(offset) = %.010f ", fabs(offset)); ++ LOG(LOGS_WARN, "offset = %.010f ", offset); if (fabs(offset) > max_offset) { LOG(LOGS_WARN, "Adjustment of %.3f seconds exceeds the allowed maximum of %.3f seconds (%s) ", From b2f36b59fe6aa0f4c4014ef90b459148c37995eee5e7e5c18dd165a1b5421875 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 13:50:32 +0000 Subject: [PATCH 24/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=146 --- chrony-tai.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrony-tai.patch b/chrony-tai.patch index 076ea47..8c2c2ba 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -4,7 +4,7 @@ return 1; } -+ LOG(LOGS_WARN, "offset = %.010f ", offset); ++ LOG(LOGS_WARN, "offset = % .010f ", offset); if (fabs(offset) > max_offset) { LOG(LOGS_WARN, "Adjustment of %.3f seconds exceeds the allowed maximum of %.3f seconds (%s) ", From d35a798a03a7d028296fc5459ca41c968b1855cc3e426eb34d8a7d1a161b685d Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Wed, 29 May 2024 14:30:53 +0000 Subject: [PATCH 25/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=147 --- chrony-tai.patch | 10 ++++++++-- chrony.spec | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/chrony-tai.patch b/chrony-tai.patch index 8c2c2ba..f39e151 100644 --- a/chrony-tai.patch +++ b/chrony-tai.patch @@ -1,10 +1,16 @@ --- reference.c.orig +++ reference.c -@@ -562,6 +562,7 @@ is_offset_ok(double offset) +@@ -562,6 +562,13 @@ is_offset_ok(double offset) return 1; } -+ LOG(LOGS_WARN, "offset = % .010f ", offset); ++ static int firsttime = 1; ++ if (firsttime) { ++ LOG(LOGS_WARN, "max_offset = % .010f ", max_offset); ++ firsttime = 0; ++ } ++ ++ LOG(LOGS_WARN, "offset = % .010f ", offset); if (fabs(offset) > max_offset) { LOG(LOGS_WARN, "Adjustment of %.3f seconds exceeds the allowed maximum of %.3f seconds (%s) ", diff --git a/chrony.spec b/chrony.spec index f64e626..f02bbb4 100644 --- a/chrony.spec +++ b/chrony.spec @@ -298,8 +298,8 @@ find %{buildroot} -type f | xargs sed -i ' # Set random seed to get deterministic results export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" -export CLKNETSIM_CONNECT_TIMEOUT=100 make %{?_smp_mflags} -C test/simulation/clknetsim +%if 0 pushd test/simulation ./124-tai ||: for f in tmp/*; do @@ -309,6 +309,7 @@ done echo popd exit 1 +%endif make %{?_smp_mflags} quickcheck %endif %endif From f5c50aa3f4d1431df79e3aace06516d643c1eacd1385e411846093c77fe67a8b Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Tue, 4 Jun 2024 10:21:04 +0000 Subject: [PATCH 26/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=148 --- chrony.spec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chrony.spec b/chrony.spec index f02bbb4..7baa9fd 100644 --- a/chrony.spec +++ b/chrony.spec @@ -182,7 +182,7 @@ e.g. because the servers will be set via DHCP. %patch -P 3 %patch -P 7 %patch -P 8 -%patch -P 9 +#%patch -P 9 # Remove pool statements from the default /etc/chrony.conf. They will # be provided by branding packages in /etc/chrony.d/pool.conf . @@ -299,8 +299,10 @@ find %{buildroot} -type f | xargs sed -i ' export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" make %{?_smp_mflags} -C test/simulation/clknetsim -%if 0 pushd test/simulation +./run -i 100 ./124-tai +exit 0 +%if 0 ./124-tai ||: for f in tmp/*; do echo ====$f==== From 0e3b3405282e00282704b6560b5f283123aa3b2e10e21a82fa215553ea743a3f Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Tue, 4 Jun 2024 12:02:50 +0000 Subject: [PATCH 27/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=149 --- chrony.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrony.spec b/chrony.spec index 7baa9fd..0a627df 100644 --- a/chrony.spec +++ b/chrony.spec @@ -296,7 +296,7 @@ find %{buildroot} -type f | xargs sed -i ' %ifnarch %ix86 %check # Set random seed to get deterministic results -export CLKNETSIM_RANDOM_SEED=24501 +#export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" make %{?_smp_mflags} -C test/simulation/clknetsim pushd test/simulation From 5393c63ce985bf5404854f1c7a8b5a4b0653b9a5f936ff9dc36d23a4ff7b597d Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Tue, 4 Jun 2024 14:37:38 +0000 Subject: [PATCH 28/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=150 --- chrony-124-tai.patch | 35 +++++++++++++++++++++++++++++++++++ chrony.spec | 6 +++--- 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 chrony-124-tai.patch diff --git a/chrony-124-tai.patch b/chrony-124-tai.patch new file mode 100644 index 0000000..943c854 --- /dev/null +++ b/chrony-124-tai.patch @@ -0,0 +1,35 @@ +From 8f5b3084144967b313cfb51285bf6517e06e1b9e Mon Sep 17 00:00:00 2001 +From: Miroslav Lichvar +Date: Tue, 4 Jun 2024 16:23:41 +0200 +Subject: [PATCH] test: make 124-tai more reliable + +Reported-by: Reinhard Max +--- + test/simulation/124-tai | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/test/simulation/124-tai b/test/simulation/124-tai +index 0192e10..e8c909d 100755 +--- a/test/simulation/124-tai ++++ b/test/simulation/124-tai +@@ -20,7 +20,7 @@ client_conf=" + refclock SHM 0 dpoll 0 poll 0 tai + leapseclist tmp/leap.list + leapsecmode ignore +-maxchange 1e-3 1 0" ++maxchange 1e-3 10 0" + + cat > tmp/leap.list <<-EOF + #$ 3676924800 +@@ -43,7 +43,7 @@ client_conf=" + refclock SHM 0 dpoll 0 poll 0 tai + leapseclist tmp/leap.list + makestep 1 1 +-maxchange 1e-3 1 0" ++maxchange 1e-3 10 0" + + run_test || test_fail + check_chronyd_exit || test_fail +-- +GitLab + diff --git a/chrony.spec b/chrony.spec index 0a627df..9f4b58c 100644 --- a/chrony.spec +++ b/chrony.spec @@ -70,7 +70,7 @@ Patch2: chrony-logrotate.patch Patch3: chrony-service-ordering.patch Patch7: chrony-htonl.patch Patch8: chrony.nm-dispatcher.dhcp.patch -Patch9: chrony-tai.patch +Patch9: chrony-124-tai.patch BuildRequires: NetworkManager-devel BuildRequires: bison BuildRequires: findutils @@ -182,7 +182,7 @@ e.g. because the servers will be set via DHCP. %patch -P 3 %patch -P 7 %patch -P 8 -#%patch -P 9 +%patch -P 9 # Remove pool statements from the default /etc/chrony.conf. They will # be provided by branding packages in /etc/chrony.d/pool.conf . @@ -296,7 +296,7 @@ find %{buildroot} -type f | xargs sed -i ' %ifnarch %ix86 %check # Set random seed to get deterministic results -#export CLKNETSIM_RANDOM_SEED=24501 +export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" make %{?_smp_mflags} -C test/simulation/clknetsim pushd test/simulation From 32cedd9f9830b2fd83839247cdfc67392355dd50d80fd42c77bee270300edc25 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Tue, 4 Jun 2024 14:48:34 +0000 Subject: [PATCH 29/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=151 --- chrony-124-tai.patch | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/chrony-124-tai.patch b/chrony-124-tai.patch index 943c854..5198fe4 100644 --- a/chrony-124-tai.patch +++ b/chrony-124-tai.patch @@ -8,28 +8,23 @@ Reported-by: Reinhard Max test/simulation/124-tai | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -diff --git a/test/simulation/124-tai b/test/simulation/124-tai -index 0192e10..e8c909d 100755 ---- a/test/simulation/124-tai -+++ b/test/simulation/124-tai +--- test/simulation/124-tai.orig ++++ test/simulation/124-tai @@ -20,7 +20,7 @@ client_conf=" refclock SHM 0 dpoll 0 poll 0 tai - leapseclist tmp/leap.list + leapsectz right/UTC leapsecmode ignore -maxchange 1e-3 1 0" +maxchange 1e-3 10 0" - cat > tmp/leap.list <<-EOF - #$ 3676924800 -@@ -43,7 +43,7 @@ client_conf=" + run_test || test_fail + check_chronyd_exit || test_fail +@@ -35,7 +35,7 @@ client_conf=" refclock SHM 0 dpoll 0 poll 0 tai - leapseclist tmp/leap.list + leapsectz right/UTC makestep 1 1 -maxchange 1e-3 1 0" +maxchange 1e-3 10 0" run_test || test_fail check_chronyd_exit || test_fail --- -GitLab - From 22801e29c6fc852b87e81592fd851b2c0be27299762cf5ba958f14c335da8d8d Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Tue, 4 Jun 2024 15:01:28 +0000 Subject: [PATCH 30/30] OBS-URL: https://build.opensuse.org/package/show/network:time/chrony?expand=0&rev=152 --- chrony-tai.patch | 35 ----------------------------------- chrony.changes | 5 +++++ chrony.spec | 13 ------------- 3 files changed, 5 insertions(+), 48 deletions(-) delete mode 100644 chrony-tai.patch diff --git a/chrony-tai.patch b/chrony-tai.patch deleted file mode 100644 index f39e151..0000000 --- a/chrony-tai.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- reference.c.orig -+++ reference.c -@@ -562,6 +562,13 @@ is_offset_ok(double offset) - return 1; - } - -+ static int firsttime = 1; -+ if (firsttime) { -+ LOG(LOGS_WARN, "max_offset = % .010f ", max_offset); -+ firsttime = 0; -+ } -+ -+ LOG(LOGS_WARN, "offset = % .010f ", offset); - if (fabs(offset) > max_offset) { - LOG(LOGS_WARN, - "Adjustment of %.3f seconds exceeds the allowed maximum of %.3f seconds (%s) ", ---- test/simulation/124-tai.orig -+++ test/simulation/124-tai -@@ -20,13 +20,15 @@ client_conf=" - refclock SHM 0 dpoll 0 poll 0 tai - leapsectz right/UTC - leapsecmode ignore --maxchange 1e-3 1 0" -+maxchange 1.1e-3 1 0" - - run_test || test_fail - check_chronyd_exit || test_fail - check_source_selection || test_fail - check_sync || test_fail - -+test_pass -+ - export CLKNETSIM_START_DATE=$(TZ=UTC date -d 'Jan 01 2009 00:10:00' +'%s') - - time_offset=-1000 diff --git a/chrony.changes b/chrony.changes index f82d816..bdcb1b8 100644 --- a/chrony.changes +++ b/chrony.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Jun 4 14:57:09 UTC 2024 - Reinhard Max + +- bsc#1225362, chrony-124-tai.patch: make 124-tai more reliable + ------------------------------------------------------------------- Mon May 27 15:34:40 UTC 2024 - Reinhard Max diff --git a/chrony.spec b/chrony.spec index 9f4b58c..b0ee217 100644 --- a/chrony.spec +++ b/chrony.spec @@ -299,19 +299,6 @@ find %{buildroot} -type f | xargs sed -i ' export CLKNETSIM_RANDOM_SEED=24501 export CFLAGS="%{optflags}" make %{?_smp_mflags} -C test/simulation/clknetsim -pushd test/simulation -./run -i 100 ./124-tai -exit 0 -%if 0 -./124-tai ||: -for f in tmp/*; do - echo ====$f==== - cat $f -done -echo -popd -exit 1 -%endif make %{?_smp_mflags} quickcheck %endif %endif