diff --git a/man/systemd-sysupdate.xml b/man/systemd-sysupdate.xml
index 1dea457e13..3abccb05e4 100644
--- a/man/systemd-sysupdate.xml
+++ b/man/systemd-sysupdate.xml
@@ -239,7 +239,9 @@
updated together in a synchronous fashion. Simply define multiple transfer files within the same
sysupdate.d/ directory for these cases.
- This option may not be combined with .
+ This option may not be combined with , nor with the
+ pending and reboot commands or the
+ switch, which only apply to the booted OS version.
@@ -314,7 +316,8 @@
When used in combination with the update commands and a new version is
- installed, automatically reboots the system immediately afterwards.
+ installed, automatically reboots the system immediately afterwards. This switch may not be combined with
+ , as it only applies to the booted OS version.
diff --git a/src/sysupdate/sysupdate.c b/src/sysupdate/sysupdate.c
index 92c40ddf71..8acf37fad1 100644
--- a/src/sysupdate/sysupdate.c
+++ b/src/sysupdate/sysupdate.c
@@ -1555,6 +1555,10 @@ static int verb_update_impl(int argc, char **argv, UpdateActionFlags action_flag
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"The --instances-max argument must be >= 2 while updating");
+ if (arg_reboot && arg_component)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "The --reboot switch may not be combined with --component=, as automatic reboots only apply to the booted OS version.");
+
if (arg_reboot) {
/* If automatic reboot on completion is requested, let's first determine the currently booted image */
@@ -1664,6 +1668,10 @@ static int verb_pending_or_reboot(int argc, char *argv[], uintptr_t _data, void
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"The --root=/--image= switches may not be combined with the '%s' operation.", argv[0]);
+ if (arg_component)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "The --component= switch may not be combined with the '%s' operation, which only applies to the booted OS version.", argv[0]);
+
r = context_make_offline(&context, /* node= */ NULL,
READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS | READ_DEFINITIONS_REQUIRES_ANY_TRANSFERS);
if (r < 0)
diff --git a/test/units/TEST-72-SYSUPDATE.sh b/test/units/TEST-72-SYSUPDATE.sh
index 749af71a06..79a49efa2f 100755
--- a/test/units/TEST-72-SYSUPDATE.sh
+++ b/test/units/TEST-72-SYSUPDATE.sh
@@ -579,6 +579,15 @@ EOF
mkdir /run/sysupdate.d
"$SYSUPDATE" --json=short components | grep -F '{"default":false,"components":["some-component"]}' >/dev/null
+# Regression test for https://github.com/systemd/systemd/issues/42330 — the
+# 'pending'/'reboot' verbs and the '--reboot' switch compare the newest installed
+# version against the booted OS version (IMAGE_VERSION= from os-release), which is
+# unrelated to component versions. Selecting a component must therefore be refused
+# rather than silently performing a bogus comparison.
+(! "$SYSUPDATE" --component=some-component pending)
+(! "$SYSUPDATE" --component=some-component reboot)
+(! "$SYSUPDATE" --component=some-component update --reboot)
+
# Clean up regression test
rmdir /run/sysupdate.d
rm -rf /run/sysupdate.some-component.d