Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
GETGROUPLIST(3)		    Library Functions Manual	       GETGROUPLIST(3)

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  sup-
       plementary groups for the user specified	in name	and returns the	effec-
       tive group list,	whose first group is the value of basegid and the oth-
       ers are the supplementary groups.  basegid typically is the user's ini-
       tial 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
       setcred(2), setgroups(2), initgroups(3)

HISTORY
       The getgrouplist() function first appeared in 4.4BSD.

FreeBSD	15.0			October	9, 2025		       GETGROUPLIST(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=getgrouplist&sektion=3&manpath=FreeBSD+15.0-RELEASE+and+Ports>

home | help