initgroups(3C) — C LIBRARY FUNCTIONS
NAME
initgroups − initialize the supplementary group access list
SYNOPSIS
#include <grp.h>
#include <sys/types.h>
int initgroups (const char ∗name, gid_t basegid)
DESCRIPTION
initgroups reads the group file to get the group membership for the user specified by name and then initializes the supplementary group access list of the calling process using setgroups. The basegid group ID is also included in the supplementary group access list. This is typically the real group ID from the password file.
With a group file configured to use NIS, initgroups includes the corresponding NIS groups in the supplementary group access list.
While scanning the groups, if the number of groups, including the basegid entry, exceeds {NGROUPS_MAX}, subsequent group entries are ignored.
initgroups will fail and not change the supplementary group access list if:
EPERM The effective user ID is not superuser.
EINVAL uname is NULL or zero length.
ENOMEM Unable to allocate memory.
initgroups fails and does not change the supplementary group access list if fopen(3C) fails to open /etc/group, or sysconf(3C) fails. See the corresponding manual pages for the related errno values.
SEE ALSO
setgroups(2), fopen(3C), sysconf(3C), group(4)
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise, a value of −1 is returned and errno is set to indicate the error.