Debian Codegraph @

upstream/debian-trixie/man3/setnetgrent.3

raw
1 '\" t
2 .\" Copyright 2002 walter harms ([email protected])
3 .\"
4 .\" SPDX-License-Identifier: GPL-1.0-or-later
5 .\"
6 .\" based on glibc infopages
7 .\" polished - aeb
8 .\"
9 .TH setnetgrent 3 2024-05-02 "Linux man-pages 6.9.1"
10 .SH NAME
11 setnetgrent, endnetgrent, getnetgrent, getnetgrent_r, innetgr \-
12 handle network group entries
13 .SH LIBRARY
14 Standard C library
15 .RI ( libc ", " \-lc )
16 .SH SYNOPSIS
17 .nf
18 .B #include <netdb.h>
19 .P
20 .BI "int setnetgrent(const char *" netgroup );
21 .B "void endnetgrent(void);"
22 .P
23 .BI "int getnetgrent(char **restrict " host ,
24 .BI " char **restrict " user ", char **restrict " domain );
25 .BI "int getnetgrent_r(char **restrict " host ,
26 .BI " char **restrict " user ", char **restrict " domain ,
27 .BI " char " buf "[restrict ." buflen "], size_t " buflen );
28 .P
29 .BI "int innetgr(const char *" netgroup ", const char *" host ,
30 .BI " const char *" user ", const char *" domain );
31 .fi
32 .P
33 .RS -4
34 Feature Test Macro Requirements for glibc (see
35 .BR feature_test_macros (7)):
36 .RE
37 .P
38 .BR \%setnetgrent (),
39 .BR \%endnetgrent (),
40 .BR \%getnetgrent (),
41 .BR \%getnetgrent_r (),
42 .BR \%innetgr ():
43 .nf
44 Since glibc 2.19:
45 _DEFAULT_SOURCE
46 glibc 2.19 and earlier:
47 _BSD_SOURCE || _SVID_SOURCE
48 .fi
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 .P
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 .P
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 .TS
101 allbox;
102 lb lb lbx
103 l l l.
104 Interface Attribute Value
105 T{
106 .na
107 .nh
108 .BR setnetgrent (),
109 .BR getnetgrent_r (),
110 .BR innetgr ()
111 T} Thread safety T{
112 .na
113 .nh
114 MT-Unsafe race:netgrent
115 locale
116 T}
117 T{
118 .na
119 .nh
120 .BR endnetgrent ()
121 T} Thread safety T{
122 .na
123 .nh
124 MT-Unsafe race:netgrent
125 T}
126 T{
127 .na
128 .nh
129 .BR getnetgrent ()
130 T} Thread safety T{
131 .na
132 .nh
133 MT-Unsafe race:netgrent
134 race:netgrentbuf locale
135 T}
136 .TE
137 .P
138 In the above table,
139 .I netgrent
140 in
141 .I race:netgrent
142 signifies that if any of the functions
143 .BR setnetgrent (),
144 .BR getnetgrent_r (),
145 .BR innetgr (),
146 .BR getnetgrent (),
147 or
148 .BR endnetgrent ()
149 are used in parallel in different threads of a program,
150 then data races could occur.
151 .SH VERSIONS
152 In the BSD implementation,
153 .BR setnetgrent ()
154 returns void.
155 .SH STANDARDS
156 None.
157 .SH HISTORY
158 .BR setnetgrent (),
159 .BR endnetgrent (),
160 .BR getnetgrent (),
161 and
162 .BR innetgr ()
163 are available on most UNIX systems.
164 .BR getnetgrent_r ()
165 is not widely available on other systems.
166 .\" getnetgrent_r() is on Solaris 8 and AIX 5.1, but not the BSDs.
167 .SH SEE ALSO
168 .BR sethostent (3),
169 .BR setprotoent (3),
170 .BR setservent (3)