xref: /netbsd-src/lib/libc/sys/getgroups.2 (revision dd3d742fd55ba83d3b6e61d27a1c191f71ac7be8)
1*dd3d742fSnjoly.\"	$NetBSD: getgroups.2,v 1.23 2013/07/14 14:29:09 njoly Exp $
24eab61bdScgd.\"
34eab61bdScgd.\" Copyright (c) 1983, 1991, 1993
44eab61bdScgd.\"	The Regents of the University of California.  All rights reserved.
561f28255Scgd.\"
661f28255Scgd.\" Redistribution and use in source and binary forms, with or without
761f28255Scgd.\" modification, are permitted provided that the following conditions
861f28255Scgd.\" are met:
961f28255Scgd.\" 1. Redistributions of source code must retain the above copyright
1061f28255Scgd.\"    notice, this list of conditions and the following disclaimer.
1161f28255Scgd.\" 2. Redistributions in binary form must reproduce the above copyright
1261f28255Scgd.\"    notice, this list of conditions and the following disclaimer in the
1361f28255Scgd.\"    documentation and/or other materials provided with the distribution.
14eb7c1594Sagc.\" 3. Neither the name of the University nor the names of its contributors
1561f28255Scgd.\"    may be used to endorse or promote products derived from this software
1661f28255Scgd.\"    without specific prior written permission.
1761f28255Scgd.\"
1861f28255Scgd.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1961f28255Scgd.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2061f28255Scgd.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2161f28255Scgd.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2261f28255Scgd.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2361f28255Scgd.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2461f28255Scgd.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2561f28255Scgd.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2661f28255Scgd.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2761f28255Scgd.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2861f28255Scgd.\" SUCH DAMAGE.
2961f28255Scgd.\"
304eab61bdScgd.\"     @(#)getgroups.2	8.2 (Berkeley) 4/16/94
3161f28255Scgd.\"
329c5eec00Selad.Dd October 7, 2006
3361f28255Scgd.Dt GETGROUPS 2
3438c96853Sgarbled.Os
3561f28255Scgd.Sh NAME
3661f28255Scgd.Nm getgroups
3761f28255Scgd.Nd get group access list
3815be242bSkleink.Sh LIBRARY
3915be242bSkleink.Lb libc
4061f28255Scgd.Sh SYNOPSIS
41472351e1Swiz.In unistd.h
4261f28255Scgd.Ft int
43c9db20ecSjtc.Fn getgroups "int gidsetlen" "gid_t *gidset"
4461f28255Scgd.Sh DESCRIPTION
45ce83c69eSlukem.Fn getgroups
462f9562f9Sjtcgets the current group access list of the current user process
4761f28255Scgdand stores it in the array
4861f28255Scgd.Fa gidset .
4961f28255ScgdThe parameter
5061f28255Scgd.Fa gidsetlen
5161f28255Scgdindicates the number of entries that may be placed in
5261f28255Scgd.Fa gidset .
53ce83c69eSlukem.Fn getgroups
5461f28255Scgdreturns the actual number of groups returned in
5561f28255Scgd.Fa gidset .
5661f28255ScgdNo more than
57*dd3d742fSnjoly.Brq Dv NGROUPS_MAX
5861f28255Scgdwill ever
5961f28255Scgdbe returned.
602f9562f9SjtcIf
612f9562f9Sjtc.Fa gidsetlen
622f9562f9Sjtcis 0,
632f9562f9Sjtc.Fn getgroups
642f9562f9Sjtcreturns the number of groups without modifying the
652f9562f9Sjtc.Fa gidset
662f9562f9Sjtcarray.
679c5eec00Selad.Pp
689c5eec00SeladThis system call only returns the secondary groups.
6961f28255Scgd.Sh RETURN VALUES
7061f28255ScgdA successful call returns the number of groups in the group set.
7164ebeb5cSwizA value of \-1 indicates that an error occurred, and the error
7261f28255Scgdcode is stored in the global variable
7361f28255Scgd.Va errno .
7461f28255Scgd.Sh ERRORS
7561f28255ScgdThe possible errors for
7661f28255Scgd.Fn getgroups
7761f28255Scgdare:
7861f28255Scgd.Bl -tag -width Er
7961f28255Scgd.It Bq Er EINVAL
8061f28255ScgdThe argument
8161f28255Scgd.Fa gidsetlen
82ed836ad5Skleinkis non-zero and is smaller than the number of groups in the group set.
8361f28255Scgd.It Bq Er EFAULT
8461f28255ScgdThe argument
8561f28255Scgd.Fa gidset
8661f28255Scgdspecifies
8761f28255Scgdan invalid address.
8861f28255Scgd.El
8961f28255Scgd.Sh SEE ALSO
909c5eec00Selad.Xr getegid 2 ,
91a721d64bSwiz.Xr getgid 2 ,
9261f28255Scgd.Xr setgroups 2 ,
9361f28255Scgd.Xr initgroups 3
94c213a3afSkleink.Sh STANDARDS
95c213a3afSkleinkThe
96c213a3afSkleink.Fn getgroups
97c213a3afSkleinkfunction conforms to
98c213a3afSkleink.St -p1003.1-90 .
9961f28255Scgd.Sh HISTORY
10061f28255ScgdThe
1016e9ac180Sjtc.Fn getgroups
10261f28255Scgdfunction call appeared in
10361f28255Scgd.Bx 4.2 .
104