update to 4.6 (RHEL-56964)

Resolves: RHEL-56964
This commit is contained in:
Miroslav Lichvar 2024-09-05 14:50:05 +02:00
parent a731c7024f
commit cf433b2aff
9 changed files with 26 additions and 1785 deletions

6
.gitignore vendored
View File

@ -1,3 +1,3 @@
/chrony-4.5.tar.gz
/chrony-4.5-tar-gz-asc.txt
/clknetsim-5d1dc0.tar.gz
/chrony-4.6.tar.gz
/chrony-4.6-tar-gz-asc.txt
/clknetsim-64df92.tar.gz

15
chrony-defconfig.patch Normal file
View File

@ -0,0 +1,15 @@
diff --git a/examples/chrony.conf.example2 b/examples/chrony.conf.example2
index 03e7d47b..bf2bbdda 100644
--- a/examples/chrony.conf.example2
+++ b/examples/chrony.conf.example2
@@ -37,8 +37,8 @@ ntsdumpdir /var/lib/chrony
# Insert/delete leap seconds by slewing instead of stepping.
#leapsecmode slew
-# Set the TAI-UTC offset of the system clock.
-#leapseclist /usr/share/zoneinfo/leap-seconds.list
+# Get TAI-UTC offset and leap seconds from the system tz database.
+#leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony

View File

@ -1,42 +0,0 @@
--- chrony-4.5/doc/chrony.conf.man.in 2023-12-05 14:26:13.000000000 +0100
+++ chrony.conf.man.in 2024-07-30 14:17:30.000000000 +0200
@@ -908,9 +915,10 @@
.RS 4
This option indicates that the reference clock keeps time in TAI instead of UTC
and that \fBchronyd\fP should correct its offset by the current TAI\-UTC offset. The
-\fBleapsectz\fP 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.
+\fBleapsectz\fP or \fBleapseclist\fP 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.
.RE
.sp
\fBlocal\fP
@@ -1652,6 +1660,25 @@
.if n .RE
.RE
.sp
+\fBleapseclist\fP \fIfile\fP
+.RS 4
+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 \fIleap\-seconds.list\fP usually included with the system timezone
+database. The behaviour of this directive is otherwise equivalent to
+\fBleapsectz\fP.
+.sp
+An example of this directive is:
+.sp
+.if n .RS 4
+.nf
+.fam C
+leapseclist /usr/share/zoneinfo/leap\-seconds.list
+.fam
+.fi
+.if n .RE
+.RE
+.sp
\fBmakestep\fP \fIthreshold\fP \fIlimit\fP
.RS 4
Normally \fBchronyd\fP will cause the system to gradually correct any time offset,

File diff suppressed because it is too large Load Diff

View File

