1 use std
::process
::Command
;
4 use log
::{error, trace}
;
6 use crate::{bitness, uname::uname, Info, Type, Version}
;
8 pub fn current_platform() -> Info
{
9 trace
!("freebsd::current_platform is called");
12 .map(Version
::from_string
)
13 .unwrap_or_else(|| Version
::Unknown
);
18 bitness
: bitness
::get(),
22 trace
!("Returning {:?}", info
);
27 let os
= Command
::new("uname")
30 .expect("Failed to get OS");
32 match str::from_utf8(&os
.stdout
) {
34 let check_hardening
= Command
::new("sysctl")
35 .arg("hardening.version")
37 .expect("Failed to check if is hardened");
38 match str::from_utf8(&check_hardening
.stderr
) {
39 Ok("0\n") => Type
::HardenedBSD
,
40 Ok(_
) => Type
::FreeBSD
,
41 Err(_
) => Type
::FreeBSD
,
44 Ok("MidnightBSD\n") => Type
::MidnightBSD
,
45 Ok(_
) => Type
::Unknown
,
46 Err(_
) => Type
::Unknown
,
53 use pretty_assertions
::assert_eq
;
57 let version
= current_platform();
58 assert_eq
!(Type
::FreeBSD
, version
.os_type());