fix lints
This commit is contained in:
parent
11c0ef4db8
commit
d6061c5dff
3 changed files with 97 additions and 103 deletions
|
@ -32,9 +32,9 @@ fn recurse_device_path(
|
||||||
|
|
||||||
match a.next {
|
match a.next {
|
||||||
Some(next) => {
|
Some(next) => {
|
||||||
return recurse_device_path(*next, uuid, path);
|
recurse_device_path(*next, uuid, path)
|
||||||
}
|
}
|
||||||
None => return (uuid, path),
|
None => (uuid, path),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
42
src/main.rs
42
src/main.rs
|
@ -7,6 +7,7 @@ mod find_mount_point;
|
||||||
mod hash;
|
mod hash;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::{self, BufReader};
|
use std::io::{self, BufReader};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -26,6 +27,7 @@ use crate::drop_ins::DropIns;
|
||||||
use crate::hash::*;
|
use crate::hash::*;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
enum Error {
|
enum Error {
|
||||||
#[error("error while parsing PE file: {0}")]
|
#[error("error while parsing PE file: {0}")]
|
||||||
PeParseError(#[from] object::Error),
|
PeParseError(#[from] object::Error),
|
||||||
|
@ -101,8 +103,7 @@ fn main() -> eyre::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
'measure_file: {
|
'measure_file: {
|
||||||
match event.event {
|
if event.event == EventType::EFIBootServicesApplication {
|
||||||
EventType::EFIBootServicesApplication => {
|
|
||||||
let event_data = match event.parsed_data {
|
let event_data = match event.parsed_data {
|
||||||
Some(event_data) => event_data,
|
Some(event_data) => event_data,
|
||||||
None => {
|
None => {
|
||||||
|
@ -133,15 +134,11 @@ fn main() -> eyre::Result<()> {
|
||||||
let windows_path = Utf8WindowsPathBuf::from(windows_path_str);
|
let windows_path = Utf8WindowsPathBuf::from(windows_path_str);
|
||||||
let unix_path = windows_path.with_encoding::<Utf8UnixEncoding>();
|
let unix_path = windows_path.with_encoding::<Utf8UnixEncoding>();
|
||||||
|
|
||||||
let esp;
|
let get_mnt = || {
|
||||||
|
|
||||||
'mnt: {
|
|
||||||
'get_mnt: {
|
|
||||||
let id = match uuid {
|
let id = match uuid {
|
||||||
Some(id) => id,
|
Some(id) => id,
|
||||||
None => {
|
None => {
|
||||||
eprintln!("uuid not in event log");
|
return Err(Cow::Borrowed("uuid not in event log"));
|
||||||
break 'get_mnt;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -150,30 +147,29 @@ fn main() -> eyre::Result<()> {
|
||||||
) {
|
) {
|
||||||
Ok(maybe_point) => maybe_point,
|
Ok(maybe_point) => maybe_point,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("error while looking up mount point: {err}");
|
return Err(Cow::Owned(format!(
|
||||||
break 'get_mnt;
|
"error while looking up mount point: {err}"
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match maybe_point {
|
match maybe_point {
|
||||||
Some(point) => {
|
Some(point) => Ok(point),
|
||||||
esp = point;
|
|
||||||
break 'mnt;
|
|
||||||
}
|
|
||||||
None => {
|
None => {
|
||||||
eprintln!("device not mounted");
|
return Err(Cow::Borrowed("device not mounted"));
|
||||||
break 'get_mnt;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// fallback
|
let esp = match get_mnt() {
|
||||||
eprintln!("couldn't find mount point, assuming \"/boot/efi\"");
|
Ok(v) => v,
|
||||||
esp = PathBuf::from("/boot/efi");
|
Err(err) => {
|
||||||
|
eprintln!("couldn't find mount point: {err}, assuming \"/boot/efi\"");
|
||||||
|
PathBuf::from("/boot/efi")
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut full_path =
|
let mut full_path = esp.join(unix_path.strip_prefix("/").unwrap_or(&unix_path));
|
||||||
esp.join(unix_path.strip_prefix("/").unwrap_or(&unix_path));
|
|
||||||
eprintln!("measuring file {full_path:?}");
|
eprintln!("measuring file {full_path:?}");
|
||||||
|
|
||||||
if let Some(drop_in_path) = drop_ins.find_drop_in(&full_path, &digest) {
|
if let Some(drop_in_path) = drop_ins.find_drop_in(&full_path, &digest) {
|
||||||
|
@ -200,8 +196,6 @@ fn main() -> eyre::Result<()> {
|
||||||
continue 'process_event;
|
continue 'process_event;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let encoded = hex::encode(digest.as_slice());
|
let encoded = hex::encode(digest.as_slice());
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
pub fn fixup_uuid(data: u128) -> u128 {
|
pub fn fixup_uuid(data: u128) -> u128 {
|
||||||
let (first, second, third, fourth): (u32, u16, u16, u64) =
|
let (first, second, third, fourth) =
|
||||||
unsafe { std::mem::transmute(data.to_be_bytes()) };
|
unsafe { std::mem::transmute::<[u8; 16], (u32, u16, u16, u64)>(data.to_be_bytes()) };
|
||||||
let real = unsafe {
|
let real = unsafe {
|
||||||
std::mem::transmute((
|
std::mem::transmute::<(u32, u16, u16, u64), [u8; 16]>((
|
||||||
first.swap_bytes(),
|
first.swap_bytes(),
|
||||||
second.swap_bytes(),
|
second.swap_bytes(),
|
||||||
third.swap_bytes(),
|
third.swap_bytes(),
|
||||||
|
|
Loading…
Reference in a new issue