Skip to content

Commit

Permalink
fix: do not emit a temporary initrd location if it's not needed
Browse files Browse the repository at this point in the history
We fabricated a lot of initrds which were exactly the same as the one in
our store when we had no initrd secrets. This ends this practice.
  • Loading branch information
RaitoBezarius committed Jan 25, 2024
1 parent 31d72b2 commit 1020a04
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions rust/tool/systemd/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,27 @@ impl<S: LanzabooteSigner> Installer<S> {
.context("Failed to install the kernel.")?;

// Assemble and install the initrd, and record its path on the ESP.
let initrd_location = tempdir
.write_secure_file(
fs::read(
bootspec
.initrd
.as_ref()
.context("Lanzaboote does not support missing initrd yet.")?,
// It is not needed to write the initrd in a temporary directory
// if we do not have any initrd secret.
let initrd_location = if bootspec.initrd_secrets.is_some() {
tempdir
.write_secure_file(
fs::read(
bootspec
.initrd
.as_ref()
.context("Lanzaboote does not support missing initrd yet.")?,
)
.context("Failed to read the initrd.")?,
)
.context("Failed to read the initrd.")?,
)
.context("Failed to copy the initrd to the temporary directory.")?;
.context("Failed to copy the initrd to the temporary directory.")?
} else {
bootspec
.initrd
.clone()
.expect("Lanzaboote does not support missing initrd yet.")
};

if let Some(initrd_secrets_script) = &bootspec.initrd_secrets {
append_initrd_secrets(initrd_secrets_script, &initrd_location, generation.version)?;
}
Expand Down

0 comments on commit 1020a04

Please sign in to comment.