From 2d81c4f5564752596becc328be0ef16e7604da22 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Thu, 2 Oct 2025 12:28:36 +0200 Subject: [PATCH] systemd-257-16 Resolves: RHEL-118216 --- ...TEST-53-ISSUE-16347-to-TEST-53-TIMER.patch | 98 ++++++++++++ ...elapsed-timer-shouldn-t-trigger-the-.patch | 101 ++++++++++++ ...ext-elapse-timer-timestamp-after-des.patch | 147 ++++++++++++++++++ ...service-immediately-after-restart-of.patch | 29 ++++ ...-and-compare-just-the-property-value.patch | 49 ++++++ systemd.spec | 14 +- 6 files changed, 437 insertions(+), 1 deletion(-) create mode 100644 0448-test-rename-TEST-53-ISSUE-16347-to-TEST-53-TIMER.patch create mode 100644 0449-test-restarting-elapsed-timer-shouldn-t-trigger-the-.patch create mode 100644 0450-test-check-the-next-elapse-timer-timestamp-after-des.patch create mode 100644 0451-timer-don-t-run-service-immediately-after-restart-of.patch create mode 100644 0452-test-store-and-compare-just-the-property-value.patch diff --git a/0448-test-rename-TEST-53-ISSUE-16347-to-TEST-53-TIMER.patch b/0448-test-rename-TEST-53-ISSUE-16347-to-TEST-53-TIMER.patch new file mode 100644 index 0000000..bfa5b1d --- /dev/null +++ b/0448-test-rename-TEST-53-ISSUE-16347-to-TEST-53-TIMER.patch @@ -0,0 +1,98 @@ +From d3f7e897bec268e21b83670c8e1e9c5d11b801de Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Tue, 23 Sep 2025 14:28:33 +0200 +Subject: [PATCH] test: rename TEST-53-ISSUE-16347 to TEST-53-TIMER + +And split the existing test into a separate subtest. + +(cherry picked from commit 953c347fb6f293acbd6da009646bfc071b68ddd7) + +Related: RHEL-118216 +--- + .../meson.build | 0 + .../mkosi.configure | 0 + test/meson.build | 2 +- + ...3-ISSUE-16347.sh => TEST-53-TIMER.issue-16347.sh} | 12 ++++-------- + test/units/TEST-53-TIMER.sh | 11 +++++++++++ + 5 files changed, 16 insertions(+), 9 deletions(-) + rename test/{TEST-53-ISSUE-16347 => TEST-53-TIMER}/meson.build (100%) + rename test/{TEST-53-ISSUE-16347 => TEST-53-TIMER}/mkosi.configure (100%) + rename test/units/{TEST-53-ISSUE-16347.sh => TEST-53-TIMER.issue-16347.sh} (82%) + create mode 100755 test/units/TEST-53-TIMER.sh + +diff --git a/test/TEST-53-ISSUE-16347/meson.build b/test/TEST-53-TIMER/meson.build +similarity index 100% +rename from test/TEST-53-ISSUE-16347/meson.build +rename to test/TEST-53-TIMER/meson.build +diff --git a/test/TEST-53-ISSUE-16347/mkosi.configure b/test/TEST-53-TIMER/mkosi.configure +similarity index 100% +rename from test/TEST-53-ISSUE-16347/mkosi.configure +rename to test/TEST-53-TIMER/mkosi.configure +diff --git a/test/meson.build b/test/meson.build +index 8775a3a3df..c440bcb722 100644 +--- a/test/meson.build ++++ b/test/meson.build +@@ -351,7 +351,7 @@ foreach dirname : [ + # 'TEST-46-HOMED', # we don't ship systemd-homed + 'TEST-50-DISSECT', + 'TEST-52-HONORFIRSTSHUTDOWN', +- 'TEST-53-ISSUE-16347', ++ 'TEST-53-TIMER', + 'TEST-54-CREDS', + 'TEST-55-OOMD', + 'TEST-58-REPART', +diff --git a/test/units/TEST-53-ISSUE-16347.sh b/test/units/TEST-53-TIMER.issue-16347.sh +similarity index 82% +rename from test/units/TEST-53-ISSUE-16347.sh +rename to test/units/TEST-53-TIMER.issue-16347.sh +index 84cd66129d..8b266145cd 100755 +--- a/test/units/TEST-53-ISSUE-16347.sh ++++ b/test/units/TEST-53-TIMER.issue-16347.sh +@@ -3,10 +3,9 @@ + set -eux + set -o pipefail + +-: >/failed +- + # Reset host date to current time, 3 days in the past. + date -s "-3 days" ++trap 'date -s "+3 days"' EXIT + + # Run a timer for every 15 minutes. + systemd-run --unit test-timer --on-calendar "*:0/15:0" true +@@ -17,15 +16,12 @@ now=$(date +%s) + time_delta=$((next_elapsed - now)) + + # Check that the timer will elapse in less than 20 minutes. +-((0 < time_delta && time_delta < 1200)) || { ++if [[ "$time_delta" -lt 0 || "$time_delta" -gt 1200 ]]; then + echo 'Timer elapse outside of the expected 20 minute window.' + echo " next_elapsed=${next_elapsed}" + echo " now=${now}" + echo " time_delta=${time_delta}" +- echo '' +-} >>/failed ++ echo + +-if test ! -s /failed ; then +- rm -f /failed +- touch /testok ++ exit 1 + fi +diff --git a/test/units/TEST-53-TIMER.sh b/test/units/TEST-53-TIMER.sh +new file mode 100755 +index 0000000000..9c2a033aa9 +--- /dev/null ++++ b/test/units/TEST-53-TIMER.sh +@@ -0,0 +1,11 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++set -eux ++set -o pipefail ++ ++# shellcheck source=test/units/test-control.sh ++. "$(dirname "$0")"/test-control.sh ++ ++run_subtests ++ ++touch /testok diff --git a/0449-test-restarting-elapsed-timer-shouldn-t-trigger-the-.patch b/0449-test-restarting-elapsed-timer-shouldn-t-trigger-the-.patch new file mode 100644 index 0000000..1b5f3c8 --- /dev/null +++ b/0449-test-restarting-elapsed-timer-shouldn-t-trigger-the-.patch @@ -0,0 +1,101 @@ +From 4286441a3e2fc82e58ec64ff26aaecb313fd7dec Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Tue, 23 Sep 2025 17:42:01 +0200 +Subject: [PATCH] test: restarting elapsed timer shouldn't trigger the + corresponding service + +Provides coverage for: + - https://github.com/systemd/systemd/issues/31231 + - https://github.com/systemd/systemd/issues/35805 + +(cherry picked from commit 5730a400fd5ee82566fe03eb832121a0d4bc26b6) + +Related: RHEL-118216 +--- + test/units/TEST-53-TIMER.restart-trigger.sh | 77 +++++++++++++++++++++ + 1 file changed, 77 insertions(+) + create mode 100755 test/units/TEST-53-TIMER.restart-trigger.sh + +diff --git a/test/units/TEST-53-TIMER.restart-trigger.sh b/test/units/TEST-53-TIMER.restart-trigger.sh +new file mode 100755 +index 0000000000..057f379ddc +--- /dev/null ++++ b/test/units/TEST-53-TIMER.restart-trigger.sh +@@ -0,0 +1,77 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++# ++# Restarting an already elapsed timer shouldn't immediately trigger the corresponding service unit. ++# ++# Provides coverage for: ++# - https://github.com/systemd/systemd/issues/31231 ++# - https://github.com/systemd/systemd/issues/35805 ++set -eux ++set -o pipefail ++ ++# shellcheck source=test/units/test-control.sh ++. "$(dirname "$0")"/util.sh ++ ++UNIT_NAME="timer-restart-$RANDOM" ++TEST_MESSAGE="Hello from timer $RANDOM" ++ ++# Setup ++cat >"/run/systemd/system/$UNIT_NAME.timer" <"/run/systemd/system/$UNIT_NAME.service" <"/run/systemd/system/$UNIT_NAME.timer.d/99-override.conf" < +Date: Tue, 23 Sep 2025 21:04:12 +0200 +Subject: [PATCH] test: check the next elapse timer timestamp after + deserialization + +When deserializing a serialized timer unit with RandomizedDelaySec= set, +systemd should use the last inactive exit timestamp instead of current +realtime to calculate the new next elapse, so the timer unit actually +runs in the given calendar window. + +Provides coverage for: + - https://github.com/systemd/systemd/issues/18678 + - https://github.com/systemd/systemd/pull/27752 + +(cherry picked from commit f4c3c107d9be4e922a080fc292ed3889c4e0f4a5) + +Related: RHEL-118216 +--- + ...TEST-53-TIMER.RandomizedDelaySec-reload.sh | 97 +++++++++++++++++++ + test/units/util.sh | 9 ++ + 2 files changed, 106 insertions(+) + create mode 100755 test/units/TEST-53-TIMER.RandomizedDelaySec-reload.sh + +diff --git a/test/units/TEST-53-TIMER.RandomizedDelaySec-reload.sh b/test/units/TEST-53-TIMER.RandomizedDelaySec-reload.sh +new file mode 100755 +index 0000000000..08f4f469d6 +--- /dev/null ++++ b/test/units/TEST-53-TIMER.RandomizedDelaySec-reload.sh +@@ -0,0 +1,97 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++# ++# When deserializing a serialized timer unit with RandomizedDelaySec= set, systemd should use the last ++# inactive exit timestamp instead of current realtime to calculate the new next elapse, so the timer unit ++# actually runs in the given calendar window. ++# ++# Provides coverage for: ++# - https://github.com/systemd/systemd/issues/18678 ++# - https://github.com/systemd/systemd/pull/27752 ++set -eux ++set -o pipefail ++ ++# shellcheck source=test/units/test-control.sh ++. "$(dirname "$0")"/util.sh ++ ++UNIT_NAME="timer-RandomizedDelaySec-$RANDOM" ++TARGET_TS="$(date --date="tomorrow 00:10")" ++TARGET_TS_S="$(date --date="$TARGET_TS" "+%s")" ++# Maximum possible next elapse timestamp: $TARGET_TS (OnCalendar=) + 22 hours (RandomizedDelaySec=) ++MAX_NEXT_ELAPSE_REALTIME_S="$((TARGET_TS_S + 22 * 60 * 60))" ++MAX_NEXT_ELAPSE_REALTIME="$(date --date="@$MAX_NEXT_ELAPSE_REALTIME_S")" ++ ++# Let's make sure to return the date & time back to the original state once we're done with our time ++# shenigans. One way to do this would be to use hwclock, but the RTC in VMs can be unreliable or slow to ++# respond, causing unexpected test fails/timeouts. ++# ++# Instead, let's save the realtime timestamp before we start with the test together with a current monotonic ++# timestamp, after the test ends take the difference between the current monotonic timestamp and the "start" ++# one, add it to the originally saved realtime timestamp, and finally use that timestamp to set the system ++# time. This should advance the system time by the amount of time the test actually ran, and hence restore it ++# to some sane state after the time jumps performed by the test. It won't be perfect, but it should be close ++# enough for our needs. ++START_REALTIME="$(date "+%s")" ++START_MONOTONIC="$(cut -d . -f 1 /proc/uptime)" ++at_exit() { ++ : "Restore the system date to a sane state" ++ END_MONOTONIC="$(cut -d . -f 1 /proc/uptime)" ++ date --set="@$((START_REALTIME + END_MONOTONIC - START_MONOTONIC))" ++} ++trap at_exit EXIT ++ ++# Set some predictable time so we can schedule the first timer elapse in a deterministic-ish way ++date --set="23:00" ++ ++# Setup ++cat >"/run/systemd/system/$UNIT_NAME.timer" <"/run/systemd/system/$UNIT_NAME.service" <&2 ++ exit 1 ++ fi ++)} ++ + assert_in() {( + set +ex + diff --git a/0451-timer-don-t-run-service-immediately-after-restart-of.patch b/0451-timer-don-t-run-service-immediately-after-restart-of.patch new file mode 100644 index 0000000..c138ed3 --- /dev/null +++ b/0451-timer-don-t-run-service-immediately-after-restart-of.patch @@ -0,0 +1,29 @@ +From 4de919773f76a7658f034f0713503f965d4fb8c3 Mon Sep 17 00:00:00 2001 +From: Lukas Nykryn +Date: Tue, 9 Sep 2025 15:24:22 +0200 +Subject: [PATCH] timer: don't run service immediately after restart of a timer + +When a timer is restarted, don't reset the last_trigger field. +This prevents the timer from triggering immediately. + +Fixes: #31231 +(cherry picked from commit 3fc44a0f68412b649e16f12ff2f97a36c615457d) + +Resolves: RHEL-118216 +--- + src/core/timer.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/src/core/timer.c b/src/core/timer.c +index b37a67f310..02fdf91c78 100644 +--- a/src/core/timer.c ++++ b/src/core/timer.c +@@ -653,8 +653,6 @@ static int timer_start(Unit *u) { + if (r < 0) + return r; + +- t->last_trigger = DUAL_TIMESTAMP_NULL; +- + /* Reenable all timers that depend on unit activation time */ + LIST_FOREACH(value, v, t->values) + if (v->base == TIMER_ACTIVE) diff --git a/0452-test-store-and-compare-just-the-property-value.patch b/0452-test-store-and-compare-just-the-property-value.patch new file mode 100644 index 0000000..0dc5555 --- /dev/null +++ b/0452-test-store-and-compare-just-the-property-value.patch @@ -0,0 +1,49 @@ +From c2a0cd9a1f46f4c9093b2070ec36466caff3db68 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Mon, 29 Sep 2025 16:11:27 +0200 +Subject: [PATCH] test: store and compare just the property value + +Follow-up for 5730a400fd5ee82566fe03eb832121a0d4bc26b6. + +(cherry picked from commit 0cb252d50f35256bff569fa6213784f2d45ad6a1) + +Related: RHEL-118216 +--- + test/units/TEST-53-TIMER.restart-trigger.sh | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/test/units/TEST-53-TIMER.restart-trigger.sh b/test/units/TEST-53-TIMER.restart-trigger.sh +index 057f379ddc..e5cd575d66 100755 +--- a/test/units/TEST-53-TIMER.restart-trigger.sh ++++ b/test/units/TEST-53-TIMER.restart-trigger.sh +@@ -45,15 +45,15 @@ assert_eq "$(journalctl -q -p info --since="@$JOURNAL_TS" --unit="$UNIT_NAME" -- + + # Restarting the timer unit shouldn't trigger neither the timer nor the service, so these + # fields should remain constant through the following tests +-SERVICE_INV_ID="$(systemctl show --property=InvocationID "$UNIT_NAME.service")" +-TIMER_LAST_TRIGGER="$(systemctl show --property=LastTriggerUSec "$UNIT_NAME.timer")" ++SERVICE_INV_ID="$(systemctl show -P InvocationID "$UNIT_NAME.service")" ++TIMER_LAST_TRIGGER="$(systemctl show -P LastTriggerUSec "$UNIT_NAME.timer")" + + # Now restart the timer and check if the timer and the service weren't triggered again + systemctl restart "$UNIT_NAME.timer" + sleep 5 + assert_eq "$(journalctl -q -p info --since="@$JOURNAL_TS" --unit="$UNIT_NAME" --grep="$TEST_MESSAGE" | wc -l)" "1" +-assert_eq "$SERVICE_INV_ID" "$(systemctl show --property=InvocationID "$UNIT_NAME.service")" +-assert_eq "$TIMER_LAST_TRIGGER" "$(systemctl show --property=LastTriggerUSec "$UNIT_NAME.timer")" ++assert_eq "$SERVICE_INV_ID" "$(systemctl show -P InvocationID "$UNIT_NAME.service")" ++assert_eq "$TIMER_LAST_TRIGGER" "$(systemctl show -P LastTriggerUSec "$UNIT_NAME.timer")" + + # Set the timer into the past, restart it, and again check if it wasn't triggered + TIMER_TS="$(date --date="-1 day" "+%Y-%m-%d %H:%M:%S")" +@@ -68,8 +68,8 @@ assert_in "OnCalendar=$TIMER_TS" "$(systemctl show -P TimersCalendar "$UNIT_NAME + systemctl restart "$UNIT_NAME.timer" + sleep 5 + assert_eq "$(journalctl -q -p info --since="@$JOURNAL_TS" --unit="$UNIT_NAME" --grep="$TEST_MESSAGE" | wc -l)" "1" +-assert_eq "$SERVICE_INV_ID" "$(systemctl show --property=InvocationID "$UNIT_NAME.service")" +-assert_eq "$TIMER_LAST_TRIGGER" "$(systemctl show --property=LastTriggerUSec "$UNIT_NAME.timer")" ++assert_eq "$SERVICE_INV_ID" "$(systemctl show -P InvocationID "$UNIT_NAME.service")" ++assert_eq "$TIMER_LAST_TRIGGER" "$(systemctl show -P LastTriggerUSec "$UNIT_NAME.timer")" + + # Cleanup + systemctl stop "$UNIT_NAME".{timer,service} diff --git a/systemd.spec b/systemd.spec index 03f21f7..b378bce 100644 --- a/systemd.spec +++ b/systemd.spec @@ -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: 15%{?dist} +Release: 16%{?dist} %global stable %(c="%version"; [ "$c" = "${c#*.*}" ]; echo $?) @@ -557,6 +557,11 @@ Patch0444: 0444-coredump-drop-RestrictSUIDSGID-option-38640.patch Patch0445: 0445-ukify-fix-insertion-of-padding-in-merged-sections.patch Patch0446: 0446-core-introduce-Unit.dependency_generation-counter-an.patch Patch0447: 0447-core-unit-use-UNIT_FOREACH_DEPENDENCY_SAFE-at-severa.patch +Patch0448: 0448-test-rename-TEST-53-ISSUE-16347-to-TEST-53-TIMER.patch +Patch0449: 0449-test-restarting-elapsed-timer-shouldn-t-trigger-the-.patch +Patch0450: 0450-test-check-the-next-elapse-timer-timestamp-after-des.patch +Patch0451: 0451-timer-don-t-run-service-immediately-after-restart-of.patch +Patch0452: 0452-test-store-and-compare-just-the-property-value.patch # Downstream-only patches (9000–9999) %endif @@ -1503,6 +1508,13 @@ rm -f .file-list-* rm -f %{name}.lang %changelog +* Thu Oct 02 2025 systemd maintenance team - 257-16 +- test: rename TEST-53-ISSUE-16347 to TEST-53-TIMER (RHEL-118216) +- test: restarting elapsed timer shouldn't trigger the corresponding service (RHEL-118216) +- test: check the next elapse timer timestamp after deserialization (RHEL-118216) +- timer: don't run service immediately after restart of a timer (RHEL-118216) +- test: store and compare just the property value (RHEL-118216) + * Mon Sep 29 2025 systemd maintenance team - 257-15 - coredump: drop RestrictSUIDSGID= option (#38640) (RHEL-113920) - ukify: fix insertion of padding in merged sections (RHEL-114414)