1setnetgrent(3) Library Functions Manual setnetgrent(3)
2
3
4
6 setnetgrent, endnetgrent, getnetgrent, getnetgrent_r, innetgr - handle
7 network group entries
8
10 Standard C library (libc, -lc)
11
13 #include <netdb.h>
14
15 int setnetgrent(const char *netgroup);
16 void endnetgrent(void);
17
18 int getnetgrent(char **restrict host,
19 char **restrict user, char **restrict domain);
20 int getnetgrent_r(char **restrict host,
21 char **restrict user, char **restrict domain,
22 char buf[restrict .buflen], size_t buflen);
23
24 int innetgr(const char *netgroup, const char *host,
25 const char *user, const char *domain);
26
27 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
28
29 setnetgrent(), endnetgrent(), getnetgrent(), getnetgrent_r(),
30 innetgr():
31 Since glibc 2.19:
32 _DEFAULT_SOURCE
33 glibc 2.19 and earlier:
34 _BSD_SOURCE || _SVID_SOURCE
35
37 The netgroup is a SunOS invention. A netgroup database is a list of
38 string triples (hostname, username, domainname) or other netgroup
39 names. Any of the elements in a triple can be empty, which means that
40 anything matches. The functions described here allow access to the
41 netgroup databases. The file /etc/nsswitch.conf defines what database
42 is searched.
43
44 The setnetgrent() call defines the netgroup that will be searched by
45 subsequent getnetgrent() calls. The getnetgrent() function retrieves
46 the next netgroup entry, and returns pointers in host, user, domain. A
47 null pointer means that the corresponding entry matches any string.
48 The pointers are valid only as long as there is no call to other net‐
49 group-related functions. To avoid this problem you can use the GNU
50 function getnetgrent_r() that stores the strings in the supplied buf‐
51 fer. To free all allocated buffers use endnetgrent().
52
53 In most cases you want to check only if the triplet (hostname, user‐
54 name, domainname) is a member of a netgroup. The function innetgr()
55 can be used for this without calling the above three functions. Again,
56 a null pointer is a wildcard and matches any string. The function is
57 thread-safe.
58
60 These functions return 1 on success and 0 for failure.
61
63 /etc/netgroup
64 /etc/nsswitch.conf
65
67 For an explanation of the terms used in this section, see at‐
68 tributes(7).
69
70 ┌─────────────────┬───────────────┬────────────────────────────────────┐
71 │Interface │ Attribute │ Value │
72 ├─────────────────┼───────────────┼────────────────────────────────────┤
73 │setnetgrent(), │ Thread safety │ MT-Unsafe race:netgrent locale │
74 │getnetgrent_r(), │ │ │
75 │innetgr() │ │ │
76 ├─────────────────┼───────────────┼────────────────────────────────────┤
77 │endnetgrent() │ Thread safety │ MT-Unsafe race:netgrent │
78 ├─────────────────┼───────────────┼────────────────────────────────────┤
79 │getnetgrent() │ Thread safety │ MT-Unsafe race:netgrent │
80 │ │ │ race:netgrentbuf locale │
81 └─────────────────┴───────────────┴────────────────────────────────────┘
82 In the above table, netgrent in race:netgrent signifies that if any of
83 the functions setnetgrent(), getnetgrent_r(), innetgr(), getnetgrent(),
84 or endnetgrent() are used in parallel in different threads of a
85 program, then data races could occur.
86
88 In the BSD implementation, setnetgrent() returns void.
89
91 None.
92
94 setnetgrent(), endnetgrent(), getnetgrent(), and innetgr() are
95 available on most UNIX systems. getnetgrent_r() is not widely
96 available on other systems.
97
99 sethostent(3), setprotoent(3), setservent(3)
100
101
102
103Linux man-pages 6.05 2023-07-30 setnetgrent(3)