@ -1,291 +0,0 @@
commit 78707d0717db7f410b3b1e1d4ae13d5cbf863a5e
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Tue Aug 6 10:45:55 2024 +0200
test: extend 008-confload test
diff --git a/test/system/008-confload b/test/system/008-confload
index 7e806988..b978c190 100755
--- a/test/system/008-confload
+++ b/test/system/008-confload
@@ -77,7 +77,32 @@ check_chronyc_output "^[^=]*
.. 127\.123\.5\.3 *[05] 7 [^^]*
.. 127\.123\.5\.6 [^^]*$" || test_fail
+run_chronyc "reload sources" || test_fail
+run_chronyc "reload sources" || test_fail
+
+rm $TEST_DIR/conf5.d/{3,5,6}.sources
+echo "server 127.123.5.7" > $TEST_DIR/conf5.d/7.sources
+
+run_chronyc "reload sources" || test_fail
+
+run_chronyc "sources" || test_fail
+check_chronyc_output "^[^=]*
+=*
+.. 127\.123\.1\.1 [^^]*
+.. 127\.123\.1\.3 [^^]*
+.. 127\.123\.1\.4 [^^]*
+.. 127\.123\.3\.1 [^^]*
+.. 127\.123\.2\.2 [^^]*
+.. 127\.123\.2\.3 [^^]*
+.. 127\.123\.4\.4 [^^]*
+.. 127\.123\.1\.2 *[05] 6 [^^]*
+.. 127\.123\.5\.2 *[05] 5 [^^]*
+.. 127\.123\.5\.7 [^^]*$" || test_fail
+
+run_chronyc "reload sources" || test_fail
+
stop_chronyd || test_fail
-check_chronyd_message_count "Could not add source" 1 1 || test_fail
+check_chronyd_message_count "Could not add source.*\.5\.5.*in use" 3 3 || test_fail
+check_chronyd_message_count "Could not add source" 3 3 || test_fail
test_pass
commit 3cac849bbfdc02625969cb721207d5436dc03ee4
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Tue Aug 6 11:28:26 2024 +0200
conf: merge ntp_source_ids with ntp_sources
Keep the configuration IDs of sources loaded from sourcedir in the
NTP_Source structure itself to simplify the code.
(Rebased to 4.5)
diff --git a/conf.c b/conf.c
index 146389aa..dad874b0 100644
--- a/conf.c
+++ b/conf.c
@@ -287,15 +287,14 @@ typedef struct {
NTP_Source_Type type;
int pool;
CPS_NTP_Source params;
+ uint32_t conf_id;
} NTP_Source;
/* Array of NTP_Source */
static ARR_Instance ntp_sources;
/* Array of (char *) */
static ARR_Instance ntp_source_dirs;
-/* Array of uint32_t corresponding to ntp_sources (for sourcedirs reload) */
-static ARR_Instance ntp_source_ids;
-/* Flag indicating ntp_sources and ntp_source_ids are used for sourcedirs */
+/* Flag indicating ntp_sources is used for sourcedirs after config load */
static int conf_ntp_sources_added = 0;
/* Array of RefclockParameters */
@@ -396,7 +395,6 @@ CNF_Initialise(int r, int client_only)
init_sources = ARR_CreateInstance(sizeof (IPAddr));
ntp_sources = ARR_CreateInstance(sizeof (NTP_Source));
ntp_source_dirs = ARR_CreateInstance(sizeof (char *));
- ntp_source_ids = ARR_CreateInstance(sizeof (uint32_t));
refclock_sources = ARR_CreateInstance(sizeof (RefclockParameters));
broadcasts = ARR_CreateInstance(sizeof (NTP_Broadcast_Destination));
@@ -456,7 +454,6 @@ CNF_Finalise(void)
ARR_DestroyInstance(init_sources);
ARR_DestroyInstance(ntp_sources);
ARR_DestroyInstance(ntp_source_dirs);
- ARR_DestroyInstance(ntp_source_ids);
ARR_DestroyInstance(refclock_sources);
ARR_DestroyInstance(broadcasts);
@@ -825,6 +822,8 @@ parse_source(char *line, char *type, int fatal)
}
source.params.name = Strdup(source.params.name);
+ source.conf_id = 0;
+
ARR_AppendElement(ntp_sources, &source);
}
@@ -1678,7 +1677,6 @@ reload_source_dirs(void)
{
NTP_Source *prev_sources, *new_sources, *source;
unsigned int i, j, prev_size, new_size, unresolved;
- uint32_t *prev_ids, *new_ids;
char buf[MAX_LINE_LENGTH];
NSR_Status s;
int d, pass;
@@ -1687,13 +1685,9 @@ reload_source_dirs(void)
if (!conf_ntp_sources_added)
return;
- prev_size = ARR_GetSize(ntp_source_ids);
- if (ARR_GetSize(ntp_sources) != prev_size)
- assert(0);
+ prev_size = ARR_GetSize(ntp_sources);
- /* Save the current sources and their configuration IDs */
- prev_ids = MallocArray(uint32_t, prev_size);
- memcpy(prev_ids, ARR_GetElements(ntp_source_ids), prev_size * sizeof (prev_ids[0]));
+ /* Save the current sources */
prev_sources = MallocArray(NTP_Source, prev_size);
memcpy(prev_sources, ARR_GetElements(ntp_sources), prev_size * sizeof (prev_sources[0]));
@@ -1711,8 +1705,6 @@ reload_source_dirs(void)
new_size = ARR_GetSize(ntp_sources);
new_sources = ARR_GetElements(ntp_sources);
- ARR_SetSize(ntp_source_ids, new_size);
- new_ids = ARR_GetElements(ntp_source_ids);
unresolved = 0;
LOG_SetContext(LOGC_SourceFile);
@@ -1728,14 +1720,14 @@ reload_source_dirs(void)
/* Remove missing sources before adding others to avoid conflicts */
if (pass == 0 && d < 0 && prev_sources[i].params.name[0] != '\0') {
- NSR_RemoveSourcesById(prev_ids[i]);
+ NSR_RemoveSourcesById(prev_sources[i].conf_id);
}
/* Add new sources */
if (pass == 1 && d > 0) {
source = &new_sources[j];
s = NSR_AddSourceByName(source->params.name, source->params.port, source->pool,
- source->type, &source->params.params, &new_ids[j]);
+ source->type, &source->params.params, &source->conf_id);
if (s == NSR_UnresolvedName) {
unresolved++;
@@ -1750,7 +1742,7 @@ reload_source_dirs(void)
/* Keep unchanged sources */
if (pass == 1 && d == 0)
- new_ids[j] = prev_ids[i];
+ new_sources[j].conf_id = prev_sources[i].conf_id;
}
}
@@ -1759,7 +1751,6 @@ reload_source_dirs(void)
for (i = 0; i < prev_size; i++)
Free(prev_sources[i].params.name);
Free(prev_sources);
- Free(prev_ids);
if (unresolved > 0)
NSR_ResolveSources();
@@ -1858,7 +1849,6 @@ CNF_AddSources(void)
/* The arrays will be used for sourcedir (re)loading */
ARR_SetSize(ntp_sources, 0);
- ARR_SetSize(ntp_source_ids, 0);
conf_ntp_sources_added = 1;
reload_source_dirs();
commit 8126dbd2de30957de32ce3e55ce367b7145a4c33
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Tue Aug 6 12:56:39 2024 +0200
conf: save source status in sourcedir reload
Save the NSR status when adding a source from a sourcedir and don't
hide sources that failed the addition by clearing their name.
(Rebased to 4.5)
diff --git a/conf.c b/conf.c
index dad874b0..6020e880 100644
--- a/conf.c
+++ b/conf.c
@@ -287,6 +287,7 @@ typedef struct {
NTP_Source_Type type;
int pool;
CPS_NTP_Source params;
+ NSR_Status status;
uint32_t conf_id;
} NTP_Source;
@@ -822,6 +823,7 @@ parse_source(char *line, char *type, int fatal)
}
source.params.name = Strdup(source.params.name);
+ source.status = NSR_NoSuchSource;
source.conf_id = 0;
ARR_AppendElement(ntp_sources, &source);
@@ -1719,30 +1721,30 @@ reload_source_dirs(void)
d = i < prev_size ? -1 : 1;
/* Remove missing sources before adding others to avoid conflicts */
- if (pass == 0 && d < 0 && prev_sources[i].params.name[0] != '\0') {
+ if (pass == 0 && d < 0 && prev_sources[i].status == NSR_Success) {
NSR_RemoveSourcesById(prev_sources[i].conf_id);
}
- /* Add new sources */
- if (pass == 1 && d > 0) {
+ /* Add new sources and sources that could not be added before */
+ if (pass == 1 && (d > 0 || (d == 0 && prev_sources[i].status != NSR_Success))) {
source = &new_sources[j];
s = NSR_AddSourceByName(source->params.name, source->params.port, source->pool,
source->type, &source->params.params, &source->conf_id);
+ source->status = s;
if (s == NSR_UnresolvedName) {
unresolved++;
} else if (s != NSR_Success) {
LOG(LOGS_ERR, "Could not add source %s : %s",
source->params.name, NSR_StatusToString(s));
-
- /* Mark the source as not present */
- source->params.name[0] = '\0';
}
}
/* Keep unchanged sources */
- if (pass == 1 && d == 0)
+ if (pass == 1 && d == 0) {
+ new_sources[j].status = prev_sources[i].status;
new_sources[j].conf_id = prev_sources[i].conf_id;
+ }
}
}
commit 7cd5d065fc17a0ec871df2ffdc74caf6d16d9f6a
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Tue Aug 6 13:05:26 2024 +0200
conf: don't repeat error message when adding sourcedir source
When a source from a configured sourcedir cannot be added (e.g. it is a
duplicate of another source), log the error message only on the first
attempt adding the source, until the source is removed and added to a
sourcedir again.
This avoids spamming of the system log with error messages if the
reload sources command is called frequently (e.g. from a DHCP renewal
networking script).
diff --git a/conf.c b/conf.c
index 6020e880..522e235a 100644
--- a/conf.c
+++ b/conf.c
@@ -1734,7 +1734,7 @@ reload_source_dirs(void)
if (s == NSR_UnresolvedName) {
unresolved++;
- } else if (s != NSR_Success) {
+ } else if (s != NSR_Success && (d > 0 || s != prev_sources[i].status)) {
LOG(LOGS_ERR, "Could not add source %s : %s",
source->params.name, NSR_StatusToString(s));
}
diff --git a/test/system/008-confload b/test/system/008-confload
index b978c190..b107d709 100755
--- a/test/system/008-confload
+++ b/test/system/008-confload
@@ -102,7 +102,7 @@ check_chronyc_output "^[^=]*
run_chronyc "reload sources" || test_fail
stop_chronyd || test_fail
-check_chronyd_message_count "Could not add source.*\.5\.5.*in use" 3 3 || test_fail
-check_chronyd_message_count "Could not add source" 3 3 || test_fail
+check_chronyd_message_count "Could not add source.*\.5\.5.*in use" 1 1 || test_fail
+check_chronyd_message_count "Could not add source" 1 1 || test_fail
test_pass

