diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index f991e30cf..8ce0aaac2 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -937,12 +937,14 @@ static int help(void) { static const char *arg_path = "/boot"; static bool arg_touch_variables = true; +static bool arg_force = false; static int parse_argv(int argc, char *argv[]) { enum { ARG_PATH = 0x100, ARG_VERSION, ARG_NO_VARIABLES, + ARG_FORCE, }; static const struct option options[] = { @@ -950,6 +952,7 @@ static int parse_argv(int argc, char *argv[]) { { "version", no_argument, NULL, ARG_VERSION }, { "path", required_argument, NULL, ARG_PATH }, { "no-variables", no_argument, NULL, ARG_NO_VARIABLES }, + { "force", no_argument, NULL, ARG_FORCE }, { NULL, 0, NULL, 0 } }; @@ -975,6 +978,9 @@ static int parse_argv(int argc, char *argv[]) { case ARG_NO_VARIABLES: arg_touch_variables = false; break; + case ARG_FORCE: + arg_force = true; + break; case '?': return -EINVAL; @@ -1034,10 +1040,13 @@ static int bootctl_main(int argc, char*argv[]) { if (geteuid() != 0) return log_error_errno(EPERM, "Need to be root."); + if (arg_force && arg_action < ACTION_INSTALL) + return log_error_errno(EINVAL, "Can only force install, update or remove operations"); + r = verify_esp(arg_path, &part, &pstart, &psize, &uuid); if (r == -ENODEV && !arg_path) log_notice("You might want to use --path= to indicate the path to your ESP, in case it is not mounted on /boot."); - if (r < 0) + if (r < 0 && !arg_force) return r; switch (arg_action) { @@ -1110,7 +1119,7 @@ static int bootctl_main(int argc, char*argv[]) { return r; } - if (arg_touch_variables) + if (arg_touch_variables && !arg_force) r = install_variables(arg_path, part, pstart, psize, uuid, "/EFI/systemd/systemd-boot" EFI_MACHINE_TYPE_NAME ".efi", @@ -1120,7 +1129,7 @@ static int bootctl_main(int argc, char*argv[]) { case ACTION_REMOVE: r = remove_binaries(arg_path); - if (arg_touch_variables) { + if (arg_touch_variables && !arg_force) { q = remove_variables(uuid, "/EFI/systemd/systemd-boot" EFI_MACHINE_TYPE_NAME ".efi", true); if (q < 0 && r == 0) r = q;