Fixes a panic() during mkimage

This commit is contained in:
Bruce Leidl 2020-08-03 20:48:50 -04:00
parent 904765ae4f
commit 7b8cc0c9d4
2 changed files with 4 additions and 8 deletions

View File

@ -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);

View File

@ -24,10 +24,11 @@ impl Verity {
})
}
pub fn generate_initial_hashtree(&self, output: impl AsRef<Path>) -> Result<VerityOutput> {
pub fn generate_initial_hashtree(image: impl AsRef<Path>, output: impl AsRef<Path>) -> Result<VerityOutput> {
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