View File

@ -1,86 +0,0 @@
commit f49be7f06343ee27fff2950937d7f6742f53976f
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Tue Mar 12 14:30:27 2024 +0100
conf: don't load sourcedir during initstepslew and RTC init
If the reload sources command was received in the chronyd start-up
sequence with initstepslew and/or RTC init (-s option), the sources
loaded from sourcedirs caused a crash due to failed assertion after
adding sources specified in the config.
Ignore the reload sources command until chronyd enters the normal
operation mode.
Fixes: 519796de3756 ("conf: add sourcedirs directive")
diff --git a/conf.c b/conf.c
index 6eae11c9..8849bdce 100644
--- a/conf.c
+++ b/conf.c
@@ -298,6 +298,8 @@ static ARR_Instance ntp_sources;
static ARR_Instance ntp_source_dirs;
/* Array of uint32_t corresponding to ntp_sources (for sourcedirs reload) */
static ARR_Instance ntp_source_ids;
+/* Flag indicating ntp_sources and ntp_source_ids are used for sourcedirs */
+static int conf_ntp_sources_added = 0;
/* Array of RefclockParameters */
static ARR_Instance refclock_sources;
@@ -1689,8 +1691,12 @@ reload_source_dirs(void)
NSR_Status s;
int d, pass;
+ /* Ignore reload command before adding configured sources */
+ if (!conf_ntp_sources_added)
+ return;
+
prev_size = ARR_GetSize(ntp_source_ids);
- if (prev_size > 0 && ARR_GetSize(ntp_sources) != prev_size)
+ if (ARR_GetSize(ntp_sources) != prev_size)
assert(0);
/* Save the current sources and their configuration IDs */
@@ -1859,7 +1865,10 @@ CNF_AddSources(void)
Free(source->params.name);
}
+ /* The arrays will be used for sourcedir (re)loading */
ARR_SetSize(ntp_sources, 0);
+ ARR_SetSize(ntp_source_ids, 0);
+ conf_ntp_sources_added = 1;
reload_source_dirs();
}
diff --git a/test/simulation/203-initreload b/test/simulation/203-initreload
new file mode 100755
index 00000000..cf7924b8
--- /dev/null
+++ b/test/simulation/203-initreload
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+. ./test.common
+
+check_config_h 'FEAT_CMDMON 1' || test_skip
+
+# Test fix "conf: don't load sourcedir during initstepslew and RTC init"
+
+test_start "reload during initstepslew"
+
+client_conf="initstepslew 5 192.168.123.1
+sourcedir tmp"
+client_server_conf="#"
+chronyc_conf="reload sources"
+chronyc_start=4
+
+echo 'server 192.168.123.1' > tmp/sources.sources
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_sync || test_fail
+
+check_log_messages "Added source 192\.168\.123\.1" 1 1 || test_fail
+
+test_pass

