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 331130b656SJordan K. Hubbard.\" $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 4758f0484fSRodney W. Grimes.Sh SYNOPSIS 489c6e4f2aSBruce Evans.Fd #include <sys/types.h> 4958f0484fSRodney W. Grimes.Fd #include <grp.h> 5058f0484fSRodney W. Grimes.Ft struct group * 5158f0484fSRodney W. Grimes.Fn getgrent void 5258f0484fSRodney W. Grimes.Ft struct group * 5358f0484fSRodney W. Grimes.Fn getgrnam "const char *name" 5458f0484fSRodney W. Grimes.Ft struct group * 5558f0484fSRodney W. Grimes.Fn getgrgid "gid_t gid" 56712dc76eSMike Pritchard.Ft int 5758f0484fSRodney W. Grimes.Fn setgroupent "int stayopen" 5858f0484fSRodney W. Grimes.\" .Ft void 5958f0484fSRodney W. Grimes.\" .Fn setgrfile "const char *name" 6058f0484fSRodney W. Grimes.Ft int 6158f0484fSRodney W. Grimes.Fn setgrent void 6258f0484fSRodney W. Grimes.Ft void 6358f0484fSRodney W. Grimes.Fn endgrent void 6458f0484fSRodney W. Grimes.Sh DESCRIPTION 6558f0484fSRodney W. GrimesThese functions operate on the group database file 6658f0484fSRodney W. Grimes.Pa /etc/group 6758f0484fSRodney W. Grimeswhich is described 6858f0484fSRodney W. Grimesin 6958f0484fSRodney W. Grimes.Xr group 5 . 7058f0484fSRodney W. GrimesEach line of the database is defined by the structure 7158f0484fSRodney W. Grimes.Ar group 7258f0484fSRodney W. Grimesfound in the include 7358f0484fSRodney W. Grimesfile 7458f0484fSRodney W. Grimes.Aq Pa grp.h : 7558f0484fSRodney W. Grimes.Bd -literal -offset indent 7658f0484fSRodney W. Grimesstruct group { 7758f0484fSRodney W. Grimes char *gr_name; /* group name */ 7858f0484fSRodney W. Grimes char *gr_passwd; /* group password */ 791ffa6450SMike Pritchard int gr_gid; /* group id */ 801ffa6450SMike Pritchard char **gr_mem; /* group members */ 8158f0484fSRodney W. Grimes}; 8258f0484fSRodney W. Grimes.Ed 8358f0484fSRodney W. Grimes.Pp 8458f0484fSRodney W. GrimesThe functions 8558f0484fSRodney W. Grimes.Fn getgrnam 8658f0484fSRodney W. Grimesand 8758f0484fSRodney W. Grimes.Fn getgrgid 8858f0484fSRodney W. Grimessearch the group database for the given group name pointed to by 8958f0484fSRodney W. Grimes.Ar name 9058f0484fSRodney W. Grimesor the group id pointed to by 9158f0484fSRodney W. Grimes.Ar gid , 9258f0484fSRodney W. Grimesrespectively, returning the first one encountered. Identical group 9358f0484fSRodney W. Grimesnames or group gids may result in undefined behavior. 9458f0484fSRodney W. Grimes.Pp 9558f0484fSRodney W. GrimesThe 9658f0484fSRodney W. Grimes.Fn getgrent 9758f0484fSRodney W. Grimesfunction 9858f0484fSRodney W. Grimessequentially reads the group database and is intended for programs 9958f0484fSRodney W. Grimesthat wish to step through the complete list of groups. 10058f0484fSRodney W. Grimes.Pp 10158f0484fSRodney W. GrimesAll three routines will open the group file for reading, if necessary. 10258f0484fSRodney W. Grimes.Pp 10358f0484fSRodney W. GrimesThe 10458f0484fSRodney W. Grimes.Fn setgroupent 10558f0484fSRodney W. Grimesfunction 10658f0484fSRodney W. Grimesopens the file, or rewinds it if it is already open. If 10758f0484fSRodney W. Grimes.Fa stayopen 10858f0484fSRodney W. Grimesis non-zero, file descriptors are left open, significantly speeding 10958f0484fSRodney W. Grimesfunctions subsequent calls. This functionality is unnecessary for 11058f0484fSRodney W. Grimes.Fn getgrent 11158f0484fSRodney W. Grimesas it doesn't close its file descriptors by default. It should also 11258f0484fSRodney W. Grimesbe noted that it is dangerous for long-running programs to use this 11358f0484fSRodney W. Grimesfunctionality as the group file may be updated. 11458f0484fSRodney W. Grimes.Pp 11558f0484fSRodney W. GrimesThe 11658f0484fSRodney W. Grimes.Fn setgrent 11758f0484fSRodney W. Grimesfunction 11858f0484fSRodney W. Grimesis identical to 11958f0484fSRodney W. Grimes.Fn setgroupent 12058f0484fSRodney W. Grimeswith an argument of zero. 12158f0484fSRodney W. Grimes.Pp 12258f0484fSRodney W. GrimesThe 12358f0484fSRodney W. Grimes.Fn endgrent 12458f0484fSRodney W. Grimesfunction 12558f0484fSRodney W. Grimescloses any open files. 1266af9798fSGarrett Wollman.Sh YP/NIS INTERACTION 1276af9798fSGarrett WollmanWhen the 1286af9798fSGarrett Wollman.Xr yp 4 1296af9798fSGarrett Wollmangroup database is enabled, the 1306af9798fSGarrett Wollman.Fn getgrnam 1316af9798fSGarrett Wollmanand 1326af9798fSGarrett Wollman.Fn getgrgid 1336af9798fSGarrett Wollmanfunctions use the YP maps 1346af9798fSGarrett Wollman.Dq Li group.byname 1356af9798fSGarrett Wollmanand 1366af9798fSGarrett Wollman.Dq Li group.bygid , 1376af9798fSGarrett Wollmanrespectively, if the requested group is not found in the local 1386af9798fSGarrett Wollman.Pa /etc/group 1396af9798fSGarrett Wollmanfile. The 1406af9798fSGarrett Wollman.Fn getgrent 1416af9798fSGarrett Wollmanfunction will step through the YP map 1426af9798fSGarrett Wollman.Dq Li group.byname 1436af9798fSGarrett Wollmanif the entire map is enabled as described in 1446af9798fSGarrett Wollman.Xr group 5 . 14558f0484fSRodney W. Grimes.Sh RETURN VALUES 14658f0484fSRodney W. GrimesThe functions 14758f0484fSRodney W. Grimes.Fn getgrent , 14858f0484fSRodney W. Grimes.Fn getgrnam , 14958f0484fSRodney W. Grimesand 15058f0484fSRodney W. Grimes.Fn getgrgid , 15158f0484fSRodney W. Grimesreturn a pointer to the group entry if successful; if end-of-file 15258f0484fSRodney W. Grimesis reached or an error occurs a null pointer is returned. 15358f0484fSRodney W. GrimesThe functions 15458f0484fSRodney W. Grimes.Fn setgroupent 15558f0484fSRodney W. Grimesand 15658f0484fSRodney W. Grimes.Fn setgrent 15758f0484fSRodney W. Grimesreturn the value 1 if successful, otherwise the value 15858f0484fSRodney W. Grimes0 is returned. 15958f0484fSRodney W. GrimesThe functions 16058f0484fSRodney W. Grimes.Fn endgrent 16158f0484fSRodney W. Grimesand 16258f0484fSRodney W. Grimes.Fn setgrfile 16358f0484fSRodney W. Grimeshave no return value. 16458f0484fSRodney W. Grimes.Sh FILES 16558f0484fSRodney W. Grimes.Bl -tag -width /etc/group -compact 16658f0484fSRodney W. Grimes.It Pa /etc/group 16758f0484fSRodney W. Grimesgroup database file 16858f0484fSRodney W. Grimes.El 16958f0484fSRodney W. Grimes.Sh SEE ALSO 17058f0484fSRodney W. Grimes.Fn getpwent 3 , 17175141cc9SWolfram Schneider.Fn yp 4 , 17275141cc9SWolfram Schneider.Fn group 5 17358f0484fSRodney W. Grimes.Sh HISTORY 17458f0484fSRodney W. GrimesThe functions 17558f0484fSRodney W. Grimes.Fn endgrent , 17658f0484fSRodney W. Grimes.Fn getgrent , 17758f0484fSRodney W. Grimes.Fn getgrnam , 17858f0484fSRodney W. Grimes.Fn getgrgid , 17958f0484fSRodney W. Grimesand 18058f0484fSRodney W. Grimes.Fn setgrent 18158f0484fSRodney W. Grimesappeared in 18258f0484fSRodney W. Grimes.At v7 . 18358f0484fSRodney W. GrimesThe functions 18458f0484fSRodney W. Grimes.Fn setgrfile 18558f0484fSRodney W. Grimesand 18658f0484fSRodney W. Grimes.Fn setgroupent 18758f0484fSRodney W. Grimesappeared in 18858f0484fSRodney W. Grimes.Bx 4.3 Reno . 18958f0484fSRodney W. Grimes.Sh COMPATIBILITY 19058f0484fSRodney W. GrimesThe historic function 19158f0484fSRodney W. Grimes.Fn setgrfile , 19258f0484fSRodney W. Grimeswhich allowed the specification of alternate password databases, has 19358f0484fSRodney W. Grimesbeen deprecated and is no longer available. 19458f0484fSRodney W. Grimes.Sh BUGS 19558f0484fSRodney W. GrimesThe functions 19658f0484fSRodney W. Grimes.Fn getgrent , 19758f0484fSRodney W. Grimes.Fn getgrnam , 19858f0484fSRodney W. Grimes.Fn getgrgid , 19958f0484fSRodney W. Grimes.Fn setgroupent 20058f0484fSRodney W. Grimesand 20158f0484fSRodney W. Grimes.Fn setgrent 20258f0484fSRodney W. Grimesleave their results in an internal static object and return 20358f0484fSRodney W. Grimesa pointer to that object. Subsequent calls to 20458f0484fSRodney W. Grimesthe same function 20558f0484fSRodney W. Grimeswill modify the same object. 206