bootctl: override is_efi_boot() check by --variables= option (#40413)
Fixes #40392.
This commit is contained in:
@@ -38,38 +38,51 @@ static int status_entries(
|
||||
|
||||
printf("%sBoot Loader Entry Locations:%s\n", ansi_underline(), ansi_normal());
|
||||
|
||||
printf(" ESP: %s (", esp_path);
|
||||
if (!sd_id128_is_null(esp_partition_uuid))
|
||||
printf("/dev/disk/by-partuuid/" SD_ID128_UUID_FORMAT_STR "",
|
||||
bool need_paren = false;
|
||||
printf(" ESP: %s", esp_path);
|
||||
if (!sd_id128_is_null(esp_partition_uuid)) {
|
||||
printf(" (/dev/disk/by-partuuid/" SD_ID128_UUID_FORMAT_STR "",
|
||||
SD_ID128_FORMAT_VAL(esp_partition_uuid));
|
||||
if (!xbootldr_path)
|
||||
need_paren = true;
|
||||
}
|
||||
if (!xbootldr_path) {
|
||||
if (!need_paren) {
|
||||
fputs(" (", stdout);
|
||||
need_paren = true;
|
||||
} else
|
||||
fputs(", ", stdout);
|
||||
|
||||
/* ESP is $BOOT if XBOOTLDR not present. */
|
||||
printf(", %s$BOOT%s", ansi_green(), ansi_normal());
|
||||
printf(")");
|
||||
printf("%s$BOOT%s", ansi_green(), ansi_normal());
|
||||
}
|
||||
if (need_paren)
|
||||
putchar(')');
|
||||
putchar('\n');
|
||||
|
||||
if (config->loader_conf_status != 0) {
|
||||
assert(esp_path);
|
||||
printf("\n config: %s%s/%s%s",
|
||||
printf(" config: %s%s/%s%s",
|
||||
ansi_grey(), esp_path, ansi_normal(), "/loader/loader.conf");
|
||||
if (config->loader_conf_status < 0)
|
||||
printf(": %s%s%s",
|
||||
config->loader_conf_status == -ENOENT ? ansi_grey() : ansi_highlight_yellow(),
|
||||
STRERROR(config->loader_conf_status),
|
||||
ansi_normal());
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
if (xbootldr_path) {
|
||||
printf("\n XBOOTLDR: %s (", xbootldr_path);
|
||||
printf(" XBOOTLDR: %s (", xbootldr_path);
|
||||
if (!sd_id128_is_null(xbootldr_partition_uuid))
|
||||
printf("/dev/disk/by-partuuid/" SD_ID128_UUID_FORMAT_STR ", ",
|
||||
SD_ID128_FORMAT_VAL(xbootldr_partition_uuid));
|
||||
/* XBOOTLDR is always $BOOT if present. */
|
||||
printf("%s$BOOT%s)", ansi_green(), ansi_normal());
|
||||
printf("%s$BOOT%s)\n", ansi_green(), ansi_normal());
|
||||
}
|
||||
|
||||
if (settle_entry_token() >= 0)
|
||||
printf("\n token: %s", arg_entry_token);
|
||||
printf("\n\n");
|
||||
printf(" token: %s\n", arg_entry_token);
|
||||
putchar('\n');
|
||||
|
||||
if (config->default_entry < 0)
|
||||
printf("%zu entries, no entry could be determined as default.\n", config->n_entries);
|
||||
@@ -318,6 +331,8 @@ int verb_status(int argc, char *argv[], void *userdata) {
|
||||
dev_t esp_devid = 0, xbootldr_devid = 0;
|
||||
int r, k;
|
||||
|
||||
bool has_efi = touch_variables();
|
||||
|
||||
r = acquire_esp(/* unprivileged_mode= */ -1,
|
||||
/* graceful= */ false,
|
||||
/* ret_part= */ NULL,
|
||||
@@ -359,13 +374,14 @@ int verb_status(int argc, char *argv[], void *userdata) {
|
||||
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (arg_root)
|
||||
log_debug("Skipping 'System' section, operating offline.");
|
||||
else if (!is_efi_boot())
|
||||
printf("%sSystem:%s\n"
|
||||
"Not booted with EFI\n\n",
|
||||
ansi_underline(), ansi_normal());
|
||||
else {
|
||||
if (!has_efi) {
|
||||
if (arg_root)
|
||||
log_debug("Skipping 'System' section, operating offline.");
|
||||
else
|
||||
printf("%sSystem:%s\n"
|
||||
"Not booted with EFI\n\n",
|
||||
ansi_underline(), ansi_normal());
|
||||
} else {
|
||||
static const struct {
|
||||
uint64_t flag;
|
||||
const char *name;
|
||||
@@ -584,7 +600,7 @@ int verb_status(int argc, char *argv[], void *userdata) {
|
||||
if (arg_esp_path)
|
||||
RET_GATHER(r, status_binaries(arg_esp_path, esp_uuid));
|
||||
|
||||
if (!arg_root && is_efi_boot())
|
||||
if (has_efi)
|
||||
RET_GATHER(r, status_variables());
|
||||
|
||||
if (arg_esp_path || arg_xbootldr_path) {
|
||||
@@ -615,6 +631,8 @@ int verb_list(int argc, char *argv[], void *userdata) {
|
||||
* Here we're interested in the latter but not the former, hence request the mode, and log about
|
||||
* EACCES. */
|
||||
|
||||
(void) touch_variables();
|
||||
|
||||
r = acquire_esp(/* unprivileged_mode= */ -1, /* graceful= */ false, NULL, NULL, NULL, NULL, &esp_devid);
|
||||
if (r == -EACCES) /* We really need the ESP path for this call, hence also log about access errors */
|
||||
return log_error_errno(r, "Failed to determine ESP location: %m");
|
||||
|
||||
Reference in New Issue
Block a user