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