158f0484fSRodney W. Grimes.\" Copyright (c) 1989, 1991, 1993 258f0484fSRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 358f0484fSRodney W. Grimes.\" 458f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 558f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions 658f0484fSRodney W. Grimes.\" are met: 758f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 858f0484fSRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 958f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 1058f0484fSRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 1158f0484fSRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 1258f0484fSRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software 1358f0484fSRodney W. Grimes.\" must display the following acknowledgement: 1458f0484fSRodney W. Grimes.\" This product includes software developed by the University of 1558f0484fSRodney W. Grimes.\" California, Berkeley and its contributors. 1658f0484fSRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 1758f0484fSRodney W. Grimes.\" may be used to endorse or promote products derived from this software 1858f0484fSRodney W. Grimes.\" without specific prior written permission. 1958f0484fSRodney W. Grimes.\" 2058f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2158f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2258f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2358f0484fSRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2458f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2558f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2658f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2758f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2858f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2958f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3058f0484fSRodney W. Grimes.\" SUCH DAMAGE. 3158f0484fSRodney W. Grimes.\" 326af9798fSGarrett Wollman.\" From: @(#)getgrent.3 8.2 (Berkeley) 4/19/94 337f3dea24SPeter Wemm.\" $FreeBSD$ 3458f0484fSRodney W. Grimes.\" 356af9798fSGarrett Wollman.Dd September 29, 1994 3658f0484fSRodney W. Grimes.Dt GETGRENT 3 3758f0484fSRodney W. Grimes.Os 3858f0484fSRodney W. Grimes.Sh NAME 3958f0484fSRodney W. Grimes.Nm getgrent , 4058f0484fSRodney W. Grimes.Nm getgrnam , 4158f0484fSRodney W. Grimes.Nm getgrgid , 4258f0484fSRodney W. Grimes.Nm setgroupent , 4358f0484fSRodney W. Grimes.\" .Nm setgrfile , 4458f0484fSRodney W. Grimes.Nm setgrent , 4558f0484fSRodney W. Grimes.Nm endgrent 4658f0484fSRodney W. Grimes.Nd group database operations 4725bb73e0SAlexey Zelkin.Sh LIBRARY 4825bb73e0SAlexey Zelkin.Lb libc 4958f0484fSRodney W. Grimes.Sh SYNOPSIS 509c6e4f2aSBruce Evans.Fd #include <sys/types.h> 5158f0484fSRodney W. Grimes.Fd #include <grp.h> 5258f0484fSRodney W. Grimes.Ft struct group * 5358f0484fSRodney W. Grimes.Fn getgrent void 5458f0484fSRodney W. Grimes.Ft struct group * 5558f0484fSRodney W. Grimes.Fn getgrnam "const char *name" 5658f0484fSRodney W. Grimes.Ft struct group * 5758f0484fSRodney W. Grimes.Fn getgrgid "gid_t gid" 58712dc76eSMike Pritchard.Ft int 5958f0484fSRodney W. Grimes.Fn setgroupent "int stayopen" 6058f0484fSRodney W. Grimes.\" .Ft void 6158f0484fSRodney W. Grimes.\" .Fn setgrfile "const char *name" 6258f0484fSRodney W. Grimes.Ft int 6358f0484fSRodney W. Grimes.Fn setgrent void 6458f0484fSRodney W. Grimes.Ft void 6558f0484fSRodney W. Grimes.Fn endgrent void 6658f0484fSRodney W. Grimes.Sh DESCRIPTION 6758f0484fSRodney W. GrimesThese functions operate on the group database file 6858f0484fSRodney W. Grimes.Pa /etc/group 6958f0484fSRodney W. Grimeswhich is described 7058f0484fSRodney W. Grimesin 7158f0484fSRodney W. Grimes.Xr group 5 . 7258f0484fSRodney W. GrimesEach line of the database is defined by the structure 7358f0484fSRodney W. Grimes.Ar group 7458f0484fSRodney W. Grimesfound in the include 7558f0484fSRodney W. Grimesfile 7658f0484fSRodney W. Grimes.Aq Pa grp.h : 7758f0484fSRodney W. Grimes.Bd -literal -offset indent 7858f0484fSRodney W. Grimesstruct group { 7958f0484fSRodney W. Grimes char *gr_name; /* group name */ 8058f0484fSRodney W. Grimes char *gr_passwd; /* group password */ 811ffa6450SMike Pritchard int gr_gid; /* group id */ 821ffa6450SMike Pritchard char **gr_mem; /* group members */ 8358f0484fSRodney W. Grimes}; 8458f0484fSRodney W. Grimes.Ed 8558f0484fSRodney W. Grimes.Pp 8658f0484fSRodney W. GrimesThe functions 8758f0484fSRodney W. Grimes.Fn getgrnam 8858f0484fSRodney W. Grimesand 8958f0484fSRodney W. Grimes.Fn getgrgid 9058f0484fSRodney W. Grimessearch the group database for the given group name pointed to by 9158f0484fSRodney W. Grimes.Ar name 9258f0484fSRodney W. Grimesor the group id pointed to by 9358f0484fSRodney W. Grimes.Ar gid , 9458f0484fSRodney W. Grimesrespectively, returning the first one encountered. Identical group 9558f0484fSRodney W. Grimesnames or group gids may result in undefined behavior. 9658f0484fSRodney W. Grimes.Pp 9758f0484fSRodney W. GrimesThe 9858f0484fSRodney W. Grimes.Fn getgrent 9958f0484fSRodney W. Grimesfunction 10058f0484fSRodney W. Grimessequentially reads the group database and is intended for programs 10158f0484fSRodney W. Grimesthat wish to step through the complete list of groups. 10258f0484fSRodney W. Grimes.Pp 10358f0484fSRodney W. GrimesAll three routines will open the group file for reading, if necessary. 10458f0484fSRodney W. Grimes.Pp 10558f0484fSRodney W. GrimesThe 10658f0484fSRodney W. Grimes.Fn setgroupent 10758f0484fSRodney W. Grimesfunction 10858f0484fSRodney W. Grimesopens the file, or rewinds it if it is already open. If 10958f0484fSRodney W. Grimes.Fa stayopen 11058f0484fSRodney W. Grimesis non-zero, file descriptors are left open, significantly speeding 11158f0484fSRodney W. Grimesfunctions subsequent calls. This functionality is unnecessary for 11258f0484fSRodney W. Grimes.Fn getgrent 11358f0484fSRodney W. Grimesas it doesn't close its file descriptors by default. It should also 11458f0484fSRodney W. Grimesbe noted that it is dangerous for long-running programs to use this 11558f0484fSRodney W. Grimesfunctionality as the group file may be updated. 11658f0484fSRodney W. Grimes.Pp 11758f0484fSRodney W. GrimesThe 11858f0484fSRodney W. Grimes.Fn setgrent 11958f0484fSRodney W. Grimesfunction 12058f0484fSRodney W. Grimesis identical to 12158f0484fSRodney W. Grimes.Fn setgroupent 12258f0484fSRodney W. Grimeswith an argument of zero. 12358f0484fSRodney W. Grimes.Pp 12458f0484fSRodney W. GrimesThe 12558f0484fSRodney W. Grimes.Fn endgrent 12658f0484fSRodney W. Grimesfunction 12758f0484fSRodney W. Grimescloses any open files. 1286af9798fSGarrett Wollman.Sh YP/NIS INTERACTION 1296af9798fSGarrett WollmanWhen the 1306af9798fSGarrett Wollman.Xr yp 4 1316af9798fSGarrett Wollmangroup database is enabled, the 1326af9798fSGarrett Wollman.Fn getgrnam 1336af9798fSGarrett Wollmanand 1346af9798fSGarrett Wollman.Fn getgrgid 1356af9798fSGarrett Wollmanfunctions use the YP maps 1366af9798fSGarrett Wollman.Dq Li group.byname 1376af9798fSGarrett Wollmanand 1386af9798fSGarrett Wollman.Dq Li group.bygid , 1396af9798fSGarrett Wollmanrespectively, if the requested group is not found in the local 1406af9798fSGarrett Wollman.Pa /etc/group 1416af9798fSGarrett Wollmanfile. The 1426af9798fSGarrett Wollman.Fn getgrent 1436af9798fSGarrett Wollmanfunction will step through the YP map 1446af9798fSGarrett Wollman.Dq Li group.byname 1456af9798fSGarrett Wollmanif the entire map is enabled as described in 1466af9798fSGarrett Wollman.Xr group 5 . 14758f0484fSRodney W. Grimes.Sh RETURN VALUES 14858f0484fSRodney W. GrimesThe functions 14958f0484fSRodney W. Grimes.Fn getgrent , 15058f0484fSRodney W. Grimes.Fn getgrnam , 15158f0484fSRodney W. Grimesand 15258f0484fSRodney W. Grimes.Fn getgrgid , 15358f0484fSRodney W. Grimesreturn a pointer to the group entry if successful; if end-of-file 15458f0484fSRodney W. Grimesis reached or an error occurs a null pointer is returned. 15558f0484fSRodney W. GrimesThe functions 15658f0484fSRodney W. Grimes.Fn setgroupent 15758f0484fSRodney W. Grimesand 15858f0484fSRodney W. Grimes.Fn setgrent 15958f0484fSRodney W. Grimesreturn the value 1 if successful, otherwise the value 16058f0484fSRodney W. Grimes0 is returned. 16158f0484fSRodney W. GrimesThe functions 16258f0484fSRodney W. Grimes.Fn endgrent 16358f0484fSRodney W. Grimesand 16458f0484fSRodney W. Grimes.Fn setgrfile 16558f0484fSRodney W. Grimeshave no return value. 16658f0484fSRodney W. Grimes.Sh FILES 16758f0484fSRodney W. Grimes.Bl -tag -width /etc/group -compact 16858f0484fSRodney W. Grimes.It Pa /etc/group 16958f0484fSRodney W. Grimesgroup database file 17058f0484fSRodney W. Grimes.El 17158f0484fSRodney W. Grimes.Sh SEE ALSO 17228f86af2SMike Pritchard.Xr getpwent 3 , 17328f86af2SMike Pritchard.Xr yp 4 , 17428f86af2SMike Pritchard.Xr group 5 17558f0484fSRodney W. Grimes.Sh HISTORY 17658f0484fSRodney W. GrimesThe functions 17758f0484fSRodney W. Grimes.Fn endgrent , 17858f0484fSRodney W. Grimes.Fn getgrent , 17958f0484fSRodney W. Grimes.Fn getgrnam , 18058f0484fSRodney W. Grimes.Fn getgrgid , 18158f0484fSRodney W. Grimesand 18258f0484fSRodney W. Grimes.Fn setgrent 18358f0484fSRodney W. Grimesappeared in 18458f0484fSRodney W. Grimes.At v7 . 18558f0484fSRodney W. GrimesThe functions 18658f0484fSRodney W. Grimes.Fn setgrfile 18758f0484fSRodney W. Grimesand 18858f0484fSRodney W. Grimes.Fn setgroupent 18958f0484fSRodney W. Grimesappeared in 19058f0484fSRodney W. Grimes.Bx 4.3 Reno . 19158f0484fSRodney W. Grimes.Sh COMPATIBILITY 19258f0484fSRodney W. GrimesThe historic function 19358f0484fSRodney W. Grimes.Fn setgrfile , 19458f0484fSRodney W. Grimeswhich allowed the specification of alternate password databases, has 19558f0484fSRodney W. Grimesbeen deprecated and is no longer available. 19658f0484fSRodney W. Grimes.Sh BUGS 19758f0484fSRodney W. GrimesThe functions 19858f0484fSRodney W. Grimes.Fn getgrent , 19958f0484fSRodney W. Grimes.Fn getgrnam , 20058f0484fSRodney W. Grimes.Fn getgrgid , 20158f0484fSRodney W. Grimes.Fn setgroupent 20258f0484fSRodney W. Grimesand 20358f0484fSRodney W. Grimes.Fn setgrent 20458f0484fSRodney W. Grimesleave their results in an internal static object and return 205c6ff3a1bSSheldon Hearna pointer to that object. 206c6ff3a1bSSheldon HearnSubsequent calls to 20758f0484fSRodney W. Grimesthe same function 20858f0484fSRodney W. Grimeswill modify the same object. 209