summaryrefslogtreecommitdiff
path: root/usr/src/man/man3c/getnetgrent.3c
blob: 024064d63339212ebd57dcd881bae2d6ac8d8c7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH GETNETGRENT 3C "Feb 25, 2017"
.SH NAME
getnetgrent, getnetgrent_r, setnetgrent, endnetgrent, innetgr \- get network
group entry
.SH SYNOPSIS
.nf
#include <netdb.h>

\fBint\fR \fBgetnetgrent\fR(\fBchar **\fR\fImachinep\fR, \fBchar **\fR\fIuserp\fR, \fBchar **\fR\fIdomainp\fR);
.fi

.LP
.nf
\fBint\fR \fBgetnetgrent_r\fR(\fBchar **\fR\fImachinep\fR, \fBchar **\fR\fIuserp\fR, \fBchar **\fR\fIdomainp\fR,
     \fBchar *\fR\fIbuffer\fR, \fBint\fR\fIbuflen\fR);
.fi

.LP
.nf
\fBint\fR \fBsetnetgrent\fR(\fBconst char *\fR\fInetgroup\fR);
.fi

.LP
.nf
\fBint\fR \fBendnetgrent\fR(\fBvoid\fR);
.fi

.LP
.nf
\fBint\fR \fBinnetgr\fR(\fBconst char *\fR\fInetgroup\fR, \fBconst char *\fR\fImachine\fR,
     \fBconst char *\fR\fIuser\fR, \fBconst char *\fR\fIdomain\fR);
.fi

.SH DESCRIPTION
These functions are used to test membership in and enumerate members of
``netgroup'' network groups defined in a system database.  Netgroups are sets
of (machine,user,domain) triples (see \fBnetgroup\fR(4)).
.sp
.LP
These functions consult the source specified for \fBnetgroup\fR in the
\fB/etc/nsswitch.conf\fR file (see \fBnsswitch.conf\fR(4)).
.sp
.LP
The function \fBinnetgr()\fR returns  \fB1\fR if there is a netgroup
\fInetgroup\fR that contains the specified \fImachine,\fR \fIuser,\fR
\fIdomain\fR triple as a member; otherwise it returns  \fB0\fR. Any of the
supplied pointers \fImachine\fR, \fIuser\fR, and \fIdomain\fR may be
\fINULL,\fR signifying a "wild card" that matches all values in that position
of the triple.
.sp
.LP
The \fBinnetgr()\fR function is safe for use in single-threaded and
multithreaded applications.
.sp
.LP
The functions \fBsetnetgrent()\fR, \fBgetnetgrent()\fR, and \fBendnetgrent()\fR
are used to enumerate the members of a given network group.
.sp
.LP
The function \fBsetnetgrent()\fR establishes the network group specified in the
parameter \fInetgroup\fR as the current group whose members are to be
enumerated.
.sp
.LP
Successive calls to the function \fBgetnetgrent()\fR will enumerate the members
of the group established by calling \fBsetnetgrent()\fR; each call returns
\fB1\fR if it succeeds in obtaining another member of the network group, or
\fB0\fR if there are no further members of the group.
.sp
.LP
When calling either \fBgetnetgrent()\fR or \fBgetnetgrent_r()\fR, addresses of
the three character pointers are used as arguments, for example:
.sp
.in +2
.nf
char \fI*mp\fR, \fI*up\fR, \fI*dp\fR;
getnetgrent(\fI&mp\fR, \fI&up\fR, \fI&dp\fR);
.fi
.in -2

.sp
.LP
Upon successful return from  \fBgetnetgrent()\fR, the pointer \fImp\fR points
to a string containing the name of the machine part of the member triple,
\fIup\fR points to a string containing the user name and \fIdp\fR points to a
string containing the domain name. If the pointer returned for \fImp\fR,
\fIup\fR, or \fIdp\fR is \fINULL,\fR it signifies that the element of the
netgroup contains wild card specifier in that position of the triple.
.sp
.LP
The pointers returned by \fBgetnetgrent()\fR point into a buffer allocated by
\fBsetnetgrent()\fR that is reused by each call. This space is released when an
\fBendnetgrent()\fR call is made, and should not be released by the caller.
This implementation is not safe for use in multi-threaded applications.
.sp
.LP
The function \fBgetnetgrent_r()\fR is similar to \fBgetnetgrent()\fR function,
but it uses a buffer supplied by the caller for the space needed to store the
results.   The parameter \fIbuffer\fR should be a pointer to a buffer allocated
by the caller and the length of this buffer should be specified by the
parameter \fIbuflen\fR. The buffer must be large enough to hold the data
associated with the triple. The \fBgetnetgrent_r()\fR function is safe for use
both in single-threaded and multi-threaded applications.
.sp
.LP
The function \fBendnetgrent()\fR frees the space allocated by the previous
\fBsetnetgrent()\fR call.  The equivalent of an \fBendnetgrent()\fR implicitly
performed whenever a  \fBsetnetgrent()\fR call is made to a new network group.
.sp
.LP
Note that while \fBsetnetgrent()\fR and \fBendnetgrent()\fR are safe for use in
multi-threaded applications, the effect of each is process-wide.  Calling
\fBsetnetgrent()\fR resets the enumeration position for all threads. If
multiple threads interleave calls to \fBgetnetgrent_r()\fR each will enumerate
a disjoint subset of the netgroup. Thus the effective use of these functions in
multi-threaded applications may require coordination by the caller.
.SH ERRORS
The function \fBgetnetgrent_r()\fR will return  \fB0\fR and set \fBerrno\fR to
\fBERANGE\fR if the length of the buffer supplied by caller is not large enough
to store the result.  See \fBIntro\fR(2) for the proper usage and
interpretation of \fBerrno\fR in multi-threaded applications.
.sp
.LP
The functions \fBsetnetgrent()\fR and \fBendnetgrent()\fR return \fB0\fR upon
success.
.SH FILES
.ne 2
.na
\fB\fB/etc/nsswitch.conf\fR\fR
.ad
.RS 22n

.RE

.SH ATTRIBUTES
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
MT-Level	See \fBDESCRIPTION\fR section.
.TE

.SH SEE ALSO
\fBIntro\fR(2), \fBIntro\fR(3), \fBnetgroup\fR(4), \fBnsswitch.conf\fR(4),
\fBattributes\fR(5)
.SH WARNINGS
The function \fBgetnetgrent_r()\fR is included in this release on an
uncommitted basis only, and is subject to change or removal in future minor
releases.
.SH NOTES
Network groups are usually stored in network information services,
such as \fBLDAP\fR, or \fBNIS\fR, but may alternatively be stored in
the local \fB/etc/netgroup\fR file.  The \fBnetgroup\fR line of the
\fBnsswitch.conf\fR(4) file determines which of those sources are used.
.sp
.LP
When compiling multi-threaded applications, see  \fBIntro\fR(3), \fINotes On
Multithread Applications\fR, for information about the use of the
\fB_REENTRANT\fR flag.