stanislav-tkach / os_info

Rust library to detect the operating system type
MIT License
171 stars 51 forks source link

Use full path to sysctl on FreeBSD #358

Closed zanchey closed 7 months ago

zanchey commented 9 months ago

Calling get_os on FreeBSD without /sbin/ in your $PATH causes a panic:

thread 'main' panicked at /rust/deps/os_info-3.7.0/src/freebsd/mod.rs:37:18:
Failed to check if is hardened: Os { code: 2, kind: NotFound, message: "No such file or directory" }
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/core/src/result.rs:1649:5
   3: os_info::imp::current_platform
   4: os_info::get
...

Call the binary with a full path instead.

stanislav-tkach commented 7 months ago

By the way, I don't think the library should panic in this case. I will fix this issue in a separate pull request.