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