Debrand for AlmaLinux

This commit is contained in:
Andrew Lukoshko 2025-11-29 04:08:21 +00:00 committed by root
commit 3461fb7265
7 changed files with 1706 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,150 @@
From 0754d389b288f690c2815f1f99859ee03d3ca00b Mon Sep 17 00:00:00 2001
From: Mike Yuan <me@yhndnzj.com>
Date: Wed, 14 May 2025 20:33:22 +0200
Subject: [PATCH] man: don't duplicate version in History section
(cherry picked from commit 7d71b23304cf8f7d4b4a06f9322847c22c1c5175)
Related: RHEL-128767
---
man/kernel-command-line.xml | 5 ++---
man/systemd-system.conf.xml | 5 ++---
man/systemd.resource-control.xml | 7 +++----
man/systemd.xml | 5 ++---
tools/check-version-history.py | 7 +++++--
tools/command_ignorelist | 4 ++++
6 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/man/kernel-command-line.xml b/man/kernel-command-line.xml
index 0a4c8cf11b..102015f545 100644
--- a/man/kernel-command-line.xml
+++ b/man/kernel-command-line.xml
@@ -762,11 +762,10 @@
<variablelist>
<varlistentry>
<term>systemd 252</term>
+
<listitem><para>Kernel command-line arguments <varname>systemd.unified_cgroup_hierarchy</varname>
and <varname>systemd.legacy_systemd_cgroup_controller</varname> were deprecated. Please switch to
- the unified cgroup hierarchy.</para>
-
- <xi:include href="version-info.xml" xpointer="v252"/></listitem>
+ the unified cgroup hierarchy.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
index 297838eaa4..23d09cfb37 100644
--- a/man/systemd-system.conf.xml
+++ b/man/systemd-system.conf.xml
@@ -754,10 +754,9 @@
<variablelist>
<varlistentry>
<term>systemd 252</term>
- <listitem><para>Option <varname>DefaultBlockIOAccounting=</varname> was deprecated. Please switch
- to the unified cgroup hierarchy.</para>
- <xi:include href="version-info.xml" xpointer="v252"/></listitem>
+ <listitem><para>Option <varname>DefaultBlockIOAccounting=</varname> was deprecated. Please switch
+ to the unified cgroup hierarchy.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
diff --git a/man/systemd.resource-control.xml b/man/systemd.resource-control.xml
index e4403e7274..540db6293f 100644
--- a/man/systemd.resource-control.xml
+++ b/man/systemd.resource-control.xml
@@ -1689,7 +1689,8 @@ DeviceAllow=/dev/loop-control
<variablelist>
<varlistentry>
<term>systemd 252</term>
- <listitem><para> Options for controlling the Legacy Control Group Hierarchy (<ulink
+
+ <listitem><para>Options for controlling the Legacy Control Group Hierarchy (<ulink
url="https://docs.kernel.org/admin-guide/cgroup-v1/index.html">Control Groups version 1</ulink>)
are now fully deprecated:
<varname>CPUShares=<replaceable>weight</replaceable></varname>,
@@ -1703,9 +1704,7 @@ DeviceAllow=/dev/loop-control
<varname>BlockIOReadBandwidth=<replaceable>device</replaceable>
<replaceable>bytes</replaceable></varname>,
<varname>BlockIOWriteBandwidth=<replaceable>device</replaceable> <replaceable>bytes</replaceable></varname>.
- Please switch to the unified cgroup hierarchy.</para>
-
- <xi:include href="version-info.xml" xpointer="v252"/></listitem>
+ Please switch to the unified cgroup hierarchy.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
diff --git a/man/systemd.xml b/man/systemd.xml
index d11c601a88..afdaf98ac9 100644
--- a/man/systemd.xml
+++ b/man/systemd.xml
@@ -1563,11 +1563,10 @@
<variablelist>
<varlistentry>
<term>systemd 252</term>
+
<listitem><para>Kernel command-line arguments <varname>systemd.unified_cgroup_hierarchy</varname>
and <varname>systemd.legacy_systemd_cgroup_controller</varname> were deprecated. Please switch to
- the unified cgroup hierarchy.</para>
-
- <xi:include href="version-info.xml" xpointer="v252"/></listitem>
+ the unified cgroup hierarchy.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
diff --git a/tools/check-version-history.py b/tools/check-version-history.py
index efd7023762..dce2b6abd1 100644
--- a/tools/check-version-history.py
+++ b/tools/check-version-history.py
@@ -75,9 +75,12 @@ def find_undocumented_commands(pages, ignorelist):
parent = listitem if listitem is not None else varlistentry
rev = parent.getchildren()[-1]
- if rev.get("href") != "version-info.xml":
- if (filename, path) not in ignorelist:
+ if (
+ rev.get("href") != "version-info.xml" and
+ not path.startswith(tuple(entry[1] for entry in ignorelist if entry[0] == filename))
+ ):
undocumented.append((filename, path))
+
return undocumented
diff --git a/tools/command_ignorelist b/tools/command_ignorelist
index f35f2a3bc1..42076013e4 100644
--- a/tools/command_ignorelist
+++ b/tools/command_ignorelist
@@ -14,6 +14,7 @@ journald.conf.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="Co
journald.conf.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="RateLimitIntervalSec="]
journald.conf.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="SystemMaxUse="]
journald.conf.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="ForwardToSyslog="]
+kernel-command-line.xml ./refsect1[title="History"]/
loginctl.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="-p"]
loginctl.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="-a"]
loginctl.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--no-ask-password"]
@@ -123,6 +124,7 @@ systemctl.xml ./refsect1[title="Commands"]/refsect2[title="System Commands"]/var
systemctl.xml ./refsect1[title="Commands"]/refsect2[title="System Commands"]/variablelist/varlistentry[term="suspend"]
systemctl.xml ./refsect1[title="Commands"]/refsect2[title="System Commands"]/variablelist/varlistentry[term="hibernate"]
systemctl.xml ./refsect1[title="Commands"]/refsect2[title="System Commands"]/variablelist/varlistentry[term="switch-root ROOT INIT"]
+systemd.xml ./refsect1[title="History"]/
systemd-ask-password.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--icon="]
systemd-ask-password.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--timeout="]
systemd-ask-password.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--no-tty"]
@@ -169,6 +171,7 @@ systemd-nspawn.xml ./refsect1[title="Options"]/refsect2[title="Execution Options
systemd-nspawn.xml ./refsect1[title="Options"]/refsect2[title="System Identity Options"]/variablelist/varlistentry[term="--uuid="]
systemd-nspawn.xml ./refsect1[title="Options"]/refsect2[title="Networking Options"]/variablelist/varlistentry[term="--private-network"]
systemd-nspawn.xml ./refsect1[title="Options"]/refsect2[title="Image Options"]/variablelist/varlistentry[term="--read-only"]
+systemd-system.conf.xml ./refsect1[title="History"]/
systemd-tmpfiles.xml ./refsect1[title="Commands and options"]/variablelist/varlistentry[term="--create"]
systemd-tmpfiles.xml ./refsect1[title="Commands and options"]/variablelist/varlistentry[term="--clean"]
systemd-tmpfiles.xml ./refsect1[title="Commands and options"]/variablelist/varlistentry[term="--remove"]
@@ -243,6 +246,7 @@ systemd.path.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="Pat
systemd.path.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="Unit="]
systemd.path.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="MakeDirectory="]
systemd.path.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="DirectoryMode="]
+systemd.resource-control.xml ./refsect1[title="History"]/
systemd.service.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="Type="]
systemd.service.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="RemainAfterExit="]
systemd.service.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="GuessMainPID="]

