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