mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-10-18 19:10:30 +08:00
cli/debug: Add hardenedBsd detection
This is conditional on the target operating system being FreeBSDs. HardenedBSD is FreeBSD but with changes. We determine which one it is, by running 'sysctl --values hardening.version'. Co-authored-by: Shawn Webb <shawn.webb@hardenedbsd.org>
This commit is contained in:
committed by
Lorenz Leutgeb
co-authored by
Shawn Webb
parent
9f05038234
commit
52ac5d3b3e
@@ -60,6 +60,7 @@ fn debug(profile: Option<&Profile>) -> anyhow::Result<()> {
|
||||
arch: std::env::consts::ARCH,
|
||||
env,
|
||||
warnings: collect_warnings(profile),
|
||||
hardened_bsd: hardened_bsd(),
|
||||
};
|
||||
|
||||
term::println(serde_json::to_string_pretty(&debug).unwrap());
|
||||
@@ -73,6 +74,21 @@ fn os_release() -> Option<HashMap<String, String>> {
|
||||
.map(|map| map.into_iter().map(|(k, v)| (k.to_string(), v)).collect())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
fn hardened_bsd() -> Option<String> {
|
||||
let mut cmd = Command::new("sysctl");
|
||||
cmd.args(["sysctl", "--values", "hardening.version"]);
|
||||
cmd.output()
|
||||
.ok()
|
||||
.map(|output| String::from_utf8_lossy(&output.stdout).trim().to_string())
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
#[inline]
|
||||
const fn hardened_bsd() -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[allow(dead_code)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -91,6 +107,8 @@ struct DebugInfo {
|
||||
arch: &'static str,
|
||||
env: BTreeMap<String, String>,
|
||||
|
||||
hardened_bsd: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
warnings: Vec<String>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user