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 5032eef9aeSRuslan Ermilov.In sys/types.h 5132eef9aeSRuslan Ermilov.In 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 */ 815567b258SMark Murray gid_t 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. 12858f0484fSRodney W. Grimes.Sh RETURN VALUES 12958f0484fSRodney W. GrimesThe functions 13058f0484fSRodney W. Grimes.Fn getgrent , 13158f0484fSRodney W. Grimes.Fn getgrnam , 13258f0484fSRodney W. Grimesand 13358f0484fSRodney W. Grimes.Fn getgrgid , 13458f0484fSRodney W. Grimesreturn a pointer to the group entry if successful; if end-of-file 13558f0484fSRodney W. Grimesis reached or an error occurs a null pointer is returned. 13658f0484fSRodney W. GrimesThe functions 13758f0484fSRodney W. Grimes.Fn setgroupent 13858f0484fSRodney W. Grimesand 13958f0484fSRodney W. Grimes.Fn setgrent 14058f0484fSRodney W. Grimesreturn the value 1 if successful, otherwise the value 14158f0484fSRodney W. Grimes0 is returned. 14258f0484fSRodney W. GrimesThe functions 14358f0484fSRodney W. Grimes.Fn endgrent 14458f0484fSRodney W. Grimesand 14558f0484fSRodney W. Grimes.Fn setgrfile 14658f0484fSRodney W. Grimeshave no return value. 14758f0484fSRodney W. Grimes.Sh FILES 14858f0484fSRodney W. Grimes.Bl -tag -width /etc/group -compact 14958f0484fSRodney W. Grimes.It Pa /etc/group 15058f0484fSRodney W. Grimesgroup database file 15158f0484fSRodney W. Grimes.El 15258f0484fSRodney W. Grimes.Sh SEE ALSO 15328f86af2SMike Pritchard.Xr getpwent 3 , 154248aee62SJacques Vidrine.Xr group 5 , 155491a8429SRuslan Ermilov.Xr nsswitch.conf 5 , 156491a8429SRuslan Ermilov.Xr yp 8 15758f0484fSRodney W. Grimes.Sh HISTORY 15858f0484fSRodney W. GrimesThe functions 15958f0484fSRodney W. Grimes.Fn endgrent , 16058f0484fSRodney W. Grimes.Fn getgrent , 16158f0484fSRodney W. Grimes.Fn getgrnam , 16258f0484fSRodney W. Grimes.Fn getgrgid , 16358f0484fSRodney W. Grimesand 16458f0484fSRodney W. Grimes.Fn setgrent 16558f0484fSRodney W. Grimesappeared in 16658f0484fSRodney W. Grimes.At v7 . 16758f0484fSRodney W. GrimesThe functions 16858f0484fSRodney W. Grimes.Fn setgrfile 16958f0484fSRodney W. Grimesand 17058f0484fSRodney W. Grimes.Fn setgroupent 17158f0484fSRodney W. Grimesappeared in 17258f0484fSRodney W. Grimes.Bx 4.3 Reno . 17358f0484fSRodney W. Grimes.Sh COMPATIBILITY 17458f0484fSRodney W. GrimesThe historic function 17558f0484fSRodney W. Grimes.Fn setgrfile , 17658f0484fSRodney W. Grimeswhich allowed the specification of alternate password databases, has 17758f0484fSRodney W. Grimesbeen deprecated and is no longer available. 17858f0484fSRodney W. Grimes.Sh BUGS 17958f0484fSRodney W. GrimesThe functions 18058f0484fSRodney W. Grimes.Fn getgrent , 18158f0484fSRodney W. Grimes.Fn getgrnam , 18258f0484fSRodney W. Grimes.Fn getgrgid , 18358f0484fSRodney W. Grimes.Fn setgroupent 18458f0484fSRodney W. Grimesand 18558f0484fSRodney W. Grimes.Fn setgrent 18658f0484fSRodney W. Grimesleave their results in an internal static object and return 187c6ff3a1bSSheldon Hearna pointer to that object. 188c6ff3a1bSSheldon HearnSubsequent calls to 18958f0484fSRodney W. Grimesthe same function 19058f0484fSRodney W. Grimeswill modify the same object. 191248aee62SJacques Vidrine.Pp 192248aee62SJacques VidrineThe functions 193248aee62SJacques Vidrine.Fn getgrent , 194248aee62SJacques Vidrine.Fn endgrent , 195248aee62SJacques Vidrine.Fn setgroupent , 196248aee62SJacques Vidrineand 197248aee62SJacques Vidrine.Fn setgrent 198248aee62SJacques Vidrineare fairly useless in a networked environment and should be 199248aee62SJacques Vidrineavoided, if possible. 200248aee62SJacques Vidrine.Fn getgrent 201248aee62SJacques Vidrinemakes no attempt to suppress duplicate information if multiple 202248aee62SJacques Vidrinesources are specified in 203248aee62SJacques Vidrine.Xr nsswitch.conf 5 . 204