1GETGRENT(3)                Linux Programmer's Manual               GETGRENT(3)
2
3
4

NAME

6       getgrent, setgrent, endgrent - get group file entry
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <grp.h>
11
12       struct group *getgrent(void);
13
14       void setgrent(void);
15
16       void endgrent(void);
17
18   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20       setgrent():
21           _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
22           _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED ||
23           /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
24
25       getgrent(), endgrent():
26           _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
27           _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
28

DESCRIPTION

30       The getgrent() function returns a pointer to a structure containing the
31       broken-out fields of a record in the group database  (e.g.,  the  local
32       group  file  /etc/group,  NIS, and LDAP).  The first time getgrent() is
33       called, it returns the first entry; thereafter, it  returns  successive
34       entries.
35
36       The setgrent() function rewinds to the beginning of the group database,
37       to allow repeated scans.
38
39       The endgrent() function is used to close the group database  after  all
40       processing has been performed.
41
42       The group structure is defined in <grp.h> as follows:
43
44           struct group {
45               char   *gr_name;       /* group name */
46               char   *gr_passwd;     /* group password */
47               gid_t   gr_gid;        /* group ID */
48               char  **gr_mem;        /* group members */
49           };
50
51       For more information about the fields of this structure, see group(5).
52

RETURN VALUE

54       The getgrent() function returns a pointer to a group structure, or NULL
55       if there are no more entries or an error occurs.
56
57       Upon error, errno may be set.  If one wants to check  errno  after  the
58       call, it should be set to zero before the call.
59
60       The  return value may point to a static area, and may be overwritten by
61       subsequent calls to getgrent(), getgrgid(3), or getgrnam(3).   (Do  not
62       pass the returned pointer to free(3).)
63

ERRORS

65       EINTR  A signal was caught.
66
67       EIO    I/O error.
68
69       EMFILE The calling process already has too many open files.
70
71       ENFILE Too many open files in the system.
72
73       ENOMEM Insufficient memory to allocate group structure.
74
75       ERANGE Insufficient buffer space supplied.
76

FILES

78       /etc/group
79              local group database file
80

ATTRIBUTES

82   Multithreading (see pthreads(7))
83       The getgrent() function is not thread-safe.
84
85       The setgrent() and endgrent() functions are thread-safe.
86

CONFORMING TO

88       SVr4, 4.3BSD, POSIX.1-2001.
89

SEE ALSO

91       fgetgrent(3), getgrent_r(3), getgrgid(3), getgrnam(3), getgrouplist(3),
92       putgrent(3), group(5)
93

COLOPHON

95       This page is part of release 3.53 of the Linux  man-pages  project.   A
96       description  of  the project, and information about reporting bugs, can
97       be found at http://www.kernel.org/doc/man-pages/.
98
99
100
101                                  2013-06-21                       GETGRENT(3)
Impressum