*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->NetBSD man pages -> getgrnam (3)              
Title
Content
Arch
Section
 

GETGRENT(3)

Contents


NAME    [Toc]    [Back]

     getgrent, getgrnam, getgrgid, setgroupent, setgrent, endgrent - group
     database operations

LIBRARY    [Toc]    [Back]

     Standard C Library (libc, -lc)

SYNOPSIS    [Toc]    [Back]

     #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    [Toc]    [Back]

     These functions operate on the group database file 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 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.

     The getgrent() function sequentially reads the group database and is
     intended for programs that wish to step through the complete list of
     groups.

     All three functions will open the group file for reading, if necessary.

     The setgroupent() function opens the file, or rewinds it if it is already
     open.  If stayopen is non-zero, file descriptors are left open, significantly
 speeding functions subsequent 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.

     The setgrent() function is equivalent to setgroupent() with an argument
     of zero.

     The endgrent() function closes any open files.

RETURN VALUES    [Toc]    [Back]

     The functions getgrent(), getgrnam(), and getgrgid(), return a pointer to
     the group entry if successful; if end-of-file is reached or an error
     occurs a null pointer is returned.  The setgroupent() function returns
     the value 1 if successful, otherwise the value 0 is returned.  The
     endgrent() and setgrent() functions have no return value.

FILES    [Toc]    [Back]

     /etc/group  group database file

SEE ALSO    [Toc]    [Back]

      
      
     getpwent(3), group(5), nsswitch.conf(5)

STANDARDS    [Toc]    [Back]

     The getgrnam() and getgrgid() functions conform to ISO/IEC 9945-1:1990
     (``POSIX.1'').

HISTORY    [Toc]    [Back]

     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    [Toc]    [Back]

     The historic function setgrfile(), which allowed the specification of
     alternative password databases, has been deprecated and is no longer
     available.

BUGS    [Toc]    [Back]

     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 possible.
  getgrent() makes no attempt to suppress duplicate information if
     multiple sources are specified in nsswitch.conf(5)

BSD                             April 25, 1999                             BSD
[ Back ]
 Similar pages
Name OS Title
getgrgid_r Tru64 Access group information in the user database
fgetgrent Tru64 Access group information in the user database
getgrnam_r Tru64 Access group information in the user database
getgrent_r Tru64 Access group information in the user database
getgrent Tru64 Access group information in the user database
fgetgrent_r Tru64 Access group information in the user database
getgrgid Tru64 Access group information in the user database
setgrent_r Tru64 Access group information in the user database
setgrent Tru64 Access group information in the user database
endgrent Tru64 Access group information in the user database
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service