Home
Search all pages
Subjects
By activity
Professions, Sciences, Humanities, Business, ...
User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...
Text Strings
Conversions, tests, processing, manipulation,...
Math
Integer, Floating point, Matrix, Statistics, Boolean, ...
Processing
Algorithms, Memory, Process control, Debugging, ...
Stored Data
Data storage, Integrity, Encryption, Compression, ...
Communications
Networks, protocols, Interprocess, Remote, Client Server, ...
Hard World Timing, Calendar and Clock, Audio, Video, Printer, Controls...
File System
Management, Filtering, File & Directory access, Viewers, ...
|
|
|
RocketLink!--> Man page versions:
OpenBSD
FreeBSD
RedHat
Others
GETGRENT(3) OpenBSD Programmer's Manual GETGRENT(3)
NAME
getgrent, getgrnam, getgrgid, setgroupent, setgrent, endgrent - group
database operations
SYNOPSIS
#include <sys/types.h>
#include <grp.h>
struct group *
getgrent(void);
struct group *
getgrnam(const char *name);
struct group *
getgrgid(gid_t gid);
int
setgroupent(int stayopen);
void
setgrent(void);
void
endgrent(void);
DESCRIPTION
These functions operate on the group database file /etc/group which is
described in group(5). Each line of the database is defined by the
structure struct group found in the include file <grp.h>:
struct group {
char *gr_name; /* group name */
char *gr_passwd; /* group password */
gid_t gr_gid; /* group id */
char **gr_mem; /* group members */
};
The functions getgrnam() and getgrgid() search the group database for the
given group name pointed to by name or the group ID pointed to by gid,
respectively, returning the first one encountered. Identical group names
or group GIDs may result in undefined behavior.
getgrent() sequentially reads the group database and is intended for pro-
grams that wish to step through the complete list of groups.
All three routines will open the group file for reading, if necessary.
setgroupent() opens the file, or rewinds it if it is already open. If
stayopen is non-zero, file descriptors are left open, significantly
speeding subsequent function calls. This functionality is unnecessary
for getgrent() as it doesn't close its file descriptors by default. It
should also be noted that it is dangerous for long-running programs to
use this functionality as the group file may be updated.
setgrent() is equivalent to setgroupent() with an argument of zero.
The endgrent() function closes any open files.
RETURN VALUES
The functions getgrent(), getgrnam(), and getgrgid() return a pointer to
the group entry if successful; if end-of-file is reached or an error oc-
curs a null pointer is returned. The setgroupent() function returns the
value 1 if successful, otherwise 0. The endgrent() and setgrent() func-
tions have no return value.
FILES
/etc/group group database file
SEE ALSO
getpwent(3), group(5)
HISTORY
The functions endgrent(), getgrent(), getgrnam(), getgrgid(), and
setgrent() appeared in Version 7 AT&T UNIX. The functions setgrfile()
and setgroupent() appeared in 4.3BSD-Reno.
COMPATIBILITY
The historic function setgrfile(3), which allowed the specification of
alternate password databases, has been deprecated and is no longer avail-
able.
BUGS
The functions getgrent(), getgrnam(), getgrgid(), setgroupent() and
setgrent() leave their results in an internal static object and return a
pointer to that object. Subsequent calls to the same function will modify
the same object.
The functions getgrent(), endgrent(), setgroupent(), and setgrent() are
fairly useless in a networked environment and should be avoided, if pos-
sible.
OpenBSD 2.6 April 19, 1994 2
Source: OpenBSD 2.6 man pages. Copyright: Portions are copyrighted by BERKELEY SOFTWARE DESIGN, INC., The Regents of the University of California, Massachusetts Institute of Technology, Free Software Foundation, FreeBSD Inc., and others. |
(Corrections, notes, and links courtesy of RocketAware.com)
FreeBSD Sources for getgrent(3) functions OpenBSD sources for getgrent(3)
Up to: Process Limits: Identity - Process ownership and Identity
RocketLink!--> Man page versions:
OpenBSD
FreeBSD
RedHat
Others
Rapid-Links:
Search | About | Comments | Submit Path: RocketAware > man pages >
getgrent.3/
RocketAware.com is a service of Mib Software Copyright 1999, Forrest J. Cavalier III. All Rights Reserved. We welcome submissions and comments
|