process_madvise.2: wfix
[man-pages.git] / man3 / setnetgrent.3
blob440cf28463bec20e7eb6e9c4c6a0d27e9ec69b26
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 .B "void endnetgrent(void);"
20 .PP
21 .BI "int getnetgrent(char **" host ", char **" user ", char **" domain );
22 .BI "int getnetgrent_r(char **" host ", char **" user ","
23 .BI "                  char **" domain ", char *" buf ", size_t " buflen );
24 .PP
25 .BI "int innetgr(const char *" netgroup ", const char *" host ","
26 .BI "                  const char *" user ", const char *" domain );
27 .fi
28 .PP
29 .RS -4
30 Feature Test Macro Requirements for glibc (see
31 .BR feature_test_macros (7)):
32 .RE
33 .ad l
34 .PP
35 .nh
36 .BR setnetgrent (),
37 .BR endnetgrent (),
38 .BR getnetgrent (),
39 .BR getnetgrent_r (),
40 .BR innetgr ():
41 .hy
42 .nf
43     Since glibc 2.19:
44         _DEFAULT_SOURCE
45     Glibc 2.19 and earlier:
46         _BSD_SOURCE || _SVID_SOURCE
47 .fi
48 .ad
49 .SH DESCRIPTION
50 The
51 .I netgroup
52 is a SunOS invention.
53 A netgroup database is a list of string triples
54 .RI ( hostname ", " username ", " domainname )
55 or other netgroup names.
56 Any of the elements in a triple can be empty,
57 which means that anything matches.
58 The functions described here allow access to the netgroup databases.
59 The file
60 .I /etc/nsswitch.conf
61 defines what database is searched.
62 .PP
63 The
64 .BR setnetgrent ()
65 call defines the netgroup that will be searched by subsequent
66 .BR getnetgrent ()
67 calls.
68 The
69 .BR getnetgrent ()
70 function retrieves the next netgroup entry, and returns pointers in
71 .IR host ,
72 .IR user ,
73 .IR domain .
74 A null pointer means that the corresponding entry matches any string.
75 The pointers are valid only as long as there is no call to other
76 netgroup-related functions.
77 To avoid this problem you can use the GNU function
78 .BR getnetgrent_r ()
79 that stores the strings in the supplied buffer.
80 To free all allocated buffers use
81 .BR endnetgrent ().
82 .PP
83 In most cases you want to check only if the triplet
84 .RI ( hostname ", " username ", " domainname )
85 is a member of a netgroup.
86 The function
87 .BR innetgr ()
88 can be used for this without calling the above three functions.
89 Again, a null pointer is a wildcard and matches any string.
90 The function is thread-safe.
91 .SH RETURN VALUE
92 These functions return 1 on success and 0 for failure.
93 .SH FILES
94 .I /etc/netgroup
95 .br
96 .I /etc/nsswitch.conf
97 .SH ATTRIBUTES
98 For an explanation of the terms used in this section, see
99 .BR attributes (7).
100 .ad l
103 allbox;
104 lb lb lbx
105 l l l.
106 Interface       Attribute       Value
108 .BR setnetgrent (),
109 .BR getnetgrent_r (),
110 .BR innetgr ()
111 T}      Thread safety   T{
112 MT-Unsafe race:netgrent
113 locale
116 .BR endnetgrent ()
117 T}      Thread safety   T{
118 MT-Unsafe race:netgrent
121 .BR getnetgrent ()
122 T}      Thread safety   T{
123 MT-Unsafe race:netgrent
124 race:netgrentbuf locale
129 .sp 1
130 In the above table,
131 .I netgrent
133 .I race:netgrent
134 signifies that if any of the functions
135 .BR setnetgrent (),
136 .BR getnetgrent_r (),
137 .BR innetgr (),
138 .BR getnetgrent (),
140 .BR endnetgrent ()
141 are used in parallel in different threads of a program,
142 then data races could occur.
143 .SH CONFORMING TO
144 These functions are not in POSIX.1, but
145 .BR setnetgrent (),
146 .BR endnetgrent (),
147 .BR getnetgrent (),
149 .BR innetgr ()
150 are available on most UNIX systems.
151 .BR getnetgrent_r ()
152 is not widely available on other systems.
153 .\" getnetgrent_r() is on Solaris 8 and AIX 5.1, but not the BSDs.
154 .SH NOTES
155 In the BSD implementation,
156 .BR setnetgrent ()
157 returns void.
158 .SH SEE ALSO
159 .BR sethostent (3),
160 .BR setprotoent (3),
161 .BR setservent (3)