Skip to content

Commit

Permalink
efi: If no EFI variables, don't try to change EFI boot order
Browse files Browse the repository at this point in the history
We can't do anything if the EFI state is immutable.

xref containers/bootc#291

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Feb 1, 2024
1 parent fa9924e commit 6c3c95e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/efi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub(crate) const ESP_MOUNTS: &[&str] = &["boot/efi", "efi", "boot"];
const EFIBOOTMGR: &str = "efibootmgr";
const SHIM: &str = "shimx64.efi";

/// The directory for EFI variables.
const EFIVARS: &str = "/sys/firmware/efi/vars";

/// The ESP partition label on Fedora CoreOS derivatives
pub(crate) const COREOS_ESP_PART_LABEL: &str = "EFI-SYSTEM";
pub(crate) const ANACONDA_ESP_PART_LABEL: &str = "EFI\\x20System\\x20Partition";
Expand Down Expand Up @@ -132,6 +135,15 @@ impl Efi {
log::debug!("Not booted via EFI, skipping firmware update");
return Ok(());
}

if !Path::new(EFIVARS)
.try_exists()
.context("Checking EFI variables")?
{
log::debug!("No EFI variables on this system");
return Ok(());
}

let efidir = &espdir.sub_dir("EFI").context("Opening EFI")?;
let vendordir = super::grubconfigs::find_efi_vendordir(efidir)?;
let vendordir = vendordir
Expand Down

0 comments on commit 6c3c95e

Please sign in to comment.