getgroups(2) getgroups(2)
getgroups - get supplementary group access list IDs
#include <unistd.h>
int ngrps;
POSIX:
ngrps = getgroups(int setlen, gid_t *gidset);
BSD:
ngrps = getgroups(int setlen, int *gidset);
To use the BSD version of getgroups one must either
1) explicitly invoke it as BSDgetgroups or
2) link with the libbsd.a library:
cc -o prog prog.c -lbsd
getgroups retrieves the current group access list of the user process and
stores it in the array gidset. The parameter setlen indicates the number
of entries that may be placed in gidset. The return value is the actual
number of groups placed in gidset, and this will never be greater than
NGROUPS_UMAX for the POSIX version, and NGROUPS for the BSD version, as
defined in <sys/param.h>.
As a special case, if the setlen parameter is zero, getgroups returns the
number of supplemental group IDs associated with the calling process
without modifying the array pointed to by the gidset argument.
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 possible errors for getgroups are:
[EINVAL] The argument setlen is smaller than the number of groups
in the group set.
[EFAULT] The argument gidset specifies an invalid address.
multgrps(1), setgroups(2), initgroups(3)
Page 1
getgroups(2) getgroups(2)
The POSIX and 4.3BSD versions differ in the types of their gidset
parameter.
PPPPaaaaggggeeee 2222 [ Back ]
|