Skip to content

Commit 1020a04

Browse files
committed
fix: do not emit a temporary initrd location if it's not needed
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.
1 parent 31d72b2 commit 1020a04

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

rust/tool/systemd/src/install.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,27 @@ impl<S: LanzabooteSigner> Installer<S> {
210210
.context("Failed to install the kernel.")?;
211211

212212
// Assemble and install the initrd, and record its path on the ESP.
213-
let initrd_location = tempdir
214-
.write_secure_file(
215-
fs::read(
216-
bootspec
217-
.initrd
218-
.as_ref()
219-
.context("Lanzaboote does not support missing initrd yet.")?,
213+
// It is not needed to write the initrd in a temporary directory
214+
// if we do not have any initrd secret.
215+
let initrd_location = if bootspec.initrd_secrets.is_some() {
216+
tempdir
217+
.write_secure_file(
218+
fs::read(
219+
bootspec
220+
.initrd
221+
.as_ref()
222+
.context("Lanzaboote does not support missing initrd yet.")?,
223+
)
224+
.context("Failed to read the initrd.")?,
220225
)
221-
.context("Failed to read the initrd.")?,
222-
)
223-
.context("Failed to copy the initrd to the temporary directory.")?;
226+
.context("Failed to copy the initrd to the temporary directory.")?
227+
} else {
228+
bootspec
229+
.initrd
230+
.clone()
231+
.expect("Lanzaboote does not support missing initrd yet.")
232+
};
233+
224234
if let Some(initrd_secrets_script) = &bootspec.initrd_secrets {
225235
append_initrd_secrets(initrd_secrets_script, &initrd_location, generation.version)?;
226236
}

0 commit comments

Comments
 (0)