mirror of
https://github.com/nushell/nushell.git
synced 2025-07-07 10:01:26 +02:00
FreeBSD compatibility patches (#11869)
# Description nushell is verified to work on FreeBSD 14 with these patches. What isn't supported on FreeBSD: * the crate 'procfs' doesn't support FreeBSD yet, all functionality depending on procfs is disabled * several RLIMIT_* values aren't supported on FreeBSD - functions related to these are disabled # User-Facing Changes n/a # Tests + Formatting n/a # After Submitting n/a --------- Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
@ -107,7 +107,7 @@ pub mod users {
|
||||
Gid::current().as_raw()
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||
#[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "android")))]
|
||||
pub fn get_current_username() -> Option<String> {
|
||||
User::from_uid(Uid::current())
|
||||
.ok()
|
||||
@ -115,7 +115,7 @@ pub mod users {
|
||||
.map(|user| user.name)
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "android"))]
|
||||
pub fn current_user_groups() -> Option<Vec<Gid>> {
|
||||
// SAFETY:
|
||||
// if first arg is 0 then it ignores second argument and returns number of groups present for given user.
|
||||
@ -154,7 +154,7 @@ pub mod users {
|
||||
/// println!("User is a member of group #{group}");
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||
#[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "android")))]
|
||||
pub fn get_user_groups(username: &str, gid: gid_t) -> Option<Vec<Gid>> {
|
||||
use std::ffi::CString;
|
||||
// MacOS uses i32 instead of gid_t in getgrouplist for unknown reasons
|
||||
|
Reference in New Issue
Block a user