2 .\" Copyright 1989 AT&T
3 .\" Copyright (C) 2004, Sun Microsystems, Inc. All Rights Reserved
4 .\" 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.
5 .\" 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.
6 .\" 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]
7 .TH YPCLNT 3NSL "Feb 25, 2017"
9 ypclnt, yp_get_default_domain, yp_bind, yp_unbind, yp_match, yp_first, yp_next,
10 yp_all, yp_order, yp_master, yperr_string, ypprot_err \- NIS Version 2 client
15 \fBcc\fR [ \fB-flag\fR... ] \fIfile\fR\&.\|.\|. \fB-lnsl\fR [ \fIlibrary\fR...]
16 #include <rpcsvc/ypclnt.h>
17 #include <rpcsvc/yp_prot.h>
21 \fBint\fR \fByp_bind\fR(\fBchar *\fR\fIindomain\fR);
26 \fBvoid\fR \fByp_unbind\fR (\fBchar *\fR\fIindomain\fR);
31 \fBint\fR \fByp_get_default_domain\fR(\fBchar **\fR\fIoutdomain\fR);
36 \fBint\fR \fByp_match\fR(\fBchar *\fR\fIindomain\fR, \fBchar *\fR\fIinmap\fR, \fBchar *\fR\fIinkey\fR, \fBint\fR \fIinkeylen\fR,
37 \fBchar *\fR\fBchar **\fR\fIoutval\fR, \fBint *\fR\fIoutvallen\fR);
42 \fBint\fR \fByp_first\fR(\fBchar *\fR\fIindomain\fR, \fBchar *\fR\fIinmap\fR, \fBchar **\fR\fIoutkey\fR, \fBint *\fR\fIoutkeylen\fR,
43 \fBchar **\fR\fIoutval\fR, \fBint *\fR\fIoutvallen\fR);
48 \fBint\fR \fByp_next\fR(\fBchar *\fR\fIindomain\fR, \fBchar *\fR\fIinmap\fR, \fBchar *\fR\fIinkey\fR, \fBint *\fR\fIinkeylen\fR,
49 \fBchar **\fR\fIoutkey\fR, \fBint *\fR\fIoutkeylen\fR, \fBchar **\fR\fIoutval\fR,
50 \fBint *\fR\fIoutvallen\fR);
55 \fBint\fR \fByp_all\fR(\fBchar *\fR\fIindomain\fR, \fBchar *\fR\fIinmap\fR, \fBstruct ypall_callback *\fR\fIincallback\fR);
60 \fBint\fR \fByp_order\fR(\fBchar *\fR\fIindomain\fR, \fBchar *\fR\fIinmap\fR, \fBunsigned long *\fR\fIoutorder\fR);
65 \fBint\fR \fByp_master\fR(\fBchar *\fR\fIindomain\fR, \fBchar *\fR\fIinmap\fR, \fBchar **\fR\fIoutname\fR);
70 \fBchar *\fR\fByperr_string\fR(\fBint\fR \fIincode\fR);
75 \fBint\fR \fBypprot_err\fR(\fBchar *\fR\fIdomain\fR);
80 This package of functions provides an interface to \fBNIS\fR, Network
81 Information Service Version 2, formerly referred to as \fBYP\fR.
82 For commands used to access \fBNIS\fR from a
83 client machine, see \fBypbind\fR(1M), \fBypwhich\fR(1), \fBypmatch\fR(1), and
84 \fBypcat\fR(1). The package can be loaded from the standard library,
85 \fB/usr/lib/libnsl.so.1\fR.
88 All input parameter names begin with \fIin\fR. Output parameters begin with
89 \fIout\fR. Output parameters of type \fBchar **\fR should be addresses of
90 uninitialized character pointers. Memory is allocated by the NIS client package
91 using \fBmalloc\fR(3C) and can be freed by the user code if it has no
92 continuing need for it. For each \fIoutkey\fR and \fIoutval\fR, two extra bytes
93 of memory are allocated at the end that contain NEWLINE and \fInull\fR,
94 respectively, but these two bytes are not reflected in \fIoutkeylen\fR or
95 \fIoutvallen\fR. The \fIindomain\fR and \fIinmap\fR strings must be non-null
96 and null-terminated. String parameters that are accompanied by a count
97 parameter may not be \fInull\fR, but they may point to null strings, with the
98 count parameter indicating this. Counted strings need not be null-terminated.
101 All functions in this package of type \fIint\fR return \fB0\fR if they succeed.
102 Otherwise, they return a failure code (\fBYPERR_\fR\fIxxxx\fR). Failure codes
103 are described in the \fBERRORS\fR section.
107 \fB\fByp_bind()\fR\fR
110 To use the NIS name services, the client process must be "bound" to an NIS
111 server that serves the appropriate domain using \fByp_bind()\fR. Binding need
112 not be done explicitly by user code. Binding is done automatically whenever an
113 NIS lookup function is called. The \fByp_bind()\fR function can be called
114 directly for processes that make use of a backup strategy , for example, a
115 local file in cases when NIS services are not available. A process should call
116 \fByp_unbind()\fR when it is finished using \fBNIS\fR in order to free up
123 \fB\fByp_unbind()\fR\fR
126 Each binding allocates or uses up one client process socket descriptor. Each
127 bound domain costs one socket descriptor. However, multiple requests to the
128 same domain use that same descriptor. The \fByp_unbind()\fR function is
129 available at the client interface for processes that explicitly manage their
130 socket descriptors while accessing multiple domains. The call to
131 \fByp_unbind()\fR makes the domain \fIunbound\fR, and frees all per-process and
132 per-node resources used to bind it.
134 If an RPC failure results upon use of a binding, that domain will be unbound
135 automatically. At that point, the \fBypclnt()\fR layer will retry a few more
136 times or until the operation succeeds, provided that \fBrpcbind\fR(1M) and
137 \fBypbind\fR(1M) are running, and either:
142 The client process cannot bind a server for the proper domain; or
148 RPC requests to the server fail.
152 Under the following circumstances, the \fBypclnt\fR layer will return control
153 to the user code, with either an error or success code and the results:
158 If an error is not RPC-related.
164 If \fBrpcbind\fR is not running.
170 If \fBypbind\fR is not running.
176 If a bound \fBypserv\fR process returns any answer (success or failure).
183 \fB\fByp_get_default_domain()\fR\fR
186 \fBNIS\fR lookup calls require a map name and a domain name, at minimum. The
187 client process should know the name of the map of interest. Client processes
188 fetch the node's default domain by calling \fByp_get_default_domain()\fR and
189 use the returned \fIoutdomain\fR as the \fIindomain\fR parameter to successive
190 \fBNIS\fR name service calls. The domain returned is the same as that returned
191 using the \fBSI_SRPC_DOMAIN\fR command to the \fBsysinfo\fR(2) system call. The
192 value returned in \fIoutdomain\fR should not be freed.
198 \fB\fByp_match()\fR\fR
201 The \fByp_match()\fR function returns the value associated with a passed key.
202 This key must be exact because no pattern matching is available.
203 \fByp_match()\fR requires a full YP map name, such as \fBhosts.byname\fR,
204 instead of the nickname \fBhosts\fR.
210 \fB\fByp_first()\fR\fR
213 The \fByp_first()\fR function returns the first key-value pair from the named
214 map in the named domain.
220 \fB\fByp_next()\fR\fR
223 The \fByp_next()\fR function returns the next key-value pair in a named map.
224 The \fIinkey\fR parameter must be the \fIoutkey\fR returned from an initial
225 call to \fByp_first()\fR (to get the second key-value pair) or the one returned
226 from the \fIn\fRth call to \fByp_next()\fR (to get the \fIn\fRth + second
227 key-value pair). Similarly, the \fIinkeylen\fR parameter must be the
228 \fIoutkeylen\fR returned from the earlier \fByp_first()\fR or \fByp_next()\fR
231 The concept of first and next is particular to the structure of the NIS map
232 being processed. Retrieval order is not related to either the lexical order
233 within any original (non-NIS name service) data base, or to any obvious
234 numerical sorting order on the keys, values, or key-value pairs. The only
235 ordering guarantee is that if the \fByp_first()\fR function is called on a
236 particular map, and then the \fByp_next()\fR function is repeatedly called on
237 the same map at the same server until the call fails with a reason of
238 \fBYPERR_NOMORE\fR, every entry in the data base is seen exactly once. Further,
239 if the same sequence of operations is performed on the same map at the same
240 server, the entries are seen in the same order.
242 Under conditions of heavy server load or server failure, the domain can become
243 unbound, then bound once again (perhaps to a different server) while a client
244 is running. This binding can cause a break in one of the enumeration rules.
245 Specific entries may be seen twice by the client, or not at all. This approach
246 protects the client from error messages that would otherwise be returned in the
247 midst of the enumeration. For a better solution to enumerating all entries in a
248 map, see \fByp_all()\fR.
257 The \fByp_all()\fR function provides a way to transfer an entire map from
258 server to client in a single request using TCP (rather than UDP as with other
259 functions in this package). The entire transaction takes place as a single RPC
260 request and response. The \fByp_all()\fR function can be used just like any
261 other NIS name service procedure to identify the map in the normal manner and
262 to supply the name of a function that will be called to process each key-value
263 pair within the map. The call to \fByp_all()\fR returns only when the
264 transaction is completed (successfully or unsuccessfully), or the
265 \fBforeach()\fR function decides that it does not want to see any more
268 The third parameter to \fByp_all()\fR is:
272 struct ypall_callback *incallback {
279 The function \fBforeach()\fR is called:
283 foreach(int \fIinstatus\fR, char *\fIinkey\fR,
284 int \fIinkeylen\fR, char *\fIinval\fR,
285 int \fIinvallen\fR, char *\fIindata\fR);
289 The \fIinstatus\fR parameter holds one of the return status values defined in
290 <\fBrpcsvc/yp_prot.h\fR>, either \fBYP_TRUE\fR or an error code. See
291 \fBypprot_err()\fR, for a function that converts an NIS name service protocol
292 error code to a \fBypclnt\fR layer error code.
294 The key and value parameters are somewhat different than defined in the
295 synopsis section above. First, the memory pointed to by the \fIinkey\fR and
296 \fIinval\fR parameters is private to the \fByp_all()\fR function, and is
297 overwritten with the arrival of each new key-value pair. The \fBforeach()\fR
298 function must do something useful with the contents of that memory, but it does
299 not own the memory itself. Key and value objects presented to the
300 \fBforeach()\fR function look exactly as they do in the server's map. If they
301 were not NEWLINE-terminated or null-terminated in the map, they would not be
304 The \fIindata\fR parameter is the contents of the \fIincallback\fR->\fIdata\fR
305 element passed to \fByp_all()\fR. The \fBdata\fR element of the callback
306 structure can be used to share state information between the \fBforeach()\fR
307 function and the mainline code. Its use is optional, and no part of the NIS
308 client package inspects its contents; cast it to something useful, or ignore
309 it. The \fBforeach()\fR function is Boolean. It should return \fB0\fR to
310 indicate that it wants to be called again for further received key-value pairs,
311 or non-zero to stop the flow of key-value pairs. If \fBforeach()\fR returns a
312 non-zero value, it is not called again. The functional value of \fByp_all()\fR
319 \fB\fByp_order()\fR\fR
322 The \fByp_order()\fR function returns the order number for a map.
328 \fB\fByp_master()\fR\fR
331 The \fByp_master()\fR function returns the machine name of the master NIS
338 \fB\fByperr_string()\fR\fR
341 The \fByperr_string()\fR function returns a pointer to an error message string
342 that is null-terminated but contains no period or NEWLINE.
348 \fB\fBypprot_err()\fR\fR
351 The \fBypprot_err()\fR function takes an NIS name service protocol error code
352 as input, and returns a \fBypclnt()\fR layer error code, which can be used as
353 an input to \fByperr_string()\fR.
358 All integer functions return \fB0\fR if the requested operation is successful,
359 or one of the following errors if the operation fails:
363 \fB\fBYPERR_ACCESS\fR\fR
372 \fB\fBYPERR_BADARGS\fR\fR
375 The arguments to the function are bad.
381 \fB\fBYPERR_BADDB\fR\fR
384 The \fBYP\fR database is bad.
390 \fB\fBYPERR_BUSY\fR\fR
393 The database is busy.
399 \fB\fBYPERR_DOMAIN\fR\fR
402 Cannot bind to server on this domain.
408 \fB\fBYPERR_KEY\fR\fR
417 \fB\fBYPERR_MAP\fR\fR
420 No such map in server's domain.
426 \fB\fBYPERR_NODOM\fR\fR
429 Local domain name not set.
435 \fB\fBYPERR_NOMORE\fR\fR
438 No more records in map database.
444 \fB\fBYPERR_PMAP\fR\fR
447 Cannot communicate with \fBrpcbind\fR.
453 \fB\fBYPERR_RESRC\fR\fR
456 Resource allocation failure.
462 \fB\fBYPERR_RPC\fR\fR
465 \fBRPC\fR failure; domain has been unbound.
471 \fB\fBYPERR_YPBIND\fR\fR
474 Cannot communicate with \fBypbind\fR.
480 \fB\fBYPERR_YPERR\fR\fR
483 Internal \fBYP\fR server or client error.
489 \fB\fBYPERR_YPSERV\fR\fR
492 Cannot communicate with \fBypserv\fR.
498 \fB\fBYPERR_VERS\fR\fR
501 \fBYP\fR version mismatch.
506 \fB/usr/lib/libnsl.so.1\fR
509 See \fBattributes\fR(5) for descriptions of the following attributes:
517 ATTRIBUTE TYPE ATTRIBUTE VALUE
524 \fBypcat\fR(1), \fBypmatch\fR(1), \fBypwhich\fR(1),
525 \fBrpcbind\fR(1M), \fBypbind\fR(1M), \fBypserv\fR(1M),
526 \fBsysinfo\fR(2), \fBmalloc\fR(3C), \fBypfiles\fR(4), \fBattributes\fR(5)