3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/cdefs.h>
35 __FBSDID("$FreeBSD$");
38 #include "yp_extern.h"
43 #include <sys/param.h>
44 #include <sys/types.h>
45 #include <sys/socket.h>
46 #include <netinet/in.h>
47 #include <arpa/inet.h>
52 #define MASTER_STRING "YP_MASTER_NAME"
53 #define MASTER_SZ sizeof(MASTER_STRING) - 1
54 #define ORDER_STRING "YP_LAST_MODIFIED"
55 #define ORDER_SZ sizeof(ORDER_STRING) - 1
60 if (yp_pid
!= getpid()) {
61 yp_error("child %d trying to fork!", getpid());
70 * NIS v2 support. This is where most of the action happens.
74 ypproc_null_2_svc(void *argp
, struct svc_req
*rqstp
)
80 if (yp_access(NULL
, NULL
, (struct svc_req
*)rqstp
))
82 if (yp_access(NULL
, (struct svc_req
*)rqstp
))
88 return((void *) &result
);
92 ypproc_domain_2_svc(domainname
*argp
, struct svc_req
*rqstp
)
97 if (yp_access(NULL
, NULL
, (struct svc_req
*)rqstp
)) {
99 if (yp_access(NULL
, (struct svc_req
*)rqstp
)) {
105 if (argp
== NULL
|| yp_validdomain(*argp
))
114 ypproc_domain_nonack_2_svc(domainname
*argp
, struct svc_req
*rqstp
)
116 static bool_t result
;
119 if (yp_access(NULL
, NULL
, (struct svc_req
*)rqstp
))
121 if (yp_access(NULL
, (struct svc_req
*)rqstp
))
125 if (argp
== NULL
|| yp_validdomain(*argp
))
134 ypproc_match_2_svc(ypreq_key
*argp
, struct svc_req
*rqstp
)
136 static ypresp_val result
;
138 result
.val
.valdat_val
= "";
139 result
.val
.valdat_len
= 0;
142 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
144 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
146 result
.stat
= YP_YPERR
;
150 if (argp
->domain
== NULL
|| argp
->map
== NULL
) {
151 result
.stat
= YP_BADARGS
;
155 if (yp_select_map(argp
->map
, argp
->domain
, NULL
, 1) != YP_TRUE
) {
156 result
.stat
= yp_errno
;
160 result
.stat
= yp_getbykey(&argp
->key
, &result
.val
);
163 * Do DNS lookups for hosts maps if database lookup failed.
167 if (do_dns
&& result
.stat
!= YP_TRUE
&&
168 (yp_testflag(argp
->map
, argp
->domain
, YP_INTERDOMAIN
) ||
169 (strstr(argp
->map
, "hosts") || strstr(argp
->map
, "ipnodes")))) {
171 if (do_dns
&& result
.stat
!= YP_TRUE
&&
172 (strstr(argp
->map
, "hosts") || strstr(argp
->map
, "ipnodes"))) {
174 char nbuf
[YPMAXRECORD
];
176 /* NUL terminate! NUL terminate!! NUL TERMINATE!!! */
177 bcopy(argp
->key
.keydat_val
, nbuf
, argp
->key
.keydat_len
);
178 nbuf
[argp
->key
.keydat_len
] = '\0';
181 yp_error("doing DNS lookup of %s", nbuf
);
183 if (!strcmp(argp
->map
, "hosts.byname"))
184 result
.stat
= yp_async_lookup_name(rqstp
, nbuf
,
186 else if (!strcmp(argp
->map
, "hosts.byaddr"))
187 result
.stat
= yp_async_lookup_addr(rqstp
, nbuf
,
189 else if (!strcmp(argp
->map
, "ipnodes.byname"))
190 result
.stat
= yp_async_lookup_name(rqstp
, nbuf
,
192 else if (!strcmp(argp
->map
, "ipnodes.byaddr"))
193 result
.stat
= yp_async_lookup_addr(rqstp
, nbuf
,
196 if (result
.stat
== YP_TRUE
)
204 ypproc_first_2_svc(ypreq_nokey
*argp
, struct svc_req
*rqstp
)
206 static ypresp_key_val result
;
208 result
.val
.valdat_val
= result
.key
.keydat_val
= "";
209 result
.val
.valdat_len
= result
.key
.keydat_len
= 0;
212 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
214 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
216 result
.stat
= YP_YPERR
;
220 if (argp
->domain
== NULL
) {
221 result
.stat
= YP_BADARGS
;
225 if (yp_select_map(argp
->map
, argp
->domain
, NULL
, 0) != YP_TRUE
) {
226 result
.stat
= yp_errno
;
230 result
.stat
= yp_firstbykey(&result
.key
, &result
.val
);
236 ypproc_next_2_svc(ypreq_key
*argp
, struct svc_req
*rqstp
)
238 static ypresp_key_val result
;
240 result
.val
.valdat_val
= result
.key
.keydat_val
= "";
241 result
.val
.valdat_len
= result
.key
.keydat_len
= 0;
244 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
246 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
248 result
.stat
= YP_YPERR
;
252 if (argp
->domain
== NULL
|| argp
->map
== NULL
) {
253 result
.stat
= YP_BADARGS
;
257 if (yp_select_map(argp
->map
, argp
->domain
, &argp
->key
, 0) != YP_TRUE
) {
258 result
.stat
= yp_errno
;
262 result
.key
.keydat_len
= argp
->key
.keydat_len
;
263 result
.key
.keydat_val
= argp
->key
.keydat_val
;
265 result
.stat
= yp_nextbykey(&result
.key
, &result
.val
);
271 ypxfr_callback(ypxfrstat rval
, struct sockaddr_in
*addr
, unsigned int transid
,
272 unsigned int prognum
, unsigned long port
)
275 int sock
= RPC_ANYSOCK
;
276 struct timeval timeout
;
277 yppushresp_xfr ypxfr_resp
;
282 addr
->sin_port
= htons(port
);
284 if ((clnt
= clntudp_create(addr
,prognum
,1,timeout
,&sock
)) == NULL
) {
285 yp_error("%s: %s", inet_ntoa(addr
->sin_addr
),
286 clnt_spcreateerror("failed to establish callback handle"));
290 ypxfr_resp
.status
= rval
;
291 ypxfr_resp
.transid
= transid
;
293 /* Turn the timeout off -- we don't want to block. */
295 if (clnt_control(clnt
, CLSET_TIMEOUT
, &timeout
) == FALSE
)
296 yp_error("failed to set timeout on ypproc_xfr callback");
298 if (yppushproc_xfrresp_1(&ypxfr_resp
, clnt
) == NULL
) {
299 clnt_geterr(clnt
, &err
);
300 if (err
.re_status
!= RPC_SUCCESS
&&
301 err
.re_status
!= RPC_TIMEDOUT
)
302 yp_error("%s", clnt_sperror(clnt
,
303 "ypxfr callback failed"));
310 #define YPXFR_RETURN(CODE) \
311 /* Order is important: send regular RPC reply, then callback */ \
312 result.xfrstat = CODE; \
313 svc_sendreply(rqstp->rq_xprt, (xdrproc_t)xdr_ypresp_xfr, &result); \
314 ypxfr_callback(CODE,rqhost,argp->transid, \
315 argp->prog,argp->port); \
319 ypproc_xfr_2_svc(ypreq_xfr
*argp
, struct svc_req
*rqstp
)
321 static ypresp_xfr result
;
322 struct sockaddr_in
*rqhost
;
326 result
.transid
= argp
->transid
;
327 rqhost
= svc_getcaller(rqstp
->rq_xprt
);
330 if (yp_access(argp
->map_parms
.map
,
331 argp
->map_parms
.domain
, (struct svc_req
*)rqstp
)) {
333 if (yp_access(argp
->map_parms
.map
, (struct svc_req
*)rqstp
)) {
335 YPXFR_RETURN(YPXFR_REFUSED
)
339 if (argp
->map_parms
.domain
== NULL
) {
340 YPXFR_RETURN(YPXFR_BADARGS
)
343 if (yp_validdomain(argp
->map_parms
.domain
)) {
344 YPXFR_RETURN(YPXFR_NODOM
)
348 * Determine the master host ourselves. The caller may
349 * be up to no good. This has the side effect of verifying
350 * that the requested map and domain actually exist.
353 mreq
.domain
= argp
->map_parms
.domain
;
354 mreq
.map
= argp
->map_parms
.map
;
356 mres
= ypproc_master_2_svc(&mreq
, rqstp
);
358 if (mres
->stat
!= YP_TRUE
) {
359 yp_error("couldn't find master for map %s@%s",
361 argp
->map_parms
.domain
);
362 yp_error("host at %s (%s) may be pulling my leg",
363 argp
->map_parms
.peer
,
364 inet_ntoa(rqhost
->sin_addr
));
365 YPXFR_RETURN(YPXFR_REFUSED
)
371 char g
[11], t
[11], p
[11];
372 char ypxfr_command
[MAXPATHLEN
+ 2];
374 snprintf (ypxfr_command
, sizeof(ypxfr_command
), "%sypxfr", _PATH_LIBEXEC
);
375 snprintf (t
, sizeof(t
), "%u", argp
->transid
);
376 snprintf (g
, sizeof(g
), "%u", argp
->prog
);
377 snprintf (p
, sizeof(p
), "%u", argp
->port
);
379 close(0); close(1); close(2);
381 if (strcmp(yp_dir
, _PATH_YP
)) {
382 execl(ypxfr_command
, "ypxfr",
383 "-d", argp
->map_parms
.domain
,
385 "-p", yp_dir
, "-C", t
,
386 g
, inet_ntoa(rqhost
->sin_addr
),
387 p
, argp
->map_parms
.map
,
390 execl(ypxfr_command
, "ypxfr",
391 "-d", argp
->map_parms
.domain
,
394 g
, inet_ntoa(rqhost
->sin_addr
),
395 p
, argp
->map_parms
.map
,
398 yp_error("ypxfr execl(%s): %s", ypxfr_command
, strerror(errno
));
399 YPXFR_RETURN(YPXFR_XFRERR
)
401 * Just to safe, prevent PR #10970 from biting us in
402 * the unlikely case that execing ypxfr fails. We don't
403 * want to have any child processes spawned from this
410 yp_error("ypxfr fork(): %s", strerror(errno
));
411 YPXFR_RETURN(YPXFR_XFRERR
)
414 result
.xfrstat
= YPXFR_SUCC
;
424 ypproc_clear_2_svc(void *argp
, struct svc_req
*rqstp
)
426 static char * result
;
427 static char rval
= 0;
430 if (yp_access(NULL
, NULL
, (struct svc_req
*)rqstp
))
432 if (yp_access(NULL
, (struct svc_req
*)rqstp
))
436 /* clear out the database cache */
439 /* Re-read the securenets database for the hell of it. */
443 return((void *) &result
);
447 * For ypproc_all, we have to send a stream of ypresp_all structures
448 * via TCP, but the XDR filter generated from the yp.x protocol
449 * definition file only serializes one such structure. This means that
450 * to send the whole stream, you need a wrapper which feeds all the
451 * records into the underlying XDR routine until it hits an 'EOF.'
452 * But to use the wrapper, you have to violate the boundaries between
453 * RPC layers by calling svc_sendreply() directly from the ypproc_all
454 * service routine instead of letting the RPC dispatcher do it.
460 * Custom XDR routine for serialzing results of ypproc_all: keep
461 * reading from the database and spew until we run out of records
462 * or encounter an error.
465 xdr_my_ypresp_all(register XDR
*xdrs
, ypresp_all
*objp
)
469 if ((objp
->ypresp_all_u
.val
.stat
=
470 yp_nextbykey(&objp
->ypresp_all_u
.val
.key
,
471 &objp
->ypresp_all_u
.val
.val
)) == YP_TRUE
) {
478 if (!xdr_ypresp_all(xdrs
, objp
))
480 if (objp
->more
== FALSE
)
486 ypproc_all_2_svc(ypreq_nokey
*argp
, struct svc_req
*rqstp
)
488 static ypresp_all result
;
491 * Set this here so that the client will be forced to make
492 * at least one attempt to read from us even if all we're
493 * doing is returning an error.
496 result
.ypresp_all_u
.val
.key
.keydat_len
= 0;
497 result
.ypresp_all_u
.val
.key
.keydat_val
= "";
500 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
502 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
504 result
.ypresp_all_u
.val
.stat
= YP_YPERR
;
508 if (argp
->domain
== NULL
|| argp
->map
== NULL
) {
509 result
.ypresp_all_u
.val
.stat
= YP_BADARGS
;
514 * XXX If we hit the child limit, fail the request.
515 * If we don't, and the map is large, we could block for
516 * a long time in the parent.
518 if (children
>= MAX_CHILDREN
) {
519 result
.ypresp_all_u
.val
.stat
= YP_YPERR
;
524 * The ypproc_all procedure can take a while to complete.
525 * Best to handle it in a subprocess so the parent doesn't
526 * block. (Is there a better way to do this? Maybe with
534 yp_error("ypall fork(): %s", strerror(errno
));
535 result
.ypresp_all_u
.val
.stat
= YP_YPERR
;
546 * Fix for PR #10971: don't let the child ypserv share
547 * DB handles with the parent process.
553 if (yp_select_map(argp
->map
, argp
->domain
,
554 &result
.ypresp_all_u
.val
.key
, 0) != YP_TRUE
) {
555 result
.ypresp_all_u
.val
.stat
= yp_errno
;
559 /* Kick off the actual data transfer. */
560 svc_sendreply(rqstp
->rq_xprt
, (xdrproc_t
)xdr_my_ypresp_all
, &result
);
563 * Proper fix for PR #10970: exit here so that we don't risk
564 * having a child spawned from this sub-process.
570 ypproc_master_2_svc(ypreq_nokey
*argp
, struct svc_req
*rqstp
)
572 static ypresp_master result
;
573 static char ypvalbuf
[YPMAXRECORD
];
574 keydat key
= { MASTER_SZ
, MASTER_STRING
};
580 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
582 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
584 result
.stat
= YP_YPERR
;
588 if (argp
->domain
== NULL
) {
589 result
.stat
= YP_BADARGS
;
593 if (yp_select_map(argp
->map
, argp
->domain
, &key
, 1) != YP_TRUE
) {
594 result
.stat
= yp_errno
;
599 * Note that we copy the data retrieved from the database to
600 * a private buffer and NUL terminate the buffer rather than
601 * terminating the data in place. We do this because by stuffing
602 * a '\0' into data.data, we will actually be corrupting memory
603 * allocated by the DB package. This is a bad thing now that we
604 * cache DB handles rather than closing the database immediately.
606 result
.stat
= yp_getbykey(&key
, &val
);
607 if (result
.stat
== YP_TRUE
) {
608 bcopy(val
.valdat_val
, &ypvalbuf
, val
.valdat_len
);
609 ypvalbuf
[val
.valdat_len
] = '\0';
610 result
.peer
= ypvalbuf
;
618 ypproc_order_2_svc(ypreq_nokey
*argp
, struct svc_req
*rqstp
)
620 static ypresp_order result
;
621 keydat key
= { ORDER_SZ
, ORDER_STRING
};
627 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
629 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
631 result
.stat
= YP_YPERR
;
635 if (argp
->domain
== NULL
) {
636 result
.stat
= YP_BADARGS
;
641 * We could just check the timestamp on the map file,
642 * but that's a hack: we'll only know the last time the file
643 * was touched, not the last time the database contents were
647 if (yp_select_map(argp
->map
, argp
->domain
, &key
, 1) != YP_TRUE
) {
648 result
.stat
= yp_errno
;
652 result
.stat
= yp_getbykey(&key
, &val
);
654 if (result
.stat
== YP_TRUE
)
655 result
.ordernum
= atoi(val
.valdat_val
);
662 static void yp_maplist_free(struct ypmaplist
*yp_maplist
)
664 register struct ypmaplist
*next
;
667 next
= yp_maplist
->next
;
668 free(yp_maplist
->map
);
675 static struct ypmaplist
*
676 yp_maplist_create(const char *domain
)
678 char yp_mapdir
[MAXPATHLEN
+ 2];
679 char yp_mapname
[MAXPATHLEN
+ 2];
680 struct ypmaplist
*cur
= NULL
;
681 struct ypmaplist
*yp_maplist
= NULL
;
686 snprintf(yp_mapdir
, sizeof(yp_mapdir
), "%s/%s", yp_dir
, domain
);
688 if ((dird
= opendir(yp_mapdir
)) == NULL
) {
689 yp_error("opendir(%s) failed: %s", yp_mapdir
, strerror(errno
));
693 while ((dirp
= readdir(dird
)) != NULL
) {
694 if (strcmp(dirp
->d_name
, ".") && strcmp(dirp
->d_name
, "..")) {
695 snprintf(yp_mapname
, sizeof(yp_mapname
), "%s/%s",
696 yp_mapdir
,dirp
->d_name
);
697 if (stat(yp_mapname
, &statbuf
) < 0 ||
698 !S_ISREG(statbuf
.st_mode
))
700 if ((cur
= (struct ypmaplist
*)
701 malloc(sizeof(struct ypmaplist
))) == NULL
) {
702 yp_error("malloc() failed");
704 yp_maplist_free(yp_maplist
);
707 if ((cur
->map
= strdup(dirp
->d_name
)) == NULL
) {
708 yp_error("strdup() failed: %s",strerror(errno
));
710 yp_maplist_free(yp_maplist
);
713 cur
->next
= yp_maplist
;
716 yp_error("map: %s", yp_maplist
->map
);
725 ypproc_maplist_2_svc(domainname
*argp
, struct svc_req
*rqstp
)
727 static ypresp_maplist result
= { 0, NULL
};
730 if (yp_access(NULL
, NULL
, (struct svc_req
*)rqstp
)) {
732 if (yp_access(NULL
, (struct svc_req
*)rqstp
)) {
734 result
.stat
= YP_YPERR
;
739 result
.stat
= YP_BADARGS
;
743 if (yp_validdomain(*argp
)) {
744 result
.stat
= YP_NODOM
;
749 * We have to construct a linked list for the ypproc_maplist
750 * procedure using dynamically allocated memory. Since the XDR
751 * layer won't free this list for us, we have to deal with it
752 * ourselves. We call yp_maplist_free() first to free any
753 * previously allocated data we may have accumulated to insure
754 * that we have only one linked list in memory at any given
758 yp_maplist_free(result
.maps
);
760 if ((result
.maps
= yp_maplist_create(*argp
)) == NULL
) {
761 yp_error("yp_maplist_create failed");
762 result
.stat
= YP_YPERR
;
765 result
.stat
= YP_TRUE
;
771 * NIS v1 support. The nullproc, domain and domain_nonack
772 * functions from v1 are identical to those in v2, so all
773 * we have to do is hand off to them.
775 * The other functions are mostly just wrappers around their v2
776 * counterparts. For example, for the v1 'match' procedure, we
777 * crack open the argument structure, make a request to the v2
778 * 'match' function, repackage the data into a v1 response and
779 * then send it on its way.
781 * Note that we don't support the pull, push and get procedures.
782 * There's little documentation available to show what they
783 * do, and I suspect they're meant largely for map transfers
784 * between master and slave servers.
788 ypoldproc_null_1_svc(void *argp
, struct svc_req
*rqstp
)
790 return(ypproc_null_2_svc(argp
, rqstp
));
794 ypoldproc_domain_1_svc(domainname
*argp
, struct svc_req
*rqstp
)
796 return(ypproc_domain_2_svc(argp
, rqstp
));
800 ypoldproc_domain_nonack_1_svc(domainname
*argp
, struct svc_req
*rqstp
)
802 return (ypproc_domain_nonack_2_svc(argp
, rqstp
));
806 * the 'match' procedure sends a response of type YPRESP_VAL
809 ypoldproc_match_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
811 static ypresponse result
;
812 ypresp_val
*v2_result
;
814 result
.yp_resptype
= YPRESP_VAL
;
815 result
.ypresponse_u
.yp_resp_valtype
.val
.valdat_val
= "";
816 result
.ypresponse_u
.yp_resp_valtype
.val
.valdat_len
= 0;
818 if (argp
->yp_reqtype
!= YPREQ_KEY
) {
819 result
.ypresponse_u
.yp_resp_valtype
.stat
= YP_BADARGS
;
823 v2_result
= ypproc_match_2_svc(&argp
->yprequest_u
.yp_req_keytype
,rqstp
);
824 if (v2_result
== NULL
)
827 bcopy(v2_result
, &result
.ypresponse_u
.yp_resp_valtype
,
834 * the 'first' procedure sends a response of type YPRESP_KEY_VAL
837 ypoldproc_first_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
839 static ypresponse result
;
840 ypresp_key_val
*v2_result
;
842 result
.yp_resptype
= YPRESP_KEY_VAL
;
843 result
.ypresponse_u
.yp_resp_key_valtype
.val
.valdat_val
=
844 result
.ypresponse_u
.yp_resp_key_valtype
.key
.keydat_val
= "";
845 result
.ypresponse_u
.yp_resp_key_valtype
.val
.valdat_len
=
846 result
.ypresponse_u
.yp_resp_key_valtype
.key
.keydat_len
= 0;
848 if (argp
->yp_reqtype
!= YPREQ_NOKEY
) {
849 result
.ypresponse_u
.yp_resp_key_valtype
.stat
= YP_BADARGS
;
853 v2_result
= ypproc_first_2_svc(&argp
->yprequest_u
.yp_req_nokeytype
,
855 if (v2_result
== NULL
)
858 bcopy(v2_result
, &result
.ypresponse_u
.yp_resp_key_valtype
,
859 sizeof(ypresp_key_val
));
865 * the 'next' procedure sends a response of type YPRESP_KEY_VAL
868 ypoldproc_next_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
870 static ypresponse result
;
871 ypresp_key_val
*v2_result
;
873 result
.yp_resptype
= YPRESP_KEY_VAL
;
874 result
.ypresponse_u
.yp_resp_key_valtype
.val
.valdat_val
=
875 result
.ypresponse_u
.yp_resp_key_valtype
.key
.keydat_val
= "";
876 result
.ypresponse_u
.yp_resp_key_valtype
.val
.valdat_len
=
877 result
.ypresponse_u
.yp_resp_key_valtype
.key
.keydat_len
= 0;
879 if (argp
->yp_reqtype
!= YPREQ_KEY
) {
880 result
.ypresponse_u
.yp_resp_key_valtype
.stat
= YP_BADARGS
;
884 v2_result
= ypproc_next_2_svc(&argp
->yprequest_u
.yp_req_keytype
,rqstp
);
885 if (v2_result
== NULL
)
888 bcopy(v2_result
, &result
.ypresponse_u
.yp_resp_key_valtype
,
889 sizeof(ypresp_key_val
));
895 * the 'poll' procedure sends a response of type YPRESP_MAP_PARMS
898 ypoldproc_poll_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
900 static ypresponse result
;
901 ypresp_master
*v2_result1
;
902 ypresp_order
*v2_result2
;
904 result
.yp_resptype
= YPRESP_MAP_PARMS
;
905 result
.ypresponse_u
.yp_resp_map_parmstype
.domain
=
906 argp
->yprequest_u
.yp_req_nokeytype
.domain
;
907 result
.ypresponse_u
.yp_resp_map_parmstype
.map
=
908 argp
->yprequest_u
.yp_req_nokeytype
.map
;
910 * Hmm... there is no 'status' value in the
911 * yp_resp_map_parmstype structure, so I have to
912 * guess at what to do to indicate a failure.
913 * I hope this is right.
915 result
.ypresponse_u
.yp_resp_map_parmstype
.ordernum
= 0;
916 result
.ypresponse_u
.yp_resp_map_parmstype
.peer
= "";
918 if (argp
->yp_reqtype
!= YPREQ_MAP_PARMS
) {
922 v2_result1
= ypproc_master_2_svc(&argp
->yprequest_u
.yp_req_nokeytype
,
924 if (v2_result1
== NULL
)
927 if (v2_result1
->stat
!= YP_TRUE
) {
931 v2_result2
= ypproc_order_2_svc(&argp
->yprequest_u
.yp_req_nokeytype
,
933 if (v2_result2
== NULL
)
936 if (v2_result2
->stat
!= YP_TRUE
) {
940 result
.ypresponse_u
.yp_resp_map_parmstype
.peer
=
942 result
.ypresponse_u
.yp_resp_map_parmstype
.ordernum
=
943 v2_result2
->ordernum
;
949 ypoldproc_push_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
951 static ypresponse result
;
961 ypoldproc_pull_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
963 static ypresponse result
;
973 ypoldproc_get_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
975 static ypresponse result
;