Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions crates/host_env/src/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,11 +797,15 @@ pub fn setpgid_if_needed(pgid_to_set: libc::pid_t) -> nix::Result<()> {
Ok(())
}

pub fn setgroups_if_needed(_groups: Option<&[u32]>) -> nix::Result<()> {
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
if let Some(groups) = _groups {
let groups = groups.iter().copied().map(gid_from_raw).collect::<Vec<_>>();
nix::unistd::setgroups(&groups)?;
pub fn setgroups_if_needed(groups: Option<&[u32]>) -> nix::Result<()> {
#[cfg(not(any(target_os = "ios", target_os = "redox")))]
if let Some(groups) = groups {
// The caller prepares this array before fork. Call libc directly so
// macOS performs the requested operation too, and so the child does
// not allocate a second array between fork and exec.
let ret =
unsafe { libc::setgroups(groups.len() as _, groups.as_ptr().cast::<libc::gid_t>()) };
nix::Error::result(ret)?;
}
Ok(())
}
Expand Down
Loading