]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
factory-reset-tool: error out if we can't cancel pending reset
authorMike Yuan <me@yhndnzj.com>
Wed, 5 Mar 2025 16:01:04 +0000 (17:01 +0100)
committerMike Yuan <me@yhndnzj.com>
Wed, 5 Mar 2025 16:17:21 +0000 (17:17 +0100)
First of all, it seems very unlikely that we'd be in the pending state
if not booted via EFI in the first place. Moreover, the operation didn't
work out, hence let's not spurious report success.

src/factory-reset/factory-reset-tool.c

index 8bf573460114de6e78609575d2e27ae7e4f855dc..bfb1a8d26fefcd8bf8b51e48db5c7e3598757161 100644 (file)
@@ -209,12 +209,9 @@ static int verb_cancel(int argc, char *argv[], void *userdata) {
                 return 0;
         }
 
-        if (!is_efi_boot()) {
-                if (!arg_quiet)
-                        log_info("Not an EFI boot, cannot remove FactoryResetMode EFI variable, not cancelling.");
-
-                return 0;
-        }
+        if (!is_efi_boot())
+                return log_error_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE),
+                                       "Not an EFI boot, cannot remove FactoryResetMode EFI variable, not cancelling.");
 
         r = efi_set_variable(EFI_SYSTEMD_VARIABLE_STR("FactoryResetRequest"), /* value= */ NULL, /* size= */ 0);
         if (r < 0)