setgroups(2)

setgroups2

Set group access list

Usage

#include <sys/param.h>

#include <unistd.h>

int

setgroups(int ngroups, const gid_t *gidset);

Overview

setgroups() sets the group access list of the current user process according to the array gidset. The parameter ngroups indicates the number of entries in the array and must be no more than {NGROUPS_MAX}.

Only the super-user may set new groups.

Use of setgroups() is highly discouraged.

Return values

A 0 value is returned on success, -1 on error, with an error code stored in errno.

Errors

The setgroups() call will fail if:

[EINVAL]

The value of ngroups is greater than {NGROUPS_MAX}.

[EPERM]

The caller is not the super-user.

[EFAULT]

The address specified for gidset is outside the process address space.

Releases

155 releases since Mac OS X 10.0; the text changed 2 times.

  1. 10.0–10.6.8
  2. 10.7–10.11.6
  3. 10.12–26.5

History

The setgroups() function call appeared in 4.2BSD.

From xnu 12377.121.6 in macOS 26.5. Parsed by carta from the page's mdoc source.