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

    pub fn setgroups(groups: &[Gid]) -> Result<()>

Set the list of supplementary group IDs for the calling process.

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

`setgroups` can be used when dropping privileges from the root user to a specific user and group. For example, given the user `www-data` with UID `33` and the group `backup` with the GID `34`, one could switch the user as follows:

    let uid = Uid::from_raw(33);
    let gid = Gid::from_raw(34);
    setgroups(&[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`)