|
NAMEgetgrent , getgrent_r ,
getgrnam , getgrnam_r ,
getgrgid , getgrgid_r ,
setgroupent , setgrent ,
endgrent —
group database operations
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <grp.h>
struct group *
int
struct group *
int
struct group *
int
int
void
void
DESCRIPTIONThese 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 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 The The functions These functions will open the group file for reading, if necessary. The The The RETURN VALUESThe functionsgetgrent (),
getgrnam (), and getgrgid (),
return a pointer to a group structure on success or
NULL if the entry is not found or if an error occurs.
If an error does occur, errno will be set. Note that
programs must explicitly set errno to zero before
calling any of these functions if they need to distinguish between a
non-existent entry and an error. The functions
getgrent_r (), getgrnam_r (),
and getgrgid_r () return 0 if no error occurred, or an
error number to indicate failure. It is not an error if a matching entry is
not found. (Thus, if result is set to
NULL and the return value is 0, no matching entry
exists.)
The function FILES
COMPATIBILITYThe historic functionsetgrfile (), which allowed the
specification of alternate password databases, has been deprecated and is no
longer available.
SEE ALSOgetpwent(3), group(5), nsswitch.conf(5), yp(8)STANDARDSThegetgrent (), getgrnam (),
getgrnam_r (), getgrgid (),
getgrgid_r () and endgrent ()
functions conform to ISO/IEC 9945-1:1996
(“POSIX.1”). The setgrent ()
function differs from that standard in that its return type is
int rather than void.
HISTORYThe functionsendgrent (),
getgrent (), getgrnam (),
getgrgid (), and setgrent ()
appeared in Version 7 AT&T UNIX. The
functions setgrfile () and
setgroupent () appeared in
4.3BSD-Reno. The functions
getgrent_r (), getgrnam_r (),
and getgrgid_r () appeared in FreeBSD
5.1.
BUGSThe functionsgetgrent (),
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
Visit the GSP FreeBSD Man Page Interface. |