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

NAME

6       setnetgrent,  endnetgrent, getnetgrent, getnetgrent_r, innetgr - handle
7       network group entries
8

SYNOPSIS

10       #include <netdb.h>
11
12       int setnetgrent(const char *netgroup);
13
14       void endnetgrent(void);
15
16       int getnetgrent(char **host, char **user, char **domain);
17
18       int getnetgrent_r(char **host, char **user,
19                         char **domain, char *buf, size_t buflen);
20
21       int innetgr(const char *netgroup, const char *host,
22                   const char *user, const char *domain);
23
24   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
25
26       setnetgrent(), endnetgrent(), getnetgrent(), getnetgrent_r(),
27       innetgr():
28           Since glibc 2.19:
29               _DEFAULT_SOURCE
30           Glibc 2.19 and earlier:
31               _BSD_SOURCE || _SVID_SOURCE
32

DESCRIPTION

34       The  netgroup  is  a SunOS invention.  A netgroup database is a list of
35       string triples  (hostname,  username,  domainname)  or  other  netgroup
36       names.   Any of the elements in a triple can be empty, which means that
37       anything matches.  The functions described here  allow  access  to  the
38       netgroup  databases.  The file /etc/nsswitch.conf defines what database
39       is searched.
40
41       The setnetgrent() call defines the netgroup that will  be  searched  by
42       subsequent  getnetgrent()  calls.  The getnetgrent() function retrieves
43       the next netgroup entry, and returns pointers in host, user, domain.  A
44       null  pointer  means  that  the corresponding entry matches any string.
45       The pointers are valid only as long as there is no call to  other  net‐
46       group-related  functions.   To  avoid  this problem you can use the GNU
47       function getnetgrent_r() that stores the strings in the  supplied  buf‐
48       fer.  To free all allocated buffers use endnetgrent().
49
50       In  most  cases  you want to check only if the triplet (hostname, user‐
51       name, domainname) is a member of a netgroup.   The  function  innetgr()
52       can be used for this without calling the above three functions.  Again,
53       a null pointer is a wildcard and matches any string.  The  function  is
54       thread-safe.
55

RETURN VALUE

57       These functions return 1 on success and 0 for failure.
58

FILES

60       /etc/netgroup
61       /etc/nsswitch.conf
62

ATTRIBUTES

64       For   an   explanation   of   the  terms  used  in  this  section,  see
65       attributes(7).
66
67       ┌─────────────────┬───────────────┬─────────────────────────┐
68Interface        Attribute     Value                   
69       ├─────────────────┼───────────────┼─────────────────────────┤
70setnetgrent(),   │ Thread safety │ MT-Unsafe race:netgrent │
71getnetgrent_r(), │               │ locale                  │
72innetgr()        │               │                         │
73       ├─────────────────┼───────────────┼─────────────────────────┤
74endnetgrent()    │ Thread safety │ MT-Unsafe race:netgrent │
75       ├─────────────────┼───────────────┼─────────────────────────┤
76getnetgrent()    │ Thread safety │ MT-Unsafe race:netgrent │
77       │                 │               │ race:netgrentbuf locale │
78       └─────────────────┴───────────────┴─────────────────────────┘
79       In the above table, netgrent in race:netgrent signifies that if any  of
80       the functions setnetgrent(), getnetgrent_r(), innetgr(), getnetgrent(),
81       or endnetgrent() are used in parallel in different threads  of  a  pro‐
82       gram, then data races could occur.
83

CONFORMING TO

85       These  functions  are not in POSIX.1, but setnetgrent(), endnetgrent(),
86       getnetgrent(), and innetgr() are available on most UNIX systems.   get‐
87       netgrent_r() is not widely available on other systems.
88

NOTES

90       In the BSD implementation, setnetgrent() returns void.
91

SEE ALSO

93       sethostent(3), setprotoent(3), setservent(3)
94

COLOPHON

96       This  page  is  part of release 4.15 of the Linux man-pages project.  A
97       description of the project, information about reporting bugs,  and  the
98       latest     version     of     this    page,    can    be    found    at
99       https://www.kernel.org/doc/man-pages/.
100
101
102
103GNU                               2017-09-15                    SETNETGRENT(3)
Impressum