From b59188311d658526098a52ad9e33192895cfd5f7 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Sat, 5 Jan 2019 20:34:22 -0500 Subject: [PATCH] Don't pass config file around, it's a lazy_static now --- citadel-mount/src/boot_select.rs | 12 +++++------- citadel-mount/src/main.rs | 28 ++++++++++------------------ libcitadel/src/partition.rs | 6 +++--- libcitadel/src/resource.rs | 8 ++++---- 4 files changed, 22 insertions(+), 32 deletions(-) diff --git a/citadel-mount/src/boot_select.rs b/citadel-mount/src/boot_select.rs index 2eba546..3807fda 100644 --- a/citadel-mount/src/boot_select.rs +++ b/citadel-mount/src/boot_select.rs @@ -1,5 +1,5 @@ -use libcitadel::{Config,Partition,Result,ImageHeader}; +use libcitadel::{Partition,Result,ImageHeader}; pub struct BootSelection { partitions: Vec, @@ -62,9 +62,9 @@ impl BootSelection { /// Perform checks for error states at boot time. - pub fn scan_boot_partitions(&mut self, config: &Config) -> Result<()> { + pub fn scan_boot_partitions(&mut self) -> Result<()> { for mut p in &mut self.partitions { - if let Err(e) = boot_scan_partition(&mut p, config) { + if let Err(e) = boot_scan_partition(&mut p) { warn!("error in bootscan of partition {}: {}", p.path().display(), e); } } @@ -82,7 +82,7 @@ impl BootSelection { /// Verify metainfo signature and mark `STATUS_BAD_SIG` if /// signature verification fails. /// -fn boot_scan_partition(p: &mut Partition, config: &Config) -> Result<()> { +fn boot_scan_partition(p: &mut Partition) -> Result<()> { if !p.is_initialized() { return Ok(()) } @@ -90,9 +90,7 @@ fn boot_scan_partition(p: &mut Partition, config: &Config) -> Result<()> { warn!("Partition {} has STATUS_TRY_BOOT, assuming it failed boot attempt and marking STATUS_FAILED", p.path().display()); p.write_status(ImageHeader::STATUS_FAILED)?; } - let signature = p.header().signature(); - p.metainfo().verify(config, &signature)?; - + p.header().verify_signature()?; Ok(()) } diff --git a/citadel-mount/src/main.rs b/citadel-mount/src/main.rs index 94461b6..1a6947b 100644 --- a/citadel-mount/src/main.rs +++ b/citadel-mount/src/main.rs @@ -6,7 +6,7 @@ extern crate libc; use std::process::exit; use std::env; -use libcitadel::{Result,Config,CommandLine,set_verbose,format_error,ResourceImage}; +use libcitadel::{Result,CommandLine,set_verbose,format_error,ResourceImage}; mod boot_select; @@ -38,20 +38,12 @@ fn main() { set_verbose(true); } - let config = match Config::load_default() { - Ok(config) => config, - Err(err) => { - warn!("{}", err); - exit(1); - }, - }; - let mut args = env::args(); args.next(); let result = match args.next() { - Some(ref s) if s == "rootfs" => mount_rootfs(config), - Some(ref s) if s == "modules" => mount_modules(config), - Some(ref s) if s == "extra" => mount_extra(config), + Some(ref s) if s == "rootfs" => mount_rootfs(), + Some(ref s) if s == "modules" => mount_modules(), + Some(ref s) if s == "extra" => mount_extra(), _ => Err(format_err!("Bad or missing argument")), }; @@ -61,22 +53,22 @@ fn main() { } } -fn mount_rootfs(config: Config) -> Result<()> { +fn mount_rootfs() -> Result<()> { info!("citadel-mount rootfs"); - let rootfs = Rootfs::new(config); + let rootfs = Rootfs::new(); rootfs.setup() } -fn mount_modules(config: Config) -> Result<()> { +fn mount_modules() -> Result<()> { info!("citadel-mount modules"); let mut image = ResourceImage::find("modules")?; - image.mount(&config)?; + image.mount()?; Ok(()) } -fn mount_extra(config: Config) -> Result<()> { +fn mount_extra() -> Result<()> { info!("citadel-mount extra"); let mut image = ResourceImage::find("extra")?; - image.mount(&config)?; + image.mount()?; Ok(()) } diff --git a/libcitadel/src/partition.rs b/libcitadel/src/partition.rs index 581d142..d88d347 100644 --- a/libcitadel/src/partition.rs +++ b/libcitadel/src/partition.rs @@ -1,6 +1,6 @@ use std::path::{Path,PathBuf}; use std::fs; -use {Config,CommandLine,Result,ImageHeader,MetaInfo,Mount}; +use {CommandLine,Result,ImageHeader,MetaInfo,Mount}; #[derive(Clone)] pub struct Partition { @@ -109,7 +109,7 @@ impl Partition { /// Verify metainfo signature and mark `STATUS_BAD_SIG` if /// signature verification fails. /// - pub fn boot_scan(&mut self, config: &Config) -> Result<()> { + pub fn boot_scan(&mut self) -> Result<()> { if !self.is_initialized() { return Ok(()) } @@ -118,7 +118,7 @@ impl Partition { } if !CommandLine::nosignatures() { - if let Err(e) = self.header().verify_signature(config) { + if let Err(e) = self.header().verify_signature() { warn!("Signature verification failed on partition: {}", e); self.write_status(ImageHeader::STATUS_BAD_SIG)?; } diff --git a/libcitadel/src/resource.rs b/libcitadel/src/resource.rs index 66dd921..7d0fa45 100644 --- a/libcitadel/src/resource.rs +++ b/libcitadel/src/resource.rs @@ -3,7 +3,7 @@ use std::ffi::OsStr; use std::io::{self,Seek,SeekFrom}; use std::path::{Path, PathBuf}; -use {CommandLine,Config,ImageHeader,MetaInfo,Result,Partition,Mount,verity,util}; +use {CommandLine,ImageHeader,MetaInfo,Result,Partition,Mount,verity,util}; use failure::ResultExt; @@ -183,8 +183,8 @@ impl ResourceImage { Ok(()) } - fn mount_verity(&self, config: &Config) -> Result<()> { - let verity_dev = self.setup_verity_device(config)?; + fn mount_verity(&self) -> Result<()> { + let verity_dev = self.setup_verity_device()?; info!("Mounting dm-verity device to {}", self.mount_path().display()); @@ -194,7 +194,7 @@ impl ResourceImage { } - pub fn setup_verity_device(&self, config: &Config) -> Result { + pub fn setup_verity_device(&self) -> Result { if !CommandLine::nosignatures() { self.header.verify_signature(config)?; }