Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ async-trait = "0.1"
clap = { version = "4.6", features = ["derive"] }
console = "0.16"
bytesize = "2.3"
dmidecode = "0.9"
47 changes: 46 additions & 1 deletion src/recorders/postinstall/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,52 @@ impl SystemRecorder {
/// dmidecode
/// ```
pub async fn record_dmidecode(&self) -> CheckResult {
self.run_tool("dmidecode").await
const NAME: &str = "Captured dmidecode";

self.host_executor
.spawn_in_host_ns(async {
let ep_bytes = match std::fs::read("/sys/firmware/dmi/tables/smbios_entry_point") {
Ok(b) => b,
Err(e) => {
return CheckResult::new(
NAME,
Skipped(format!("could not read smbios_entry_point: {e}")),
);
}
};

let entry_point = match dmidecode::EntryPoint::search(&ep_bytes) {
Ok(ep) => ep,
Err(e) => {
return CheckResult::new(
NAME,
Skipped(format!("could not parse DMI entry point: {e:?}")),
);
}
};

let table_bytes = match std::fs::read("/sys/firmware/dmi/tables/DMI") {
Ok(b) => b,
Err(e) => {
return CheckResult::new(
NAME,
Skipped(format!("could not read DMI table: {e}")),
);
}
};

let mut output = String::new();
for structure in entry_point.structures(&table_bytes) {
match structure {
Ok(s) => output.push_str(&format!("{s:#?}\n")),
Err(e) => output.push_str(&format!("Error: {e:?}\n")),
}
}

CheckResult::new_with_output(NAME, Passed, Some(output.trim().to_string()))
})
.await
.unwrap_or_else(|e| CheckResult::new(NAME, Skipped(e.to_string())))
}

/// Records the Xen hypervisor console log via the protect-ctl tool.
Expand Down
47 changes: 46 additions & 1 deletion src/recorders/preinstall/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,52 @@ impl SystemRecorder {
/// dmidecode
/// ```
pub async fn record_dmidecode(&self) -> CheckResult {
self.run_tool("dmidecode").await
const NAME: &str = "Captured dmidecode";

self.host_executor
.spawn_in_host_ns(async {
let ep_bytes = match std::fs::read("/sys/firmware/dmi/tables/smbios_entry_point") {
Ok(b) => b,
Err(e) => {
return CheckResult::new(
NAME,
Skipped(format!("could not read smbios_entry_point: {e}")),
);
}
};

let entry_point = match dmidecode::EntryPoint::search(&ep_bytes) {
Ok(ep) => ep,
Err(e) => {
return CheckResult::new(
NAME,
Skipped(format!("could not parse DMI entry point: {e:?}")),
);
}
};

let table_bytes = match std::fs::read("/sys/firmware/dmi/tables/DMI") {
Ok(b) => b,
Err(e) => {
return CheckResult::new(
NAME,
Skipped(format!("could not read DMI table: {e}")),
);
}
};

let mut output = String::new();
for structure in entry_point.structures(&table_bytes) {
match structure {
Ok(s) => output.push_str(&format!("{s:#?}\n")),
Err(e) => output.push_str(&format!("Error: {e:?}\n")),
}
}

CheckResult::new_with_output(NAME, Passed, Some(output.trim().to_string()))
})
.await
.unwrap_or_else(|e| CheckResult::new(NAME, Skipped(e.to_string())))
}

/// Records CPU hardware details and feature flags.
Expand Down
Loading