setgroups(3)

DESCRIPTION

Replaces the process supplementary group list with count values from groups.

SYNOPSIS

#include <unistd.h>

int setgroups(int count, const gid_t groups[]);

RETURN VALUE

  • Returns zero, or -1 and sets errno.

ERRORS

  • -EFAULT
    • Groups is not readable for count group IDs.
  • -EINVAL
    • Count is negative or greater than 16.
  • -EPERM
    • The current effective GID is not zero.
  • -ESRCH
    • The calling process does not exist.

NOTES

An empty list is valid and does not dereference groups. The kernel copies the list before replacing the process credential state.