View File

@ -0,0 +1,35 @@
From f7092782c240db9fe8887c510b231e1dd3c2f284 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Behrmann?= <behrmann@physik.fu-berlin.de>
Date: Wed, 20 Aug 2025 15:47:28 +0200
Subject: [PATCH] tools: ignore root element explicitly in
check-version-history
Currently these messages (broken for length)
2025-08-20T12:04:15.9609277Z
/home/runner/work/systemd/systemd/tools/check-version-history.py:26:
FutureWarning: This search incorrectly ignores the root element, and will be fixed in a future version.
If you rely on the current behaviour, change it to './/funcprototype/funcdef/function'
can be seen in CI output. So let's apply the suggestion.
(cherry picked from commit 1dcbb0b4ca48fe69e2984943d536c3f4252b12b1)
Related: RHEL-128767
---
tools/check-version-history.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/check-version-history.py b/tools/check-version-history.py
index dce2b6abd1..db32b6920a 100644
--- a/tools/check-version-history.py
+++ b/tools/check-version-history.py
@@ -23,7 +23,7 @@ def find_undocumented_functions(pages, ignorelist):
assert pagetree.getroot().tag == "refentry"
hist_section = pagetree.find("refsect1[title='History']")
- for func in pagetree.findall("//funcprototype/funcdef/function"):
+ for func in pagetree.findall(".//funcprototype/funcdef/function"):
path = f"./refsynopsisdiv/funcsynopsis/funcprototype/funcdef/function[.='{func.text}']"
assert pagetree.findall(path) == [func]

