pub fn get_groups_gnu(arg_id: Option<u32>) -> IOResult<Vec<gid_t>>
Expand description

The list of group IDs returned from GNU’s groups and GNU’s id --groups starts with the effective group ID (egid). This is a wrapper for get_groups() to mimic this behavior.

If arg_id is None (default), get_groups_gnu moves the effective group id (egid) to the first entry in the returned Vector. If arg_id is Some(x), get_groups_gnu moves the id with value x to the first entry in the returned Vector. This might be necessary for id --groups --real if gid and egid are not equal.

From: <https://www.man7.org/linux/man-pages/man3/getgroups.3p.html>

As implied by the definition of supplementary groups, the effective group ID may appear in the array returned by getgroups() or it may be returned only by getegid(). Duplication may exist, but the application needs to call getegid() to be sure of getting all of the information. Various implementation variations and administrative sequences cause the set of groups appearing in the result of getgroups() to vary in order and as to whether the effective group ID is included, even when the set of groups is the same (in the mathematical sense of ``set’’). (The history of a process and its parents could affect the details of the result.)