[Previous] [Contents] [Next]

getgrouplist()

Determine the group access list for a user

Synopsis:

#include <unistd.h>

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

Library:

libc

Description:

The getgrouplist() function reads the group file and determines the group access list for the user specified in name. The basegid is automatically included in the list of groups. Typically this value is given as the group number from the password file.

The resulting group list is returned in the integer array pointed to by groups. The ngroups argument specifies the size of the groups array, and is set by this function to be the actual number of groups found.

Returns:

-1 if the size of the group list is too small to hold all the user's groups. The group array is filled with as many groups as fit.

Files:

/etc/group
Group membership list.

Classification:

Unix

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

Caveats:

The getgrouplist() function uses the routines based on getgrent(). If the invoking program uses any of these routines, the group structure will be overwritten in the call to getgrouplist().

See also:

initgroups(), setgroups()


[Previous] [Contents] [Next]