Skip to content

Commit

Permalink
Merge pull request #372 from yonasBSD/yonas-patch-1
Browse files Browse the repository at this point in the history
Fix build on FreeBSD.
  • Loading branch information
stanislav-tkach authored Mar 16, 2024
2 parents 93f9921 + 83fc567 commit 9986b75
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions os_info/src/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{bitness, uname::uname, Info, Type, Version};
pub fn current_platform() -> Info {
trace!("freebsd::current_platform is called");

let version = uname()
let version = uname("-s")
.map(Version::from_string)
.unwrap_or_else(|| Version::Unknown);

Expand All @@ -29,18 +29,9 @@ fn get_os() -> Type {
None => return Type::Unknown,
};

let os = match Command::new("uname").arg("-s").output() {
Ok(o) => o,
Err(e) => {
error!("Failed to invoke 'uname': {:?}", e);
return Type::Unknown;
}
};

match uname("-s") {
None => Type::Unknown,
Some("MidnightBSD") => Type::MidnightBSD,
Some("FreeBSD") => {
match os.as_str() {
"MidnightBSD" => Type::MidnightBSD,
"FreeBSD" => {
let check_hardening = match Command::new("/sbin/sysctl")
.arg("hardening.version")
.output()
Expand All @@ -56,7 +47,8 @@ fn get_os() -> Type {
Ok(_) => Type::FreeBSD,
Err(_) => Type::FreeBSD,
}
}
},
_ => Type::Unknown
}
}

Expand Down

0 comments on commit 9986b75

Please sign in to comment.