version 1.6, 1999/04/25 14:56:10 |
version 1.11, 2004/09/28 10:49:22 |
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright |
.\" 2. Redistributions in binary form must reproduce the above copyright |
.\" notice, this list of conditions and the following disclaimer in the |
.\" notice, this list of conditions and the following disclaimer in the |
.\" documentation and/or other materials provided with the distribution. |
.\" documentation and/or other materials provided with the distribution. |
.\" 3. All advertising materials mentioning features or use of this software |
.\" 3. Neither the name of the University nor the names of its contributors |
.\" must display the following acknowledgement: |
|
.\" This product includes software developed by the University of |
|
.\" California, Berkeley and its contributors. |
|
.\" 4. Neither the name of the University nor the names of its contributors |
|
.\" may be used to endorse or promote products derived from this software |
.\" may be used to endorse or promote products derived from this software |
.\" without specific prior written permission. |
.\" without specific prior written permission. |
.\" |
.\" |
|
|
.\" |
.\" |
.\" @(#)getgrouplist.3 8.1 (Berkeley) 6/9/93 |
.\" @(#)getgrouplist.3 8.1 (Berkeley) 6/9/93 |
.\" |
.\" |
.Dd April 25, 1999 |
.Dd September 28, 2004 |
.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> |
.In unistd.h |
.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 |
Line 59 the group number from the password datab |
|
Line 55 the group number from the password datab |
|
.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 ; |
Line 71 Duplicate group ids will be suppressed f |
|
Line 67 Duplicate group ids will be suppressed f |
|
The |
The |
.Fn getgrouplist |
.Fn getgrouplist |
function |
function |
|
returns 0 if successful, and |
returns \-1 if the size of the group list is too small to |
returns \-1 if the size of the group list is too small to |
hold all the user's groups. |
hold all the user's groups. |
Here, the group array will be filled with as many groups as will fit. |
In the latter case, the |
|
.Fa groups |
|
array will be filled with as many groups as will fit and |
|
.Fa ngroups |
|
will contain the total number of groups found. |
.Sh FILES |
.Sh FILES |
.Bl -tag -width /etc/group -compact |
.Bl -tag -width /etc/group -compact |
.It Pa /etc/group |
.It Pa /etc/group |
Line 81 group membership list |
|
Line 82 group membership list |
|
.El |
.El |
.Sh SEE ALSO |
.Sh SEE ALSO |
.Xr setgroups 2 , |
.Xr setgroups 2 , |
.Xr initgroups 3 |
.Xr initgroups 3 , |
|
.Xr group 5 . |
.Sh HISTORY |
.Sh HISTORY |
The |
The |
.Fn getgrouplist |
.Fn getgrouplist |
Line 97 If the invoking program uses any of thes |
|
Line 99 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. |
|