forked from brl/citadel-tools
Don't pass config file around, it's a lazy_static now
This commit is contained in:
parent
434c19433e
commit
b59188311d
@ -1,5 +1,5 @@
|
||||
|
||||
use libcitadel::{Config,Partition,Result,ImageHeader};
|
||||
use libcitadel::{Partition,Result,ImageHeader};
|
||||
|
||||
pub struct BootSelection {
|
||||
partitions: Vec<Partition>,
|
||||
@ -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(())
|
||||
}
|
||||
|
||||
|
@ -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(())
|
||||
}
|
||||
|
@ -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)?;
|
||||
}
|
||||
|
@ -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<PathBuf> {
|
||||
pub fn setup_verity_device(&self) -> Result<PathBuf> {
|
||||
if !CommandLine::nosignatures() {
|
||||
self.header.verify_signature(config)?;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user