fix lints

This commit is contained in:
slonkazoid 2024-08-04 18:46:25 +03:00
parent 11c0ef4db8
commit d6061c5dff
Signed by: slonk
SSH key fingerprint: SHA256:tbZfJX4IOvZ0LGWOWu5Ijo8jfMPi78TU7x1VoEeCIjM
3 changed files with 97 additions and 103 deletions

View file

@ -32,9 +32,9 @@ fn recurse_device_path(
match a.next {
Some(next) => {
return recurse_device_path(*next, uuid, path);
recurse_device_path(*next, uuid, path)
}
None => return (uuid, path),
None => (uuid, path),
}
}

View file

@ -7,6 +7,7 @@ mod find_mount_point;
mod hash;
mod util;
use std::borrow::Cow;
use std::fs::OpenOptions;
use std::io::{self, BufReader};
use std::path::PathBuf;
@ -26,6 +27,7 @@ use crate::drop_ins::DropIns;
use crate::hash::*;
#[derive(Error, Debug)]
#[allow(clippy::enum_variant_names)]
enum Error {
#[error("error while parsing PE file: {0}")]
PeParseError(#[from] object::Error),
@ -101,8 +103,7 @@ fn main() -> eyre::Result<()> {
}
'measure_file: {
match event.event {
EventType::EFIBootServicesApplication => {
if event.event == EventType::EFIBootServicesApplication {
let event_data = match event.parsed_data {
Some(event_data) => event_data,
None => {
@ -133,15 +134,11 @@ fn main() -> eyre::Result<()> {
let windows_path = Utf8WindowsPathBuf::from(windows_path_str);
let unix_path = windows_path.with_encoding::<Utf8UnixEncoding>();
let esp;
'mnt: {
'get_mnt: {
let get_mnt = || {
let id = match uuid {
Some(id) => id,
None => {
eprintln!("uuid not in event log");
break 'get_mnt;
return Err(Cow::Borrowed("uuid not in event log"));
}
};
@ -150,30 +147,29 @@ fn main() -> eyre::Result<()> {
) {
Ok(maybe_point) => maybe_point,
Err(err) => {
eprintln!("error while looking up mount point: {err}");
break 'get_mnt;
return Err(Cow::Owned(format!(
"error while looking up mount point: {err}"
)));
}
};
match maybe_point {
Some(point) => {
esp = point;
break 'mnt;
}
Some(point) => Ok(point),
None => {
eprintln!("device not mounted");
break 'get_mnt;
}
return Err(Cow::Borrowed("device not mounted"));
}
}
};
// fallback
eprintln!("couldn't find mount point, assuming \"/boot/efi\"");
esp = PathBuf::from("/boot/efi");
let esp = match get_mnt() {
Ok(v) => v,
Err(err) => {
eprintln!("couldn't find mount point: {err}, assuming \"/boot/efi\"");
PathBuf::from("/boot/efi")
}
};
let mut full_path =
esp.join(unix_path.strip_prefix("/").unwrap_or(&unix_path));
let mut full_path = esp.join(unix_path.strip_prefix("/").unwrap_or(&unix_path));
eprintln!("measuring file {full_path:?}");
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;
}
}
_ => {}
}
}
let encoded = hex::encode(digest.as_slice());

View file

@ -1,8 +1,8 @@
pub fn fixup_uuid(data: u128) -> u128 {
let (first, second, third, fourth): (u32, u16, u16, u64) =
unsafe { std::mem::transmute(data.to_be_bytes()) };
let (first, second, third, fourth) =
unsafe { std::mem::transmute::<[u8; 16], (u32, u16, u16, u64)>(data.to_be_bytes()) };
let real = unsafe {
std::mem::transmute((
std::mem::transmute::<(u32, u16, u16, u64), [u8; 16]>((
first.swap_bytes(),
second.swap_bytes(),
third.swap_bytes(),