getgrouplist

Name

getgrouplist -- get groups a user belongs to

Synopsis

#include <grp.h>

int getgrouplist(const char * user, gid_t group, gid_t * groups, int * ngroups);

Description

The getgrouplist() function shall fill in the array groups with the supplementary groups for the user specified by user. On entry, ngroups shall refer to an integer containing the maximum number of gid_t members in the groups array. The group group shall also be included.

Return Value

If on entry the value referenced by ngroups was greater than or equal to the number of supplementary group identifiers to be copied to the array identified by groups, getgrouplist() shall return the number of group identifiers actually copied, and shall set the value referenced by ngroups to this value.

If on entry the value referenced by ngroups was less than to the number of supplementary group identifiers, getgrouplist() shall return -1. The initial *ngroups entries in groups may be overwritten.

If user does not refer to a valid user on the system, getgrouplist() shall return 1, and set the value referenced by ngroups to 1, reflecting the group supplied as group.

Errors

None defined.

See Also

getgroups()