]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) |
2297bf0e | 2 | .\" |
38f20bb9 | 3 | .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE) |
b18188c5 | 4 | .\" Distributed under GPL |
38f20bb9 | 5 | .\" %%%LICENSE_END |
a5e73dd4 | 6 | .\" |
fea681da MK |
7 | .\" based on glibc infopages |
8 | .\" polished - aeb | |
a5e73dd4 | 9 | .\" |
4b8c67d9 | 10 | .TH SETNETGRENT 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
c13182ef | 11 | .SH NAME |
fea681da MK |
12 | setnetgrent, endnetgrent, getnetgrent, getnetgrent_r, innetgr \- |
13 | handle network group entries | |
14 | .SH SYNOPSIS | |
088a639b | 15 | .nf |
fea681da | 16 | .B #include <netdb.h> |
dbfe9c70 | 17 | .PP |
fea681da | 18 | .BI "int setnetgrent(const char *" netgroup ); |
dbfe9c70 | 19 | .PP |
0daa9e92 | 20 | .B "void endnetgrent(void);" |
dbfe9c70 | 21 | .PP |
fea681da | 22 | .BI "int getnetgrent(char **" host ", char **" user ", char **" domain ); |
dbfe9c70 | 23 | .PP |
fea681da | 24 | .BI "int getnetgrent_r(char **" host ", char **" user "," |
d7f5fd1b | 25 | .BI " char **" domain ", char *" buf ", size_t " buflen ); |
dbfe9c70 | 26 | .PP |
fea681da | 27 | .BI "int innetgr(const char *" netgroup ", const char *" host "," |
088a639b MK |
28 | .BI " const char *" user ", const char *" domain ); |
29 | .fi | |
68e4db0a | 30 | .PP |
cc4615cc MK |
31 | .in -4n |
32 | Feature Test Macro Requirements for glibc (see | |
33 | .BR feature_test_macros (7)): | |
34 | .in | |
68e4db0a | 35 | .PP |
cc4615cc MK |
36 | .ad l |
37 | .BR setnetgrent (), | |
38 | .BR endnetgrent (), | |
39 | .BR getnetgrent (), | |
40 | .BR getnetgrent_r (), | |
41 | .BR innetgr (): | |
51c612fb MK |
42 | Since glibc 2.19: |
43 | _DEFAULT_SOURCE | |
44 | Glibc 2.19 and earlier: | |
45 | _BSD_SOURCE || _SVID_SOURCE | |
cc4615cc | 46 | .ad b |
c13182ef MK |
47 | .SH DESCRIPTION |
48 | The | |
f19a0f03 | 49 | .I netgroup |
c13182ef MK |
50 | is a SunOS invention. |
51 | A netgroup database is a list of string triples | |
74d32233 | 52 | .RI ( hostname ", " username ", " domainname ) |
c13182ef MK |
53 | or other netgroup names. |
54 | Any of the elements in a triple can be empty, | |
fea681da MK |
55 | which means that anything matches. |
56 | The functions described here allow access to the netgroup databases. | |
57 | The file | |
58 | .I /etc/nsswitch.conf | |
59 | defines what database is searched. | |
60 | .PP | |
61 | The | |
63aa9df0 | 62 | .BR setnetgrent () |
fea681da | 63 | call defines the netgroup that will be searched by subsequent |
63aa9df0 | 64 | .BR getnetgrent () |
c13182ef MK |
65 | calls. |
66 | The | |
63aa9df0 | 67 | .BR getnetgrent () |
fea681da MK |
68 | function retrieves the next netgroup entry, and returns pointers in |
69 | .IR host , | |
70 | .IR user , | |
71 | .IR domain . | |
b437fdd9 | 72 | A null pointer means that the corresponding entry matches any string. |
fea681da | 73 | The pointers are valid only as long as there is no call to other |
28442c8f | 74 | netgroup-related functions. |
fea681da | 75 | To avoid this problem you can use the GNU function |
63aa9df0 | 76 | .BR getnetgrent_r () |
fea681da MK |
77 | that stores the strings in the supplied buffer. |
78 | To free all allocated buffers use | |
63aa9df0 | 79 | .BR endnetgrent (). |
fea681da | 80 | .PP |
33a0ccb2 | 81 | In most cases you want to check only if the triplet |
74d32233 | 82 | .RI ( hostname ", " username ", " domainname ) |
c13182ef MK |
83 | is a member of a netgroup. |
84 | The function | |
63aa9df0 | 85 | .BR innetgr () |
fea681da | 86 | can be used for this without calling the above three functions. |
b437fdd9 | 87 | Again, a null pointer is a wildcard and matches any string. |
fea681da | 88 | The function is thread-safe. |
47297adb | 89 | .SH RETURN VALUE |
2b2581ee | 90 | These functions return 1 on success and 0 for failure. |
fea681da MK |
91 | .SH FILES |
92 | .I /etc/netgroup | |
93 | .br | |
94 | .I /etc/nsswitch.conf | |
ff446578 ZL |
95 | .SH ATTRIBUTES |
96 | For an explanation of the terms used in this section, see | |
97 | .BR attributes (7). | |
98 | .TS | |
99 | allbox; | |
100 | lbw16 lb lbw23 | |
101 | l l l. | |
102 | Interface Attribute Value | |
103 | T{ | |
104 | .BR setnetgrent (), | |
105 | .br | |
106 | .BR getnetgrent_r (), | |
107 | .br | |
108 | .BR innetgr () | |
109 | T} Thread safety T{ | |
110 | MT-Unsafe race:netgrent | |
111 | .br | |
112 | locale | |
113 | T} | |
114 | T{ | |
115 | .BR endnetgrent () | |
116 | T} Thread safety MT-Unsafe race:netgrent | |
117 | T{ | |
118 | .BR getnetgrent () | |
119 | T} Thread safety T{ | |
120 | MT-Unsafe race:netgrent | |
121 | .br | |
122 | race:netgrentbuf locale | |
123 | T} | |
124 | .TE | |
847e0d88 | 125 | .sp 1 |
ff446578 ZL |
126 | In the above table, |
127 | .I netgrent | |
128 | in | |
129 | .I race:netgrent | |
130 | signifies that if any of the functions | |
bf7bc8b8 MK |
131 | .BR setnetgrent (), |
132 | .BR getnetgrent_r (), | |
133 | .BR innetgr (), | |
134 | .BR getnetgrent (), | |
ff446578 | 135 | or |
bf7bc8b8 | 136 | .BR endnetgrent () |
ff446578 ZL |
137 | are used in parallel in different threads of a program, |
138 | then data races could occur. | |
fd9d7bd6 | 139 | .SH CONFORMING TO |
9afbac85 | 140 | These functions are not in POSIX.1, but |
fd9d7bd6 MK |
141 | .BR setnetgrent (), |
142 | .BR endnetgrent (), | |
143 | .BR getnetgrent (), | |
144 | and | |
145 | .BR innetgr () | |
008f1ecc | 146 | are available on most UNIX systems. |
fd9d7bd6 MK |
147 | .BR getnetgrent_r () |
148 | is not widely available on other systems. | |
149 | .\" getnetgrent_r() is on Solaris 8 and AIX 5.1, but not the BSDs. | |
fea681da MK |
150 | .SH NOTES |
151 | In the BSD implementation, | |
63aa9df0 | 152 | .BR setnetgrent () |
fea681da | 153 | returns void. |
47297adb | 154 | .SH SEE ALSO |
fea681da | 155 | .BR sethostent (3), |
f0c34053 MK |
156 | .BR setprotoent (3), |
157 | .BR setservent (3) |