1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00

Merge pull request #7446 from poettering/efi-firmware-boot-fixes

logind efi boot-into-firmware fixes
This commit is contained in:
Lennart Poettering 2017-11-24 15:42:32 +01:00 committed by GitHub
commit 5f33279244
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 17 deletions

View File

@ -2397,7 +2397,7 @@ static int property_get_reboot_to_firmware_setup(
r = efi_get_reboot_to_firmware();
if (r < 0 && r != -EOPNOTSUPP)
return r;
log_warning_errno(r, "Failed to determine reboot-to-firmware state: %m");
return sd_bus_message_append(reply, "b", r > 0);
}
@ -2451,10 +2451,12 @@ static int method_can_reboot_to_firmware_setup(
assert(m);
r = efi_reboot_to_firmware_supported();
if (r == -EOPNOTSUPP)
if (r < 0) {
if (r != -EOPNOTSUPP)
log_warning_errno(errno, "Failed to determine whether reboot to firmware is supported: %m");
return sd_bus_reply_method_return(message, "s", "na");
else if (r < 0)
return r;
}
r = bus_test_polkit(message,
CAP_SYS_ADMIN,

View File

@ -85,10 +85,10 @@ bool is_efi_boot(void) {
}
static int read_flag(const char *varname) {
int r;
_cleanup_free_ void *v = NULL;
size_t s;
uint8_t b;
size_t s;
int r;
r = efi_get_variable(EFI_VENDOR_GLOBAL, varname, NULL, &v, &s);
if (r < 0)
@ -98,8 +98,7 @@ static int read_flag(const char *varname) {
return -EINVAL;
b = *(uint8_t *)v;
r = b > 0;
return r;
return b > 0;
}
bool is_efi_secure_boot(void) {
@ -111,29 +110,33 @@ bool is_efi_secure_boot_setup_mode(void) {
}
int efi_reboot_to_firmware_supported(void) {
int r;
size_t s;
uint64_t b;
_cleanup_free_ void *v = NULL;
uint64_t b;
size_t s;
int r;
if (!is_efi_boot() || detect_container() > 0)
return -EOPNOTSUPP;
r = efi_get_variable(EFI_VENDOR_GLOBAL, "OsIndicationsSupported", NULL, &v, &s);
if (r == -ENOENT) /* variable doesn't exist? it's not supported then */
return -EOPNOTSUPP;
if (r < 0)
return r;
else if (s != sizeof(uint64_t))
if (s != sizeof(uint64_t))
return -EINVAL;
b = *(uint64_t *)v;
b &= EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
return b > 0 ? 0 : -EOPNOTSUPP;
b = *(uint64_t*) v;
if (!(b & EFI_OS_INDICATIONS_BOOT_TO_FW_UI))
return -EOPNOTSUPP; /* bit unset? it's not supported then */
return 0;
}
static int get_os_indications(uint64_t *os_indication) {
int r;
size_t s;
_cleanup_free_ void *v = NULL;
size_t s;
int r;
r = efi_reboot_to_firmware_supported();
if (r < 0)