Skip to content

Commit

Permalink
Add getresuid/gid and setresuid/gid on BSDs
Browse files Browse the repository at this point in the history
  • Loading branch information
rtzoeller committed Jan 3, 2022
1 parent f6268d9 commit c34164e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
26 changes: 20 additions & 6 deletions src/unistd.rs
Expand Up @@ -30,11 +30,18 @@ feature! {
pub use self::pivot_root::*;
}

#[cfg(any(target_os = "android", target_os = "freebsd",
target_os = "linux", target_os = "openbsd"))]
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "openbsd"))]
pub use self::setres::*;

#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "openbsd"))]
pub use self::getres::*;

feature! {
Expand Down Expand Up @@ -2691,8 +2698,11 @@ mod pivot_root {
}
}

#[cfg(any(target_os = "android", target_os = "freebsd",
target_os = "linux", target_os = "openbsd"))]
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "openbsd"))]
mod setres {
feature! {
#![feature = "users"]
Expand Down Expand Up @@ -2735,7 +2745,11 @@ mod setres {
}
}

#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "openbsd"))]
mod getres {
feature! {
#![feature = "users"]
Expand Down
12 changes: 10 additions & 2 deletions test/test_unistd.rs
Expand Up @@ -621,7 +621,11 @@ fn test_sysconf_unsupported() {
}


#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "openbsd"))]
#[test]
fn test_getresuid() {
let resuids = getresuid().unwrap();
Expand All @@ -630,7 +634,11 @@ fn test_getresuid() {
assert!(resuids.saved.as_raw() != libc::uid_t::max_value());
}

#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "openbsd"))]
#[test]
fn test_getresgid() {
let resgids = getresgid().unwrap();
Expand Down

0 comments on commit c34164e

Please sign in to comment.