bootctl: override is_efi_boot() check by --variables= option (#40413)
Fixes #40392.
This commit is contained in:
+7
-25
@@ -145,8 +145,8 @@ int acquire_xbootldr(
|
||||
int r;
|
||||
|
||||
r = find_xbootldr_and_warn(arg_root, arg_xbootldr_path, unprivileged_mode, &np, ret_uuid, ret_devid);
|
||||
if (r == -ENOKEY) {
|
||||
log_debug_errno(r, "Didn't find an XBOOTLDR partition, using the ESP as $BOOT.");
|
||||
if (r == -ENOKEY || path_equal(np, arg_esp_path)) {
|
||||
log_debug("Didn't find an XBOOTLDR partition, using the ESP as $BOOT.");
|
||||
arg_xbootldr_path = mfree(arg_xbootldr_path);
|
||||
|
||||
if (ret_uuid)
|
||||
@@ -229,29 +229,6 @@ static int print_loader_or_stub_path(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool touch_variables(void) {
|
||||
/* If we run in a container or on a non-EFI system, automatically turn off EFI file system access,
|
||||
* unless explicitly overridden. */
|
||||
|
||||
if (arg_touch_variables >= 0)
|
||||
return arg_touch_variables;
|
||||
|
||||
if (arg_root) {
|
||||
log_once(LOG_NOTICE,
|
||||
"Operating on %s, skipping EFI variable modifications.",
|
||||
arg_image ? "image" : "root directory");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_efi_boot()) { /* NB: this internally checks if we run in a container */
|
||||
log_once(LOG_NOTICE,
|
||||
"Not booted with EFI or running in a container, skipping EFI variable modifications.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GracefulMode arg_graceful(void) {
|
||||
static bool chroot_checked = false;
|
||||
|
||||
@@ -524,6 +501,11 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
r = parse_tristate_argument_with_auto("--variables=", optarg, &arg_touch_variables);
|
||||
if (r < 0)
|
||||
return r;
|
||||
#if !ENABLE_EFI
|
||||
if (arg_touch_variables > 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Compiled without support for EFI, --variables=%s cannot be specified.", optarg);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ARG_NO_VARIABLES:
|
||||
|
||||
Reference in New Issue
Block a user