Disable reading SystemdOptions EFI Var when in SecureBoot mode
In SecureBoot mode this is probably not what you want. As your cmdline is cryptographically signed like when using Type #2 EFI Unified Kernel Images (https://systemd.io/BOOT_LOADER_SPECIFICATION/) The user's intention is then that the cmdline should not be modified. You want to make sure that the system starts up as exactly specified in the signed artifact.
This commit is contained in:
committed by
Lennart Poettering
parent
5c1a9ef088
commit
c7d26acce6
@@ -63,40 +63,6 @@ struct device_path device_path__contents;
|
||||
struct device_path__packed device_path__contents _packed_;
|
||||
assert_cc(sizeof(struct device_path) == sizeof(struct device_path__packed));
|
||||
|
||||
bool is_efi_boot(void) {
|
||||
if (detect_container() > 0)
|
||||
return false;
|
||||
|
||||
return access("/sys/firmware/efi/", F_OK) >= 0;
|
||||
}
|
||||
|
||||
static int read_flag(const char *varname) {
|
||||
_cleanup_free_ void *v = NULL;
|
||||
uint8_t b;
|
||||
size_t s;
|
||||
int r;
|
||||
|
||||
if (!is_efi_boot()) /* If this is not an EFI boot, assume the queried flags are zero */
|
||||
return 0;
|
||||
|
||||
r = efi_get_variable(EFI_VENDOR_GLOBAL, varname, NULL, &v, &s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (s != 1)
|
||||
return -EINVAL;
|
||||
|
||||
b = *(uint8_t *)v;
|
||||
return !!b;
|
||||
}
|
||||
|
||||
bool is_efi_secure_boot(void) {
|
||||
return read_flag("SecureBoot") > 0;
|
||||
}
|
||||
|
||||
bool is_efi_secure_boot_setup_mode(void) {
|
||||
return read_flag("SetupMode") > 0;
|
||||
}
|
||||
|
||||
int efi_reboot_to_firmware_supported(void) {
|
||||
_cleanup_free_ void *v = NULL;
|
||||
|
||||
Reference in New Issue
Block a user