NAME
getgrouplist – produce a user's effective group list
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <unistd.h>
int
getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroups);
DESCRIPTION
The getgrouplist() function retrieves from the group database the supplementary groups for the user specified in name and returns the effective group list, whose first group is the value of basegid and the others are the supplementary groups. basegid typically is the user's initial numerical group ID from the password database.
The effective group list is returned in the array pointed to by groups. The caller specifies the length of the groups array in the integer pointed to by ngroups. The number of groups of the effective group list, which may be greater than the groups array's length, is returned through ngroups.
RETURN VALUES
The getgrouplist() function returns 0 on success and -1 if the length of the group list is too small to hold all the user's groups. In the latter case, the groups array is filled with as many groups as possible from the start of the effective group list, and the length pointed to by ngroups is set to the full length of the latter, thus to a value strictly greater than before the call.
FILES
- /etc/group
-
group membership list
SEE ALSO
HISTORY
The getgrouplist() function first appeared in 4.4BSD.