View File

@ -1,39 +0,0 @@
commit e11b518a1ffa704986fb1f1835c425844ba248ef
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Mon Jan 8 11:35:56 2024 +0100
ntp: fix authenticated requests in serverstats
Fix the CLG_UpdateNtpStats() call to count requests passing the
authentication check instead of requests triggering a KoD response
(i.e. NTS NAK).
diff --git a/ntp_core.c b/ntp_core.c
index 023e60b2..35801744 100644
--- a/ntp_core.c
+++ b/ntp_core.c
@@ -2736,7 +2736,7 @@ NCR_ProcessRxUnknown(NTP_Remote_Address *remote_addr, NTP_Local_Address *local_a
CLG_DisableNtpTimestamps(&ntp_rx);
}
- CLG_UpdateNtpStats(kod != 0 && info.auth.mode != NTP_AUTH_NONE &&
+ CLG_UpdateNtpStats(kod == 0 && info.auth.mode != NTP_AUTH_NONE &&
info.auth.mode != NTP_AUTH_MSSNTP,
rx_ts->source, interleaved ? tx_ts->source : NTP_TS_DAEMON);
diff --git a/test/system/010-nts b/test/system/010-nts
index 8d92bbc8..b215efa3 100755
--- a/test/system/010-nts
+++ b/test/system/010-nts
@@ -45,6 +45,11 @@ check_chronyc_output "^Name/IP address Mode KeyID Type KLen Last Atm
=========================================================================
127\.0\.0\.1 NTS 1 (30|15) (128|256) [0-9] 0 0 [78] ( 64|100)$" || test_fail
+run_chronyc "serverstats" || test_fail
+check_chronyc_output "NTS-KE connections accepted: 1
+NTS-KE connections dropped : 0
+Authenticated NTP packets : [1-9][0-9]*" || test_fail
+
stop_chronyd || test_fail
check_chronyd_messages || test_fail
check_chronyd_files || test_fail

View File

@ -1,5 +1,5 @@
%global _hardened_build 1
%global clknetsim_ver 5d1dc0
%global clknetsim_ver 64df92
%bcond_without debug
%bcond_without nts
@ -8,7 +8,7 @@
%endif
Name: chrony
Version: 4.5
Version: 4.6
Release: 3%{?dist}
Summary: An NTP client/server
@ -29,16 +29,8 @@ Patch1: chrony-nm-dispatcher-dhcp.patch
Patch2: chrony-keys.patch
# revert some hardening options in service files
Patch3: chrony-services.patch
# fix serverstats to correctly count authenticated packets
Patch4: chrony-serverstats.patch
# fix crash on reload command during start
Patch5: chrony-reload.patch
# don't repeat error log messages when reloading sourcedir
Patch6: chrony-logreload.patch
# add support for leap-seconds.list file
Patch7: chrony-leaplist.patch
# update asciidoctor-generated man page
Patch8: chrony-leaplist-man.patch
# revert upstream changes in packaged configuration examples
Patch4: chrony-defconfig.patch
BuildRequires: gnutls-devel libcap-devel libedit-devel pps-tools-devel
BuildRequires: gcc gcc-c++ make bison systemd gnupg2
@ -72,11 +64,7 @@ service to other computers in the network.
%patch1 -p1 -b .nm-dispatcher-dhcp
%patch2 -p1 -b .keys
%patch3 -p1 -b .services
%patch4 -p1 -b .serverstats
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch4 -p1 -b .defconfig
%{?gitpatch: echo %{version}-%{gitpatch} > version.txt}

View File

@ -1,3 +1,3 @@
SHA512 (chrony-4.5.tar.gz) = 58a449e23186da799064b16ab16f799c1673296984b152b43e87c620d86e272c55365e83439d410fc89e4e0ba0befd7d5c625eac78a6665813b7ea75444f71b5
SHA512 (chrony-4.5-tar-gz-asc.txt) = 05470e6cc34524fdab494f70cee71d46172b38bdd4acd8173ac79fdec12178239248880db474437690094aae7909002113289ac7f9305130c5e0a1d9364122cb
SHA512 (clknetsim-5d1dc0.tar.gz) = 7d542443d7d9334d900cee821207fab1ee87e57fda6580a9d894f65fb36d265fdc4a72022b4293134d54cdeffba7e84d2f68f732f4b228b84d846d8668b314b2
SHA512 (chrony-4.6.tar.gz) = 84926b6c9eb90824ab98333412b001b18de9342dacb898d195ee8de52868b1945700a8b161de6b603c231460d290e02df6712c1dcb7f034ba45754b38466c8bd
SHA512 (chrony-4.6-tar-gz-asc.txt) = f735c1d52f1474d2af656e55d3a9abfd33b4ed706b983a393c7e3852b766b5179fe4098425ee7f32bb5db4a2e4170e8c5930cf63d20884be6c0eac338a3d26db
SHA512 (clknetsim-64df92.tar.gz) = 3253e6823b66f23f63203aad0ea22c25cf9d1f5af789722662f4d383111cb2c1816cb23d2fa06171a65b102ae82a5371376becb029d7c9b163b0aee710374c02