diff --git a/src/header/grp/mod.rs b/src/header/grp/mod.rs index 20d5a91f29..1f5ef44a6f 100644 --- a/src/header/grp/mod.rs +++ b/src/header/grp/mod.rs @@ -18,12 +18,14 @@ use alloc::{ }; use crate::{ + error::ResultExt, fs::File, - header::{errno, fcntl, limits, string::strlen, unistd}, - io, - io::{BufReader, Lines, prelude::*}, - platform, - platform::types::{c_char, c_int, c_void, gid_t, size_t}, + header::{errno, fcntl, limits, string::strlen}, + io::{self, BufReader, Lines, prelude::*}, + platform::{ + self, Pal, Sys, + types::{c_char, c_int, c_void, gid_t, size_t}, + }, }; use super::{errno::*, string::strncmp}; @@ -544,5 +546,13 @@ pub unsafe extern "C" fn initgroups(user: *const c_char, gid: gid_t) -> c_int { if unsafe { getgrouplist(user, gid, groups.as_mut_ptr(), &raw mut count) < 0 } { return -1; } - unsafe { unistd::setgroups(count as size_t, groups.as_ptr()) } + unsafe { setgroups(count as size_t, groups.as_ptr()) } +} + +/// Non-POSIX, see . +#[unsafe(no_mangle)] +pub unsafe extern "C" fn setgroups(size: size_t, list: *const gid_t) -> c_int { + unsafe { Sys::setgroups(size, list) } + .map(|()| 0) + .or_minus_one_errno() } diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index fa30b644d0..d3bc890f48 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -899,16 +899,6 @@ pub extern "C" fn setgid(gid: gid_t) -> c_int { .or_minus_one_errno() } -/// Non-POSIX, see . -/// -/// TODO: specified in `grp.h`? -#[unsafe(no_mangle)] -pub unsafe extern "C" fn setgroups(size: size_t, list: *const gid_t) -> c_int { - unsafe { Sys::setgroups(size, list) } - .map(|()| 0) - .or_minus_one_errno() -} - /// See . #[unsafe(no_mangle)] pub extern "C" fn setpgid(pid: pid_t, pgid: pid_t) -> c_int { diff --git a/src/platform/pal/mod.rs b/src/platform/pal/mod.rs index 4c5be00036..3b8c119f85 100644 --- a/src/platform/pal/mod.rs +++ b/src/platform/pal/mod.rs @@ -349,7 +349,7 @@ pub trait Pal { /// Platform implementation of [`sched_yield()`](crate::header::sched::sched_yield) from [`sched.h`](crate::header::sched). fn sched_yield() -> Result<()>; - /// Platform implementation of [`setgroups()`](crate::header::unistd::setgroups) from [`unistd.h`](crate::header::unistd) (TODO: should be `grp.h`?). + /// Platform implementation of [`setgroups()`](crate::header::grp::setgroups) from [`grp.h`](crate::header::grp). unsafe fn setgroups(size: size_t, list: *const gid_t) -> Result<()>; /// Platform implementation of [`setpgid()`](crate::header::unistd::setpgid) from [`unistd.h`](crate::header::unistd).