]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysupdate: address review feedback on component/reboot guard 42578/head
authorArmaan Sandhu <armaan.sandhu0504@gmail.com>
Sat, 13 Jun 2026 09:25:12 +0000 (14:55 +0530)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 19 Jun 2026 18:52:24 +0000 (19:52 +0100)
Move the --reboot/--component= rejection into parse_argv() alongside the
other cross-option checks, and tighten TEST-72 to assert the specific
guard message rather than merely a non-zero exit.

src/sysupdate/sysupdate.c
test/units/TEST-72-SYSUPDATE.sh

index 8acf37fad1a9bf66d8be600fb50d1223914a9e64..cd5850bd38dcc2a061ef698534ef33a552dd5117 100644 (file)
@@ -1555,10 +1555,6 @@ 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 */
 
@@ -2023,6 +2019,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
         if ((arg_image || arg_root) && arg_reboot)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "The --reboot switch may not be combined with --root= or --image=.");
 
+        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_definitions && arg_component)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "The --definitions= and --component= switches may not be combined.");
 
index 79a49efa2f5d67cb27aa6b82e5938a92757e06bf..dc2b3fbb6482d2b48e100e64116155e9fc7e7af0 100755 (executable)
@@ -584,9 +584,9 @@ mkdir /run/sysupdate.d
 # 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)
+(! "$SYSUPDATE" --component=some-component pending) |& grep -F 'may not be combined' >/dev/null
+(! "$SYSUPDATE" --component=some-component reboot) |& grep -F 'may not be combined' >/dev/null
+(! "$SYSUPDATE" --component=some-component update --reboot) |& grep -F 'may not be combined' >/dev/null
 
 # Clean up regression test
 rmdir /run/sysupdate.d