setgroups - set group access list
int setgroups(int ngroups, gid_t *gidset);
int setgroups(int ngroups, int *gidset);
To use the BSD version of setgroups, one must either
1) explicitly invoke it as BSDsetgroups or
2) link with the libbsd.a library:
cc -o prog prog.c -lbsd
setgroups initializes 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. The sysconf(_SC_NGROUPS_MAX) system call
may be used to determine at runtime the maximum allowable value for
ngroups in the particular kernel configuration (it is an lbootable value
(ngroups_max) which is declared in /var/sysgen/master.d/kernel). If
using the BSD version, ngroups may never be greater than NGROUPS (as
defined in <sys/param.h>).
Setting ngroups_max to zero and rebooting effectively disables multiplegroups
system-wide. In most cases, however, it will be set to a value
between NGROUPS_UMIN and NGROUPS_UMAX (also defined in <sys/param.h>).
Only the super-user may set new groups or alter the value of ngroups_max.
A successful call returns the number of groups in the group set. A value
of -1 indicates that an error occurred, and the error code is stored in
the global variable errno.
The setgroups call will fail if:
[EPERM] The caller is not the super-user.
[EFAULT] The address specified for gidset is outside the process
[EINVAL] The ngroups parameter is greater than NGROUPS or the
kernel maximum, as specified above.
multgrps(1), getgroups(2), initgroups(3), sysconf(2)
The POSIX and 4.3BSD versions differ in the types of their gidset
PPPPaaaaggggeeee 2222 [ Back ]