View File

@ -0,0 +1,48 @@
From 699c8216cd5cd85c344f6ca475b5adaa8272daa4 Mon Sep 17 00:00:00 2001
From: Masanari Iida <standby24x7@gmail.com>
Date: Tue, 11 Nov 2025 23:20:15 +0900
Subject: [PATCH] systemd-logind: Add signal section in man systemd-logind
This patch adds signal setion in man systemd-logind
(cherry picked from commit 036100d74563edda3cb81e19255ffec5e1b7fc7f)
Resolves: RHEL-128767
---
man/systemd-logind.service.xml | 10 ++++++++++
tools/command_ignorelist | 1 +
2 files changed, 11 insertions(+)
diff --git a/man/systemd-logind.service.xml b/man/systemd-logind.service.xml
index 93bcd6bc8f..34f6330bf7 100644
--- a/man/systemd-logind.service.xml
+++ b/man/systemd-logind.service.xml
@@ -95,6 +95,16 @@
Desktop Environments</ulink>.</para>
</refsect1>
+ <refsect1>
+ <title>Signal</title>
+ <variablelist>
+ <varlistentry>
+ <term><constant>SIGHUP</constant></term>
+ <listitem><para>Reloads the service configuration file.</para></listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
<refsect1>
<title>See Also</title>
<para><simplelist type="inline">
diff --git a/tools/command_ignorelist b/tools/command_ignorelist
index 42076013e4..ffbff08867 100644
--- a/tools/command_ignorelist
+++ b/tools/command_ignorelist
@@ -161,6 +161,7 @@ systemd-inhibit.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="
systemd-inhibit.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--why="]
systemd-inhibit.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--mode="]
systemd-inhibit.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--list"]
+systemd-logind.service.xml ./refsect1[title="Signal"]/
systemd-notify.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--ready"]
systemd-notify.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--pid="]
systemd-notify.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--status="]

View File

