efivars: check whether we are booted with EFI before reading/writing to variables
We do these checks only for the high-level calls as for the low-level ones it might make sense in some exotic uses to read the host EFI data from a container or so.
This commit is contained in:
@@ -41,7 +41,7 @@ static int test_efi_loader(void) {
|
||||
|
||||
r = efi_loader_get_boot_usec(&loader_start, &loader_exit);
|
||||
if (r < 0) {
|
||||
bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES);
|
||||
bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES) || r == -EOPNOTSUPP;
|
||||
|
||||
log_full_errno(ok ? LOG_DEBUG : LOG_ERR,
|
||||
r, "Failed to read EFI loader data: %m");
|
||||
@@ -64,7 +64,7 @@ static int test_boot_timestamps(void) {
|
||||
|
||||
r = boot_timestamps(NULL, &fw, &l);
|
||||
if (r < 0) {
|
||||
bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES);
|
||||
bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES) || r == -EOPNOTSUPP;
|
||||
|
||||
log_full_errno(ok ? LOG_DEBUG : LOG_ERR,
|
||||
r, "Failed to read variables: %m");
|
||||
|
||||
Reference in New Issue
Block a user