diff --git a/crates/radicle-cli/src/commands/debug.rs b/crates/radicle-cli/src/commands/debug.rs index e70cb39d3..45b475dbe 100644 --- a/crates/radicle-cli/src/commands/debug.rs +++ b/crates/radicle-cli/src/commands/debug.rs @@ -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> { .map(|map| map.into_iter().map(|(k, v)| (k.to_string(), v)).collect()) } +#[cfg(target_os = "freebsd")] +fn hardened_bsd() -> Option { + 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 { + None +} + #[derive(Debug, Serialize)] #[allow(dead_code)] #[serde(rename_all = "camelCase")] @@ -91,6 +107,8 @@ struct DebugInfo { arch: &'static str, env: BTreeMap, + hardened_bsd: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] warnings: Vec, }