@ -0,0 +1,131 @@
From aba4e35c7af08fadf1d434f892f0b4b87ee9fafc Mon Sep 17 00:00:00 2001
From: Frantisek Sumsal <frantisek@sumsal.cz>
Date: Mon, 13 Oct 2025 17:36:55 +0200
Subject: [PATCH] timer: rebase the next elapse timestamp only if timer didn't
already run
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The test added in f4c3c107d9be4e922a080fc292ed3889c4e0f4a5 uncovered a
corner case while recalculating the next elapse timestamp of a timer unit
that uses RandomizedDelaySec= during deserialization.
If the scheduled time (without RandomizedDelaySec=) already elapsed,
systemd "rebases" the next elapse timestamp to the time when systemd
first started, to make the RandomizedDelaySec= feature work even at
boot. However, since it was done unconditionally, it always overrode the
next elapse timestamp, which could then cause the final next elapse
timestamp to fall out of the expected window.
With a couple of additional debug logs one of the test fail looks like
this:
[ 132.129815] TEST-53-TIMER.sh[384]: + : 'Next elapse timestamp after daemon-reload, try #328'
[ 132.129815] TEST-53-TIMER.sh[384]: + systemctl daemon-reload
[ 132.136352] systemd[1]: Reload requested from client PID 16399 ('systemctl') (unit TEST-53-TIMER.service)...
[ 132.136636] systemd[1]: Reloading...
[ 132.446160] systemd[1]: Rebasing next elapse timestamp
[ 132.446168] systemd[1]: v->next_elapse: Tue 2025-10-14 00:10:00 CEST
[ 132.446170] systemd[1]: rebased: Tue 2025-10-14 00:10:56 CEST
[ 132.446172] systemd[1]: v->next_elapse after rebase: Tue 2025-10-14 00:10:56 CEST
[ 132.447361] systemd[1]: Reloading finished in 310 ms.
[ 132.484041] TEST-53-TIMER.sh[384]: + check_elapse_timestamp
[ 132.484041] TEST-53-TIMER.sh[384]: + systemctl status timer-RandomizedDelaySec-16377.timer
[ 132.533657] TEST-53-TIMER.sh[16440]: ● timer-RandomizedDelaySec-16377.timer
[ 132.533657] TEST-53-TIMER.sh[16440]: Loaded: loaded (/run/systemd/system/timer-RandomizedDelaySec-16377.timer; static)
[ 132.533657] TEST-53-TIMER.sh[16440]: Active: active (waiting) since Mon 2025-10-13 23:00:00 CEST; 1h 13min ago
[ 132.533657] TEST-53-TIMER.sh[16440]: Invocation: 5555d4f060114a5493ff228013830d17
[ 132.533657] TEST-53-TIMER.sh[16440]: Trigger: Tue 2025-10-14 22:10:04 CEST; 21h left
[ 132.533657] TEST-53-TIMER.sh[16440]: Triggers: ● timer-RandomizedDelaySec-16377.service
[ 132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:07 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Changed dead -> waiting
[ 132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:07 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Adding 15h 35min 1.230173s random time.
[ 132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:07 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Realtime timer elapses at Tue 2025-10-14 15:45:58 CEST.
[ 132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:07 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Changed dead -> waiting
[ 132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Adding 16h 29min 44.084409s random time.
[ 132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Realtime timer elapses at Tue 2025-10-14 16:40:41 CEST.
[ 132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Changed dead -> waiting
[ 132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Adding 21h 59min 7.955828s random time.
[ 132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Realtime timer elapses at Tue 2025-10-14 22:10:04 CEST.
[ 132.533657] TEST-53-TIMER.sh[16440]: Oct 14 00:13:08 H systemd[1]: timer-RandomizedDelaySec-16377.timer: Changed dead -> waiting
[ 132.535386] TEST-53-TIMER.sh[384]: + systemctl show -p InactiveExitTimestamp timer-RandomizedDelaySec-16377.timer
[ 132.537727] TEST-53-TIMER.sh[16442]: InactiveExitTimestamp=Mon 2025-10-13 23:00:00 CEST
[ 132.540317] TEST-53-TIMER.sh[16444]: ++ systemctl show -P NextElapseUSecRealtime timer-RandomizedDelaySec-16377.timer
[ 132.547745] TEST-53-TIMER.sh[384]: + NEXT_ELAPSE_REALTIME='Tue 2025-10-14 22:10:04 CEST'
[ 132.548020] TEST-53-TIMER.sh[16445]: ++ date '--date=Tue 2025-10-14 22:10:04 CEST' +%s
[ 132.550218] TEST-53-TIMER.sh[384]: + NEXT_ELAPSE_REALTIME_S=1760472604
[ 132.550218] TEST-53-TIMER.sh[384]: + : 'Next elapse timestamp should be Tue 2025-10-14 00:10:00 CEST <= Tue 2025-10-14 22:10:04 CEST <= Tue 2025-10-14 22:10:00 CEST'
[ 132.550218] TEST-53-TIMER.sh[384]: + assert_ge 1760472604 1760393400
[ 132.550555] TEST-53-TIMER.sh[16446]: + set +ex
[ 132.550702] TEST-53-TIMER.sh[384]: + assert_le 1760472604 1760472600
[ 132.550832] TEST-53-TIMER.sh[16447]: + set +ex
[ 132.551091] TEST-53-TIMER.sh[16447]: FAIL: '1760472604' > '1760472600'
Here the original next elapse timestamp was Tue 2025-10-14 00:10:00 CEST
as expected, but it was overridden by the rebased timestamp:
Tue 2025-10-14 00:10:56 CEST. And when a new randomized delay was added
to it (21h 59min 7.955828s) the final next elapse timestamp fell out of
the expected window, i.e. Tue 2025-10-14 00:10:00 (scheduled time) <
Tue 2025-10-14 22:10:04 CEST (rebased elapse timestamp + randomized
delay) < Tue 2025-10-14 22:10:00 CEST (scheduled time + maximum from
RandomizedDelaySec=, i.e. 22h).
By limiting the timestamp rebase only the case where the unit hasn't
already run should prevent this from happening during daemon-reload.
(cherry picked from commit bdb8e584f4509de0daebbe2357d23156160c3a90)
Related: RHEL-118216
---
src/core/timer.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/core/timer.c b/src/core/timer.c
index 02fdf91c78..2fc95d597d 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -391,7 +391,8 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
continue;
if (v->base == TIMER_CALENDAR) {
- usec_t b, rebased;
+ bool rebase_after_boot_time = false;
+ usec_t b;
/* If DeferReactivation= is enabled, schedule the job based on the last time
* the trigger unit entered inactivity. Otherwise, if we know the last time
@@ -409,21 +410,25 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
b = t->last_trigger.realtime;
else if (dual_timestamp_is_set(&UNIT(t)->inactive_exit_timestamp))
b = UNIT(t)->inactive_exit_timestamp.realtime;
- else
+ else {
b = ts.realtime;
+ rebase_after_boot_time = true;
+ }
r = calendar_spec_next_usec(v->calendar_spec, b, &v->next_elapse);
if (r < 0)
continue;
- /* To make the delay due to RandomizedDelaySec= work even at boot, if the scheduled
- * time has already passed, set the time when systemd first started as the scheduled
- * time. Note that we base this on the monotonic timestamp of the boot, not the
- * realtime one, since the wallclock might have been off during boot. */
- rebased = map_clock_usec(UNIT(t)->manager->timestamps[MANAGER_TIMESTAMP_USERSPACE].monotonic,
- CLOCK_MONOTONIC, CLOCK_REALTIME);
- if (v->next_elapse < rebased)
- v->next_elapse = rebased;
+ if (rebase_after_boot_time) {
+ /* To make the delay due to RandomizedDelaySec= work even at boot, if the scheduled
+ * time has already passed, set the time when systemd first started as the scheduled
+ * time. Note that we base this on the monotonic timestamp of the boot, not the
+ * realtime one, since the wallclock might have been off during boot. */
+ usec_t rebased = map_clock_usec(UNIT(t)->manager->timestamps[MANAGER_TIMESTAMP_USERSPACE].monotonic,
+ CLOCK_MONOTONIC, CLOCK_REALTIME);
+ if (v->next_elapse < rebased)
+ v->next_elapse = rebased;
+ }
if (!found_realtime)
t->next_elapse_realtime = v->next_elapse;

View File

@ -0,0 +1,144 @@
From 974b8e42491ddf150f01f4e0b224d180ab1fe8fa Mon Sep 17 00:00:00 2001
From: Frantisek Sumsal <frantisek@sumsal.cz>
Date: Wed, 19 Nov 2025 14:44:13 +0100
Subject: [PATCH] timer: rebase last_trigger timestamp if needed
After bdb8e584f4509de0daebbe2357d23156160c3a90 we stopped rebasing the
next elapse timestamp unconditionally and the only case where we'd do
that was when both last trigger and last inactive timestamps were empty.
This covered timer units during boot just fine, since they would have
neither of those timestamps set. However, persistent timers
(Persistent=yes) store their last trigger timestamp on a persistent
storage and load it back after reboot, so the rebasing was skipped in
this case.
To mitigate this, check the last_trigger timestamp is older than the
current machine boot - if so, that means that it came from a stamp file
of a persistent timer unit and we need to rebase it to make
RandomizedDelaySec= work properly.
Follow-up for bdb8e584f4509de0daebbe2357d23156160c3a90.
(cherry picked from commit 3605b3ba87833a9919bfde05952a7d9de10499a2)
Related: RHEL-118216
---
src/core/timer.c | 15 +++--
...-53-TIMER.RandomizedDelaySec-persistent.sh | 67 +++++++++++++++++++
2 files changed, 78 insertions(+), 4 deletions(-)
create mode 100755 test/units/TEST-53-TIMER.RandomizedDelaySec-persistent.sh
diff --git a/src/core/timer.c b/src/core/timer.c
index 2fc95d597d..4158a67b5e 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -393,6 +393,7 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
if (v->base == TIMER_CALENDAR) {
bool rebase_after_boot_time = false;
usec_t b;
+ usec_t boot_monotonic = UNIT(t)->manager->timestamps[MANAGER_TIMESTAMP_USERSPACE].monotonic;
/* If DeferReactivation= is enabled, schedule the job based on the last time
* the trigger unit entered inactivity. Otherwise, if we know the last time
@@ -406,9 +407,16 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
t->last_trigger.realtime);
else
b = trigger->inactive_enter_timestamp.realtime;
- } else if (dual_timestamp_is_set(&t->last_trigger))
+ } else if (dual_timestamp_is_set(&t->last_trigger)) {
b = t->last_trigger.realtime;
- else if (dual_timestamp_is_set(&UNIT(t)->inactive_exit_timestamp))
+
+ /* Check if the last_trigger timestamp is older than the current machine
+ * boot. If so, this means the timestamp came from a stamp file of a
+ * persistent timer and we need to rebase it to make RandomizedDelaySec=
+ * work (see below). */
+ if (t->last_trigger.monotonic < boot_monotonic)
+ rebase_after_boot_time = true;
+ } else if (dual_timestamp_is_set(&UNIT(t)->inactive_exit_timestamp))
b = UNIT(t)->inactive_exit_timestamp.realtime;
else {
b = ts.realtime;
@@ -424,8 +432,7 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
* time has already passed, set the time when systemd first started as the scheduled
* time. Note that we base this on the monotonic timestamp of the boot, not the
* realtime one, since the wallclock might have been off during boot. */
- usec_t rebased = map_clock_usec(UNIT(t)->manager->timestamps[MANAGER_TIMESTAMP_USERSPACE].monotonic,
- CLOCK_MONOTONIC, CLOCK_REALTIME);
+ usec_t rebased = map_clock_usec(boot_monotonic, CLOCK_MONOTONIC, CLOCK_REALTIME);
if (v->next_elapse < rebased)
v->next_elapse = rebased;
}
diff --git a/test/units/TEST-53-TIMER.RandomizedDelaySec-persistent.sh b/test/units/TEST-53-TIMER.RandomizedDelaySec-persistent.sh
new file mode 100755
index 0000000000..af22daecc7
--- /dev/null
+++ b/test/units/TEST-53-TIMER.RandomizedDelaySec-persistent.sh
@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+#
+# Persistent timers (i.e. timers with Persitent=yes) save their last trigger timestamp to a persistent
+# storage (a stamp file), which is loaded during subsequent boots. As mentioned in the man page, such timers
+# should be still affected by RandomizedDelaySec= during boot even if they already elapsed and would be then
+# triggered immediately.
+#
+# This behavior was, however, broken by [0], which stopped rebasing the to-be next elapse timestamps
+# unconditionally and left that only for timers that have neither last trigger nor inactive exit timestamps
+# set, since rebasing is needed only during boot. This holds for regular timers during boot, but not for
+# persistent ones, since the last trigger timestamp is loaded from a persistent storage.
+#
+# Provides coverage for:
+# - https://github.com/systemd/systemd/issues/39739
+#
+# [0] bdb8e584f4509de0daebbe2357d23156160c3a90
+#
+set -eux
+set -o pipefail
+
+# shellcheck source=test/units/test-control.sh
+. "$(dirname "$0")"/util.sh
+
+UNIT_NAME="timer-RandomizedDelaySec-persistent-$RANDOM"
+STAMP_FILE="/var/lib/systemd/timers/stamp-$UNIT_NAME.timer"
+
+# Setup
+cat >"/run/systemd/system/$UNIT_NAME.timer" <<EOF
+[Timer]
+OnCalendar=daily
+Persistent=true
+RandomizedDelaySec=12h
+EOF
+
+cat >"/run/systemd/system/$UNIT_NAME.service" <<\EOF
+[Service]
+ExecStart=echo "Service ran at $(date)"
+EOF
+
+systemctl daemon-reload
+
+# Create timer's state file with an old-enough timestamp (~2 days ago), so it'd definitely elapse if the next
+# elapse timestamp wouldn't get rebased
+mkdir -p "$(dirname "$STAMP_FILE")"
+touch -d "2 days ago" "$STAMP_FILE"
+stat "$STAMP_FILE"
+SAVED_LAST_TRIGGER_S="$(stat --format="%Y" "$STAMP_FILE")"
+
+# Start the timer and verify that its last trigger timestamp didn't change
+#
+# The last trigger timestamp should get rebased before it gets used as a base for the next elapse timestamp
+# (since it pre-dates the machine boot time). This should then add a RandomizedDelaySec= to the rebased
+# timestamp and the timer unit should not get triggered immediately after starting.
+systemctl start "$UNIT_NAME.timer"
+systemctl status "$UNIT_NAME.timer"
+
+TIMER_LAST_TRIGGER="$(systemctl show --property=LastTriggerUSec --value "$UNIT_NAME.timer")"
+TIMER_LAST_TRIGGER_S="$(date --date="$TIMER_LAST_TRIGGER" "+%s")"
+: "The timer should not be triggered immediately, hence the last trigger timestamp should not change"
+assert_eq "$SAVED_LAST_TRIGGER_S" "$TIMER_LAST_TRIGGER_S"
+
+# Cleanup
+systemctl stop "$UNIT_NAME".{timer,service}
+systemctl clean --what=state "$UNIT_NAME.timer"
+rm -f "/run/systemd/system/$UNIT_NAME".{timer,service}
+systemctl daemon-reload

View File

@ -48,7 +48,7 @@ Url: https://systemd.io
# Allow users to specify the version and release when building the rpm by
# setting the %%version_override and %%release_override macros.
Version: %{?version_override}%{!?version_override:257}
Release: 19%{?dist}.alma.1
Release: 20%{?dist}.alma.1
%global stable %(c="%version"; [ "$c" = "${c#*.*}" ]; echo $?)
@ -602,6 +602,12 @@ Patch0489: 0489-strv-introduce-string_strv_hashmap_remove.patch
Patch0490: 0490-unit-file-introduce-unit_file_remove_from_name_map.patch
Patch0491: 0491-core-unit-remove-path-to-transient-unit-file-from-un.patch
Patch0492: 0492-TEST-07-PID1-add-reprudcer-for-issue-35190.patch
Patch0493: 0493-tools-check-version-history-avoid-DeprecationWarning.patch
Patch0494: 0494-man-don-t-duplicate-version-in-History-section.patch
Patch0495: 0495-tools-ignore-root-element-explicitly-in-check-versio.patch
Patch0496: 0496-systemd-logind-Add-signal-section-in-man-systemd-log.patch
Patch0497: 0497-timer-rebase-the-next-elapse-timestamp-only-if-timer.patch
Patch0498: 0498-timer-rebase-last_trigger-timestamp-if-needed.patch
# Downstream-only patches (90009999)
%endif
@ -1552,9 +1558,17 @@ rm -f .file-list-*
rm -f %{name}.lang
%changelog
* Tue Nov 25 2025 Andrew Lukoshko <alukoshko@almalinux.org> - 257-19.alma.1
* Sat Nov 29 2025 Andrew Lukoshko <alukoshko@almalinux.org> - 257-20.alma.1
- Debrand for AlmaLinux
* Thu Nov 27 2025 systemd maintenance team <systemd-maint@redhat.com> - 257-20
- tools/check-version-history: avoid DeprecationWarning with newer lxml (RHEL-128767)
- man: don't duplicate version in History section (RHEL-128767)
- tools: ignore root element explicitly in check-version-history (RHEL-128767)
- systemd-logind: Add signal section in man systemd-logind (RHEL-128767)
- timer: rebase the next elapse timestamp only if timer didn't already run (RHEL-118216)
- timer: rebase last_trigger timestamp if needed (RHEL-118216)
* Fri Nov 21 2025 systemd maintenance team <systemd-maint@redhat.com> - 257-19
- man: fix a missing word (RHEL-120277)
- sd_bus_open_user_machine(): Don't shortcut without necessary env (RHEL-129179)