GETGROUPLIST(3) Library Functions Manual GETGROUPLIST(3)

getgrouplistcalculate partial group access list

Standard system libraries.

#include <unistd.h>

int
getgrouplist(const char *name, int basegid, int *groups, int *ngroups);

The () function obtains information from opendirectoryd(8) to construct the group access list for the user specified in name. The basegid is automatically included in the groups list. Typically this value is given as the default group number from the user's account record.

The resulting group list is returned in the array pointed to by groups. The caller specifies the size of the groups array in the integer pointed to by ngroups; the actual number of groups found is returned in ngroups.

The getgrouplist() function returns 0 on success. If the size of the group list is too small to hold all the user's groups, getgrouplist() returns -1 to indicate failure. In this case, the group array will be filled with as many groups as will fit.

/etc/group
group membership list

setgroups(2), initgroups(3), opendirectoryd(8).

The getgrouplist() function first appeared in 4.4BSD.

June 9, 1993 macOS 15.2