---
name: "getgrouplist"
section: "3"
platform: "macos"
package: "Libinfo"
version: "600"
release: "macOS 26.5"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/getgrouplist"
---

# getgrouplist(3)

calculate partial group access list

## NAME

**getgrouplist** – calculate partial group access list

## LIBRARY

Standard system libraries.

## SYNOPSIS

**#include \<unistd.h\>**

*int*\

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

## DESCRIPTION

The **getgrouplist**() 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*.

## RETURN VALUES

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.

## FILES

- */etc/group*

  group membership list

## SEE ALSO

[setgroups(2)](/setgroups/2.md), [initgroups(3)](/initgroups/3.md), opendirectoryd(8).

## HISTORY

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