mirror of
https://github.com/systemd/systemd.git
synced 2024-11-06 08:26:52 +03:00
bootctl: try to catch all errors
Do not print garbage on non-EFI installations.
This commit is contained in:
parent
d3226d7796
commit
551710cf2e
@ -988,6 +988,14 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void read_loader_efi_var(const char *name, char **var) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = efi_get_variable_string(EFI_VENDOR_LOADER, name, var);
|
||||||
|
if (r < 0 && r != -ENOENT)
|
||||||
|
log_warning_errno(r, "Failed to read EFI variable %s: %m", name);
|
||||||
|
}
|
||||||
|
|
||||||
static int bootctl_main(int argc, char*argv[]) {
|
static int bootctl_main(int argc, char*argv[]) {
|
||||||
enum action {
|
enum action {
|
||||||
ACTION_STATUS,
|
ACTION_STATUS,
|
||||||
@ -1042,28 +1050,44 @@ static int bootctl_main(int argc, char*argv[]) {
|
|||||||
_cleanup_free_ char *loader_path = NULL;
|
_cleanup_free_ char *loader_path = NULL;
|
||||||
sd_id128_t loader_part_uuid = {};
|
sd_id128_t loader_part_uuid = {};
|
||||||
|
|
||||||
efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderFirmwareType", &fw_type);
|
if (is_efi_boot()) {
|
||||||
efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderFirmwareInfo", &fw_info);
|
read_loader_efi_var("LoaderFirmwareType", &fw_type);
|
||||||
efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderInfo", &loader);
|
read_loader_efi_var("LoaderFirmwareInfo", &fw_info);
|
||||||
if (efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderImageIdentifier", &loader_path) > 0)
|
read_loader_efi_var("LoaderInfo", &loader);
|
||||||
efi_tilt_backslashes(loader_path);
|
read_loader_efi_var("LoaderImageIdentifier", &loader_path);
|
||||||
efi_loader_get_device_part_uuid(&loader_part_uuid);
|
if (loader_path)
|
||||||
|
efi_tilt_backslashes(loader_path);
|
||||||
|
r = efi_loader_get_device_part_uuid(&loader_part_uuid);
|
||||||
|
if (r < 0 && r == -ENOENT)
|
||||||
|
log_warning_errno(r, "Failed to read EFI variable LoaderDevicePartUUID: %m");
|
||||||
|
|
||||||
printf("System:\n");
|
printf("System:\n");
|
||||||
printf(" Firmware: %s (%s)\n", fw_type, strna(fw_info));
|
printf(" Firmware: %s (%s)\n", strna(fw_type), strna(fw_info));
|
||||||
printf(" Secure Boot: %s\n", is_efi_secure_boot() ? "enabled" : "disabled");
|
|
||||||
printf(" Setup Mode: %s\n", is_efi_secure_boot_setup_mode() ? "setup" : "user");
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("Loader:\n");
|
r = is_efi_secure_boot();
|
||||||
printf(" Product: %s\n", strna(loader));
|
if (r < 0)
|
||||||
if (!sd_id128_equal(loader_part_uuid, SD_ID128_NULL))
|
log_warning_errno(r, "Failed to query secure boot status: %m");
|
||||||
printf(" Partition: /dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
|
else
|
||||||
SD_ID128_FORMAT_VAL(loader_part_uuid));
|
printf(" Secure Boot: %s\n", r ? "enabled" : "disabled");
|
||||||
else
|
|
||||||
printf(" Partition: n/a\n");
|
r = is_efi_secure_boot_setup_mode();
|
||||||
printf(" File: %s%s\n", draw_special_char(DRAW_TREE_RIGHT), strna(loader_path));
|
if (r < 0)
|
||||||
printf("\n");
|
log_warning_errno(r, "Failed to query secure boot mode: %m");
|
||||||
|
else
|
||||||
|
printf(" Setup Mode: %s\n", r ? "setup" : "user");
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
printf("Loader:\n");
|
||||||
|
printf(" Product: %s\n", strna(loader));
|
||||||
|
if (!sd_id128_equal(loader_part_uuid, SD_ID128_NULL))
|
||||||
|
printf(" Partition: /dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
|
||||||
|
SD_ID128_FORMAT_VAL(loader_part_uuid));
|
||||||
|
else
|
||||||
|
printf(" Partition: n/a\n");
|
||||||
|
printf(" File: %s%s\n", draw_special_char(DRAW_TREE_RIGHT), strna(loader_path));
|
||||||
|
printf("\n");
|
||||||
|
} else
|
||||||
|
printf("System:\n Not booted with EFI\n");
|
||||||
|
|
||||||
r = status_binaries(arg_path, uuid);
|
r = status_binaries(arg_path, uuid);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user