# [−][src]Function nix::unistd::initgroups

    pub fn initgroups(user: &CStr, group: Gid) -> Result<()>

Initialize the supplementary group access list.

Sets the supplementary group IDs for the calling process using all groups that `user` is a member of. The additional group `group` is also added to the list.

Further reading

Note: This function is not available for Apple platforms. On those platforms, group membership management should be achieved via communication with the `opendirectoryd` service.

# Examples

`initgroups` can be used when dropping privileges from the root user to another user. For example, given the user `www-data`, we could look up the UID and GID for the user in the system's password database (usually found in `/etc/passwd`). If the `www-data` user's UID and GID were `33` and `33`, respectively, one could switch the user as follows:

    let user = CString::new("www-data").unwrap();
    let uid = Uid::from_raw(33);
    let gid = Gid::from_raw(33);
    initgroups(&user, gid)?;
    setgid(gid)?;
    setuid(uid)?;

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)