version 1.5, 1998/02/05 18:46:41 |
version 1.6.10.3, 2002/03/22 20:42:07 |
|
|
.\" |
.\" |
.\" @(#)getgrouplist.3 8.1 (Berkeley) 6/9/93 |
.\" @(#)getgrouplist.3 8.1 (Berkeley) 6/9/93 |
.\" |
.\" |
.Dd June 9, 1993 |
.Dd April 25, 1999 |
.Dt GETGROUPLIST 3 |
.Dt GETGROUPLIST 3 |
.Os |
.Os |
.Sh NAME |
.Sh NAME |
|
|
.Sh LIBRARY |
.Sh LIBRARY |
.Lb libc |
.Lb libc |
.Sh SYNOPSIS |
.Sh SYNOPSIS |
.Fd #include <unistd.h> |
.Fd #include \*[Lt]unistd.h\*[Gt] |
.Ft int |
.Ft int |
.Fn getgrouplist "const char *name" "gid_t basegid" "gid_t *groups" "int *ngroups" |
.Fn getgrouplist "const char *name" "gid_t basegid" "gid_t *groups" "int *ngroups" |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
The |
The |
.Fn getgrouplist |
.Fn getgrouplist |
function reads through the group file and calculates |
function reads through the group database and calculates |
the group access list for the user specified in |
the group access list for the user specified in |
.Fa name . |
.Fa name . |
The |
The |
.Fa basegid |
.Fa basegid |
is automatically included in the groups list. |
is automatically included in the groups list. |
Typically this value is given as |
Typically this value is given as |
the group number from the password file. |
the group number from the password database. |
.Pp |
.Pp |
The resulting group list is returned in the integer array pointed to by |
The resulting group list is returned in the integer array pointed to by |
.Fa groups . |
.Fa groups . |
The caller specifies the size of the |
The caller specifies the size of the |
.Fa groups |
.Fa groups |
array in the integer pointed to by |
array in the integer pointed to by |
.Fa ngroups ; |
.Fa ngroups ; |
the actual number of groups found is returned in |
the actual number of groups found is returned in |
.Fa ngroups . |
.Fa ngroups . |
|
.Pp |
|
Duplicate group ids will be suppressed from the result. |
.Sh RETURN VALUES |
.Sh RETURN VALUES |
The |
The |
.Fn getgrouplist |
.Fn getgrouplist |
Line 95 If the invoking program uses any of thes |
|
Line 97 If the invoking program uses any of thes |
|
the group structure will |
the group structure will |
be overwritten in the call to |
be overwritten in the call to |
.Fn getgrouplist . |
.Fn getgrouplist . |
|
.Pp |
|
In the case where the group array is too small and duplicate gids |
|
have been suppressed, the returned |
|
.Fa ngroups |
|
will be too large by a factor of the difference between the given |
|
size and the number of matches. |
|
This is not considered to be a major problem, since it's still going |
|
to be a smaller figure than when duplicates were not suppressed. |