From 7b8cc0c9d4a1b2e35afed3fbdee4307e5c6ab043 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Mon, 3 Aug 2020 20:48:50 -0400 Subject: [PATCH] Fixes a panic() during mkimage --- citadel-tool/src/mkimage/build.rs | 3 +-- libcitadel/src/verity.rs | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/citadel-tool/src/mkimage/build.rs b/citadel-tool/src/mkimage/build.rs index 214fab1..b2ae638 100644 --- a/citadel-tool/src/mkimage/build.rs +++ b/citadel-tool/src/mkimage/build.rs @@ -123,8 +123,7 @@ impl UpdateBuilder { let hashfile = self.config.workdir_path(self.verity_filename()); let outfile = self.config.workdir_path("verity-format.out"); - let verity = Verity::new(self.image())?; - let output = verity.generate_initial_hashtree(&hashfile)?; + let output = Verity::generate_initial_hashtree(self.image(), &hashfile)?; if let Err(err) = fs::write(outfile, output.output()) { bail!("Failed to write veritysetup command output to a file: {}", err); diff --git a/libcitadel/src/verity.rs b/libcitadel/src/verity.rs index 1980f25..64796bd 100644 --- a/libcitadel/src/verity.rs +++ b/libcitadel/src/verity.rs @@ -24,10 +24,11 @@ impl Verity { }) } - pub fn generate_initial_hashtree(&self, output: impl AsRef) -> Result { + pub fn generate_initial_hashtree(image: impl AsRef, output: impl AsRef) -> Result { + let image = image.as_ref(); let output = output.as_ref(); // Don't use absolute path to veritysetup so that the build will correctly find the version from cryptsetup-native - let output = cmd_with_output!("veritysetup", "format {} {}", self.path_str(), output.display())?; + let output = cmd_with_output!("veritysetup", "format {:?} {}", image.display(), output.display())?; Ok(VerityOutput::parse(&output)) } @@ -114,10 +115,6 @@ impl Verity { fn path(&self) -> &Path { &self.image } - - fn path_str(&self) -> &str { - self.image.to_str().unwrap() - } } /// The output from the `veritysetup format` command can be parsed as key/value