Skip to content

Commit c3b7291

Browse files
committed
unistd: Add documentation for getgroups/setgroups/initgroups
1 parent 55ff3a5 commit c3b7291

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/unistd.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,12 @@ pub fn setgid(gid: Gid) -> Result<()> {
941941
Errno::result(res).map(drop)
942942
}
943943

944+
/// Get the list of supplementary group IDs of the calling process.
945+
///
946+
/// Note that if the user is added to more group(s) while this call is in
947+
/// progress then an error (EINVAL) will be returned.
948+
///
949+
/// [Further reading](http://pubs.opengroup.org/onlinepubs/009695399/functions/getgroups.html)
944950
pub fn getgroups() -> Result<Vec<Gid>> {
945951
// First get the number of groups so we can size our Vec
946952
use std::ptr;
@@ -960,6 +966,9 @@ pub fn getgroups() -> Result<Vec<Gid>> {
960966
})
961967
}
962968

969+
/// Set the list of supplementary group IDs for the calling process.
970+
///
971+
/// [Further reading](http://man7.org/linux/man-pages/man2/getgroups.2.html)
963972
pub fn setgroups(groups: &[Gid]) -> Result<()> {
964973
cfg_if! {
965974
if #[cfg(any(target_os = "dragonfly",
@@ -979,6 +988,11 @@ pub fn setgroups(groups: &[Gid]) -> Result<()> {
979988
Errno::result(res).map(drop)
980989
}
981990

991+
/// Initialize the supplementary group access list. Sets the supplementary
992+
/// group IDs for the calling process using all groups that `user` is a member
993+
/// of. The additional group `group` is also added to the list.
994+
///
995+
/// [Further reading](http://man7.org/linux/man-pages/man3/initgroups.3.html)
982996
#[cfg(any(target_os = "android", target_os = "ios", target_os = "linux", target_os = "macos"))]
983997
pub fn initgroups(user: &CString, group: Gid) -> Result<()> {
984998
cfg_if! {

0 commit comments

Comments
 (0)