]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/setnetgrent.3
mlock.2: tfix
[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 2017-09-15 "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 .PP
18 .BI "int setnetgrent(const char *" netgroup );
19 .PP
20 .B "void endnetgrent(void);"
21 .PP
22 .BI "int getnetgrent(char **" host ", char **" user ", char **" domain );
23 .PP
24 .BI "int getnetgrent_r(char **" host ", char **" user ","
25 .BI " char **" domain ", char *" buf ", size_t " buflen );
26 .PP
27 .BI "int innetgr(const char *" netgroup ", const char *" host ","
28 .BI " const char *" user ", const char *" domain );
29 .fi
30 .PP
31 .in -4n
32 Feature Test Macro Requirements for glibc (see
33 .BR feature_test_macros (7)):
34 .in
35 .PP
36 .ad l
37 .BR setnetgrent (),
38 .BR endnetgrent (),
39 .BR getnetgrent (),
40 .BR getnetgrent_r (),
41 .BR innetgr ():
42 Since glibc 2.19:
43 _DEFAULT_SOURCE
44 Glibc 2.19 and earlier:
45 _BSD_SOURCE || _SVID_SOURCE
46 .ad b
47 .SH DESCRIPTION
48 The
49 .I netgroup
50 is a SunOS invention.
51 A netgroup database is a list of string triples
52 .RI ( hostname ", " username ", " domainname )
53 or other netgroup names.
54 Any of the elements in a triple can be empty,
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
62 .BR setnetgrent ()
63 call defines the netgroup that will be searched by subsequent
64 .BR getnetgrent ()
65 calls.
66 The
67 .BR getnetgrent ()
68 function retrieves the next netgroup entry, and returns pointers in
69 .IR host ,
70 .IR user ,
71 .IR domain .
72 A null pointer means that the corresponding entry matches any string.
73 The pointers are valid only as long as there is no call to other
74 netgroup-related functions.
75 To avoid this problem you can use the GNU function
76 .BR getnetgrent_r ()
77 that stores the strings in the supplied buffer.
78 To free all allocated buffers use
79 .BR endnetgrent ().
80 .PP
81 In most cases you want to check only if the triplet
82 .RI ( hostname ", " username ", " domainname )
83 is a member of a netgroup.
84 The function
85 .BR innetgr ()
86 can be used for this without calling the above three functions.
87 Again, a null pointer is a wildcard and matches any string.
88 The function is thread-safe.
89 .SH RETURN VALUE
90 These functions return 1 on success and 0 for failure.
91 .SH FILES
92 .I /etc/netgroup
93 .br
94 .I /etc/nsswitch.conf
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
125 .sp 1
126 In the above table,
127 .I netgrent
128 in
129 .I race:netgrent
130 signifies that if any of the functions
131 .BR setnetgrent (),
132 .BR getnetgrent_r (),
133 .BR innetgr (),
134 .BR getnetgrent (),
135 or
136 .BR endnetgrent ()
137 are used in parallel in different threads of a program,
138 then data races could occur.
139 .SH CONFORMING TO
140 These functions are not in POSIX.1, but
141 .BR setnetgrent (),
142 .BR endnetgrent (),
143 .BR getnetgrent (),
144 and
145 .BR innetgr ()
146 are available on most UNIX systems.
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.
150 .SH NOTES
151 In the BSD implementation,
152 .BR setnetgrent ()
153 returns void.
154 .SH SEE ALSO
155 .BR sethostent (3),
156 .BR setprotoent (3),
157 .BR setservent (3)