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
32 * $FreeBSD: src/usr.sbin/ypserv/yp_server.c,v 1.31.2.1 2002/02/15 00:47:00 des Exp $
33 * $DragonFly: src/usr.sbin/ypserv/yp_server.c,v 1.4 2005/11/24 22:23:02 swildner Exp $
37 #include "yp_extern.h"
42 #include <sys/param.h>
43 #include <sys/types.h>
44 #include <sys/socket.h>
45 #include <netinet/in.h>
46 #include <arpa/inet.h>
51 #define MASTER_STRING "YP_MASTER_NAME"
52 #define MASTER_SZ sizeof(MASTER_STRING) - 1
53 #define ORDER_STRING "YP_LAST_MODIFIED"
54 #define ORDER_SZ sizeof(ORDER_STRING) - 1
59 if (yp_pid
!= getpid()) {
60 yp_error("child %d trying to fork!", getpid());
69 * NIS v2 support. This is where most of the action happens.
73 ypproc_null_2_svc(void *argp
, struct svc_req
*rqstp
)
79 if (yp_access(NULL
, NULL
, (struct svc_req
*)rqstp
))
81 if (yp_access(NULL
, (struct svc_req
*)rqstp
))
87 return((void *) &result
);
91 ypproc_domain_2_svc(domainname
*argp
, struct svc_req
*rqstp
)
96 if (yp_access(NULL
, NULL
, (struct svc_req
*)rqstp
)) {
98 if (yp_access(NULL
, (struct svc_req
*)rqstp
)) {
104 if (argp
== NULL
|| yp_validdomain(*argp
))
113 ypproc_domain_nonack_2_svc(domainname
*argp
, struct svc_req
*rqstp
)
115 static bool_t result
;
118 if (yp_access(NULL
, NULL
, (struct svc_req
*)rqstp
))
120 if (yp_access(NULL
, (struct svc_req
*)rqstp
))
124 if (argp
== NULL
|| yp_validdomain(*argp
))
133 ypproc_match_2_svc(ypreq_key
*argp
, struct svc_req
*rqstp
)
135 static ypresp_val result
;
137 result
.val
.valdat_val
= "";
138 result
.val
.valdat_len
= 0;
141 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
143 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
145 result
.stat
= YP_YPERR
;
149 if (argp
->domain
== NULL
|| argp
->map
== NULL
) {
150 result
.stat
= YP_BADARGS
;
154 if (yp_select_map(argp
->map
, argp
->domain
, NULL
, 1) != YP_TRUE
) {
155 result
.stat
= yp_errno
;
159 result
.stat
= yp_getbykey(&argp
->key
, &result
.val
);
162 * Do DNS lookups for hosts maps if database lookup failed.
166 if (result
.stat
!= YP_TRUE
&&
167 (yp_testflag(argp
->map
, argp
->domain
, YP_INTERDOMAIN
) ||
168 (strstr(argp
->map
, "hosts") && do_dns
))) {
170 if (do_dns
&& result
.stat
!= YP_TRUE
&& strstr(argp
->map
, "hosts")) {
172 char nbuf
[YPMAXRECORD
];
174 /* NUL terminate! NUL terminate!! NUL TERMINATE!!! */
175 bcopy(argp
->key
.keydat_val
, nbuf
, argp
->key
.keydat_len
);
176 nbuf
[argp
->key
.keydat_len
] = '\0';
179 yp_error("doing DNS lookup of %s", nbuf
);
181 if (!strcmp(argp
->map
, "hosts.byname"))
182 result
.stat
= yp_async_lookup_name(rqstp
, nbuf
);
183 else if (!strcmp(argp
->map
, "hosts.byaddr"))
184 result
.stat
= yp_async_lookup_addr(rqstp
, nbuf
);
186 if (result
.stat
== YP_TRUE
)
194 ypproc_first_2_svc(ypreq_nokey
*argp
, struct svc_req
*rqstp
)
196 static ypresp_key_val result
;
198 result
.val
.valdat_val
= result
.key
.keydat_val
= "";
199 result
.val
.valdat_len
= result
.key
.keydat_len
= 0;
202 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
204 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
206 result
.stat
= YP_YPERR
;
210 if (argp
->domain
== NULL
) {
211 result
.stat
= YP_BADARGS
;
215 if (yp_select_map(argp
->map
, argp
->domain
, NULL
, 0) != YP_TRUE
) {
216 result
.stat
= yp_errno
;
220 result
.stat
= yp_firstbykey(&result
.key
, &result
.val
);
226 ypproc_next_2_svc(ypreq_key
*argp
, struct svc_req
*rqstp
)
228 static ypresp_key_val result
;
230 result
.val
.valdat_val
= result
.key
.keydat_val
= "";
231 result
.val
.valdat_len
= result
.key
.keydat_len
= 0;
234 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
236 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
238 result
.stat
= YP_YPERR
;
242 if (argp
->domain
== NULL
|| argp
->map
== NULL
) {
243 result
.stat
= YP_BADARGS
;
247 if (yp_select_map(argp
->map
, argp
->domain
, &argp
->key
, 0) != YP_TRUE
) {
248 result
.stat
= yp_errno
;
252 result
.key
.keydat_len
= argp
->key
.keydat_len
;
253 result
.key
.keydat_val
= argp
->key
.keydat_val
;
255 result
.stat
= yp_nextbykey(&result
.key
, &result
.val
);
261 ypxfr_callback(ypxfrstat rval
, struct sockaddr_in
*addr
, unsigned int transid
,
262 unsigned int prognum
, unsigned long port
)
265 int sock
= RPC_ANYSOCK
;
266 struct timeval timeout
;
267 yppushresp_xfr ypxfr_resp
;
272 addr
->sin_port
= htons(port
);
274 if ((clnt
= clntudp_create(addr
,prognum
,1,timeout
,&sock
)) == NULL
) {
275 yp_error("%s: %s", inet_ntoa(addr
->sin_addr
),
276 clnt_spcreateerror("failed to establish callback handle"));
280 ypxfr_resp
.status
= rval
;
281 ypxfr_resp
.transid
= transid
;
283 /* Turn the timeout off -- we don't want to block. */
285 if (clnt_control(clnt
, CLSET_TIMEOUT
, (char *)&timeout
) == FALSE
)
286 yp_error("failed to set timeout on ypproc_xfr callback");
288 if (yppushproc_xfrresp_1(&ypxfr_resp
, clnt
) == NULL
) {
289 clnt_geterr(clnt
, &err
);
290 if (err
.re_status
!= RPC_SUCCESS
&&
291 err
.re_status
!= RPC_TIMEDOUT
)
292 yp_error("%s", clnt_sperror(clnt
,
293 "ypxfr callback failed"));
300 #define YPXFR_RETURN(CODE) \
301 /* Order is important: send regular RPC reply, then callback */ \
302 result.xfrstat = CODE; \
303 svc_sendreply(rqstp->rq_xprt, xdr_ypresp_xfr, (char *)&result); \
304 ypxfr_callback(CODE,rqhost,argp->transid, \
305 argp->prog,argp->port); \
309 ypproc_xfr_2_svc(ypreq_xfr
*argp
, struct svc_req
*rqstp
)
311 static ypresp_xfr result
;
312 struct sockaddr_in
*rqhost
;
316 result
.transid
= argp
->transid
;
317 rqhost
= svc_getcaller(rqstp
->rq_xprt
);
320 if (yp_access(argp
->map_parms
.map
,
321 argp
->map_parms
.domain
, (struct svc_req
*)rqstp
)) {
323 if (yp_access(argp
->map_parms
.map
, (struct svc_req
*)rqstp
)) {
325 YPXFR_RETURN(YPXFR_REFUSED
)
329 if (argp
->map_parms
.domain
== NULL
) {
330 YPXFR_RETURN(YPXFR_BADARGS
)
333 if (yp_validdomain(argp
->map_parms
.domain
)) {
334 YPXFR_RETURN(YPXFR_NODOM
)
338 * Determine the master host ourselves. The caller may
339 * be up to no good. This has the side effect of verifying
340 * that the requested map and domain actually exist.
343 mreq
.domain
= argp
->map_parms
.domain
;
344 mreq
.map
= argp
->map_parms
.map
;
346 mres
= ypproc_master_2_svc(&mreq
, rqstp
);
348 if (mres
->stat
!= YP_TRUE
) {
349 yp_error("couldn't find master for map %s@%s",
351 argp
->map_parms
.domain
);
352 yp_error("host at %s (%s) may be pulling my leg",
353 argp
->map_parms
.peer
,
354 inet_ntoa(rqhost
->sin_addr
));
355 YPXFR_RETURN(YPXFR_REFUSED
)
361 char g
[11], t
[11], p
[11];
362 char ypxfr_command
[MAXPATHLEN
+ 2];
364 sprintf (ypxfr_command
, "%sypxfr", _PATH_LIBEXEC
);
365 sprintf (t
, "%u", argp
->transid
);
366 sprintf (g
, "%u", argp
->prog
);
367 sprintf (p
, "%u", argp
->port
);
369 close(0); close(1); close(2);
371 if (strcmp(yp_dir
, _PATH_YP
)) {
372 execl(ypxfr_command
, "ypxfr",
373 "-d", argp
->map_parms
.domain
,
375 "-p", yp_dir
, "-C", t
,
376 g
, inet_ntoa(rqhost
->sin_addr
),
377 p
, argp
->map_parms
.map
,
380 execl(ypxfr_command
, "ypxfr",
381 "-d", argp
->map_parms
.domain
,
384 g
, inet_ntoa(rqhost
->sin_addr
),
385 p
, argp
->map_parms
.map
,
388 yp_error("ypxfr execl(%s): %s", ypxfr_command
, strerror(errno
));
389 YPXFR_RETURN(YPXFR_XFRERR
)
391 * Just to safe, prevent PR #10970 from biting us in
392 * the unlikely case that execing ypxfr fails. We don't
393 * want to have any child processes spawned from this
400 yp_error("ypxfr fork(): %s", strerror(errno
));
401 YPXFR_RETURN(YPXFR_XFRERR
)
404 result
.xfrstat
= YPXFR_SUCC
;
414 ypproc_clear_2_svc(void *argp
, struct svc_req
*rqstp
)
416 static char * result
;
417 static char rval
= 0;
420 if (yp_access(NULL
, NULL
, (struct svc_req
*)rqstp
))
422 if (yp_access(NULL
, (struct svc_req
*)rqstp
))
426 /* clear out the database cache */
429 /* Re-read the securenets database for the hell of it. */
433 return((void *) &result
);
437 * For ypproc_all, we have to send a stream of ypresp_all structures
438 * via TCP, but the XDR filter generated from the yp.x protocol
439 * definition file only serializes one such structure. This means that
440 * to send the whole stream, you need a wrapper which feeds all the
441 * records into the underlying XDR routine until it hits an 'EOF.'
442 * But to use the wrapper, you have to violate the boundaries between
443 * RPC layers by calling svc_sendreply() directly from the ypproc_all
444 * service routine instead of letting the RPC dispatcher do it.
450 * Custom XDR routine for serialzing results of ypproc_all: keep
451 * reading from the database and spew until we run out of records
452 * or encounter an error.
455 xdr_my_ypresp_all(XDR
*xdrs
, ypresp_all
*objp
)
459 if ((objp
->ypresp_all_u
.val
.stat
=
460 yp_nextbykey(&objp
->ypresp_all_u
.val
.key
,
461 &objp
->ypresp_all_u
.val
.val
)) == YP_TRUE
) {
468 if (!xdr_ypresp_all(xdrs
, objp
))
470 if (objp
->more
== FALSE
)
476 ypproc_all_2_svc(ypreq_nokey
*argp
, struct svc_req
*rqstp
)
478 static ypresp_all result
;
481 * Set this here so that the client will be forced to make
482 * at least one attempt to read from us even if all we're
483 * doing is returning an error.
486 result
.ypresp_all_u
.val
.key
.keydat_len
= 0;
487 result
.ypresp_all_u
.val
.key
.keydat_val
= "";
490 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
492 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
494 result
.ypresp_all_u
.val
.stat
= YP_YPERR
;
498 if (argp
->domain
== NULL
|| argp
->map
== NULL
) {
499 result
.ypresp_all_u
.val
.stat
= YP_BADARGS
;
504 * XXX If we hit the child limit, fail the request.
505 * If we don't, and the map is large, we could block for
506 * a long time in the parent.
508 if (children
>= MAX_CHILDREN
) {
509 result
.ypresp_all_u
.val
.stat
= YP_YPERR
;
514 * The ypproc_all procedure can take a while to complete.
515 * Best to handle it in a subprocess so the parent doesn't
516 * block. (Is there a better way to do this? Maybe with
524 yp_error("ypall fork(): %s", strerror(errno
));
525 result
.ypresp_all_u
.val
.stat
= YP_YPERR
;
536 * Fix for PR #10971: don't let the child ypserv share
537 * DB handles with the parent process.
543 if (yp_select_map(argp
->map
, argp
->domain
,
544 &result
.ypresp_all_u
.val
.key
, 0) != YP_TRUE
) {
545 result
.ypresp_all_u
.val
.stat
= yp_errno
;
549 /* Kick off the actual data transfer. */
550 svc_sendreply(rqstp
->rq_xprt
, xdr_my_ypresp_all
, (char *)&result
);
553 * Proper fix for PR #10970: exit here so that we don't risk
554 * having a child spawned from this sub-process.
560 ypproc_master_2_svc(ypreq_nokey
*argp
, struct svc_req
*rqstp
)
562 static ypresp_master result
;
563 static char ypvalbuf
[YPMAXRECORD
];
564 keydat key
= { MASTER_SZ
, MASTER_STRING
};
570 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
572 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
574 result
.stat
= YP_YPERR
;
578 if (argp
->domain
== NULL
) {
579 result
.stat
= YP_BADARGS
;
583 if (yp_select_map(argp
->map
, argp
->domain
, &key
, 1) != YP_TRUE
) {
584 result
.stat
= yp_errno
;
589 * Note that we copy the data retrieved from the database to
590 * a private buffer and NUL terminate the buffer rather than
591 * terminating the data in place. We do this because by stuffing
592 * a '\0' into data.data, we will actually be corrupting memory
593 * allocated by the DB package. This is a bad thing now that we
594 * cache DB handles rather than closing the database immediately.
596 result
.stat
= yp_getbykey(&key
, &val
);
597 if (result
.stat
== YP_TRUE
) {
598 bcopy((char *)val
.valdat_val
, (char *)&ypvalbuf
,
600 ypvalbuf
[val
.valdat_len
] = '\0';
601 result
.peer
= (char *)&ypvalbuf
;
609 ypproc_order_2_svc(ypreq_nokey
*argp
, struct svc_req
*rqstp
)
611 static ypresp_order result
;
612 keydat key
= { ORDER_SZ
, ORDER_STRING
};
618 if (yp_access(argp
->map
, argp
->domain
, (struct svc_req
*)rqstp
)) {
620 if (yp_access(argp
->map
, (struct svc_req
*)rqstp
)) {
622 result
.stat
= YP_YPERR
;
626 if (argp
->domain
== NULL
) {
627 result
.stat
= YP_BADARGS
;
632 * We could just check the timestamp on the map file,
633 * but that's a hack: we'll only know the last time the file
634 * was touched, not the last time the database contents were
638 if (yp_select_map(argp
->map
, argp
->domain
, &key
, 1) != YP_TRUE
) {
639 result
.stat
= yp_errno
;
643 result
.stat
= yp_getbykey(&key
, &val
);
645 if (result
.stat
== YP_TRUE
)
646 result
.ordernum
= atoi((char *)val
.valdat_val
);
654 yp_maplist_free(struct ypmaplist
*yp_maplist
)
656 struct ypmaplist
*next
;
659 next
= yp_maplist
->next
;
660 free(yp_maplist
->map
);
667 static struct ypmaplist
*
668 yp_maplist_create(const char *domain
)
670 char yp_mapdir
[MAXPATHLEN
+ 2];
671 char yp_mapname
[MAXPATHLEN
+ 2];
672 struct ypmaplist
*cur
= NULL
;
673 struct ypmaplist
*yp_maplist
= NULL
;
678 snprintf(yp_mapdir
, sizeof(yp_mapdir
), "%s/%s", yp_dir
, domain
);
680 if ((dird
= opendir(yp_mapdir
)) == NULL
) {
681 yp_error("opendir(%s) failed: %s", yp_mapdir
, strerror(errno
));
685 while ((dirp
= readdir(dird
)) != NULL
) {
686 if (strcmp(dirp
->d_name
, ".") && strcmp(dirp
->d_name
, "..")) {
687 snprintf(yp_mapname
, sizeof(yp_mapname
), "%s/%s",
688 yp_mapdir
,dirp
->d_name
);
689 if (stat(yp_mapname
, &statbuf
) < 0 ||
690 !S_ISREG(statbuf
.st_mode
))
692 if ((cur
= (struct ypmaplist
*)
693 malloc(sizeof(struct ypmaplist
))) == NULL
) {
694 yp_error("malloc() failed");
696 yp_maplist_free(yp_maplist
);
699 if ((cur
->map
= (char *)strdup(dirp
->d_name
)) == NULL
) {
700 yp_error("strdup() failed: %s",strerror(errno
));
702 yp_maplist_free(yp_maplist
);
705 cur
->next
= yp_maplist
;
708 yp_error("map: %s", yp_maplist
->map
);
717 ypproc_maplist_2_svc(domainname
*argp
, struct svc_req
*rqstp
)
719 static ypresp_maplist result
= { 0, NULL
};
722 if (yp_access(NULL
, NULL
, (struct svc_req
*)rqstp
)) {
724 if (yp_access(NULL
, (struct svc_req
*)rqstp
)) {
726 result
.stat
= YP_YPERR
;
731 result
.stat
= YP_BADARGS
;
735 if (yp_validdomain(*argp
)) {
736 result
.stat
= YP_NODOM
;
741 * We have to construct a linked list for the ypproc_maplist
742 * procedure using dynamically allocated memory. Since the XDR
743 * layer won't free this list for us, we have to deal with it
744 * ourselves. We call yp_maplist_free() first to free any
745 * previously allocated data we may have accumulated to insure
746 * that we have only one linked list in memory at any given
750 yp_maplist_free(result
.maps
);
752 if ((result
.maps
= yp_maplist_create(*argp
)) == NULL
) {
753 yp_error("yp_maplist_create failed");
754 result
.stat
= YP_YPERR
;
757 result
.stat
= YP_TRUE
;
763 * NIS v1 support. The nullproc, domain and domain_nonack
764 * functions from v1 are identical to those in v2, so all
765 * we have to do is hand off to them.
767 * The other functions are mostly just wrappers around their v2
768 * counterparts. For example, for the v1 'match' procedure, we
769 * crack open the argument structure, make a request to the v2
770 * 'match' function, repackage the data into a v1 response and
771 * then send it on its way.
773 * Note that we don't support the pull, push and get procedures.
774 * There's little documentation available to show what they
775 * do, and I suspect they're meant largely for map transfers
776 * between master and slave servers.
780 ypoldproc_null_1_svc(void *argp
, struct svc_req
*rqstp
)
782 return(ypproc_null_2_svc(argp
, rqstp
));
786 ypoldproc_domain_1_svc(domainname
*argp
, struct svc_req
*rqstp
)
788 return(ypproc_domain_2_svc(argp
, rqstp
));
792 ypoldproc_domain_nonack_1_svc(domainname
*argp
, struct svc_req
*rqstp
)
794 return (ypproc_domain_nonack_2_svc(argp
, rqstp
));
798 * the 'match' procedure sends a response of type YPRESP_VAL
801 ypoldproc_match_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
803 static ypresponse result
;
804 ypresp_val
*v2_result
;
806 result
.yp_resptype
= YPRESP_VAL
;
807 result
.ypresponse_u
.yp_resp_valtype
.val
.valdat_val
= "";
808 result
.ypresponse_u
.yp_resp_valtype
.val
.valdat_len
= 0;
810 if (argp
->yp_reqtype
!= YPREQ_KEY
) {
811 result
.ypresponse_u
.yp_resp_valtype
.stat
= YP_BADARGS
;
815 v2_result
= ypproc_match_2_svc(&argp
->yprequest_u
.yp_req_keytype
,rqstp
);
816 if (v2_result
== NULL
)
819 bcopy((char *)v2_result
,
820 (char *)&result
.ypresponse_u
.yp_resp_valtype
,
827 * the 'first' procedure sends a response of type YPRESP_KEY_VAL
830 ypoldproc_first_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
832 static ypresponse result
;
833 ypresp_key_val
*v2_result
;
835 result
.yp_resptype
= YPRESP_KEY_VAL
;
836 result
.ypresponse_u
.yp_resp_key_valtype
.val
.valdat_val
=
837 result
.ypresponse_u
.yp_resp_key_valtype
.key
.keydat_val
= "";
838 result
.ypresponse_u
.yp_resp_key_valtype
.val
.valdat_len
=
839 result
.ypresponse_u
.yp_resp_key_valtype
.key
.keydat_len
= 0;
841 if (argp
->yp_reqtype
!= YPREQ_NOKEY
) {
842 result
.ypresponse_u
.yp_resp_key_valtype
.stat
= YP_BADARGS
;
846 v2_result
= ypproc_first_2_svc(&argp
->yprequest_u
.yp_req_nokeytype
,
848 if (v2_result
== NULL
)
851 bcopy((char *)v2_result
,
852 (char *)&result
.ypresponse_u
.yp_resp_key_valtype
,
853 sizeof(ypresp_key_val
));
859 * the 'next' procedure sends a response of type YPRESP_KEY_VAL
862 ypoldproc_next_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
864 static ypresponse result
;
865 ypresp_key_val
*v2_result
;
867 result
.yp_resptype
= YPRESP_KEY_VAL
;
868 result
.ypresponse_u
.yp_resp_key_valtype
.val
.valdat_val
=
869 result
.ypresponse_u
.yp_resp_key_valtype
.key
.keydat_val
= "";
870 result
.ypresponse_u
.yp_resp_key_valtype
.val
.valdat_len
=
871 result
.ypresponse_u
.yp_resp_key_valtype
.key
.keydat_len
= 0;
873 if (argp
->yp_reqtype
!= YPREQ_KEY
) {
874 result
.ypresponse_u
.yp_resp_key_valtype
.stat
= YP_BADARGS
;
878 v2_result
= ypproc_next_2_svc(&argp
->yprequest_u
.yp_req_keytype
,rqstp
);
879 if (v2_result
== NULL
)
882 bcopy((char *)v2_result
,
883 (char *)&result
.ypresponse_u
.yp_resp_key_valtype
,
884 sizeof(ypresp_key_val
));
890 * the 'poll' procedure sends a response of type YPRESP_MAP_PARMS
893 ypoldproc_poll_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
895 static ypresponse result
;
896 ypresp_master
*v2_result1
;
897 ypresp_order
*v2_result2
;
899 result
.yp_resptype
= YPRESP_MAP_PARMS
;
900 result
.ypresponse_u
.yp_resp_map_parmstype
.domain
=
901 argp
->yprequest_u
.yp_req_nokeytype
.domain
;
902 result
.ypresponse_u
.yp_resp_map_parmstype
.map
=
903 argp
->yprequest_u
.yp_req_nokeytype
.map
;
905 * Hmm... there is no 'status' value in the
906 * yp_resp_map_parmstype structure, so I have to
907 * guess at what to do to indicate a failure.
908 * I hope this is right.
910 result
.ypresponse_u
.yp_resp_map_parmstype
.ordernum
= 0;
911 result
.ypresponse_u
.yp_resp_map_parmstype
.peer
= "";
913 if (argp
->yp_reqtype
!= YPREQ_MAP_PARMS
) {
917 v2_result1
= ypproc_master_2_svc(&argp
->yprequest_u
.yp_req_nokeytype
,
919 if (v2_result1
== NULL
)
922 if (v2_result1
->stat
!= YP_TRUE
) {
926 v2_result2
= ypproc_order_2_svc(&argp
->yprequest_u
.yp_req_nokeytype
,
928 if (v2_result2
== NULL
)
931 if (v2_result2
->stat
!= YP_TRUE
) {
935 result
.ypresponse_u
.yp_resp_map_parmstype
.peer
=
937 result
.ypresponse_u
.yp_resp_map_parmstype
.ordernum
=
938 v2_result2
->ordernum
;
944 ypoldproc_push_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
946 static ypresponse result
;
956 ypoldproc_pull_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
958 static ypresponse result
;
968 ypoldproc_get_1_svc(yprequest
*argp
, struct svc_req
*rqstp
)
970 static ypresponse result
;