From: Armaan Sandhu Date: Sat, 13 Jun 2026 09:25:12 +0000 (+0530) Subject: sysupdate: address review feedback on component/reboot guard X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19e40a6de9594ccc0f69353092d7ac266d833ed3;p=thirdparty%2Fsystemd.git sysupdate: address review feedback on component/reboot guard 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. --- diff --git a/src/sysupdate/sysupdate.c b/src/sysupdate/sysupdate.c index 8acf37fad1a..cd5850bd38d 100644 --- a/src/sysupdate/sysupdate.c +++ b/src/sysupdate/sysupdate.c @@ -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."); diff --git a/test/units/TEST-72-SYSUPDATE.sh b/test/units/TEST-72-SYSUPDATE.sh index 79a49efa2f5..dc2b3fbb648 100755 --- a/test/units/TEST-72-SYSUPDATE.sh +++ b/test/units/TEST-72-SYSUPDATE.sh @@ -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