Deleted Added
sdiff udiff text old ( 21673 ) new ( 22321 )
full compact
1/*
2 * Copyright (c) 1995
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
19 *
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
30 * SUCH DAMAGE.
31 *
32 */
33
34#include "yp.h"
35#include "yp_extern.h"
36#include <stdlib.h>
37#include <dirent.h>
38#include <sys/stat.h>
39#include <sys/param.h>
40#include <errno.h>
41#include <sys/types.h>
42#include <sys/socket.h>
43#include <netinet/in.h>
44#include <arpa/inet.h>
45#include <rpc/rpc.h>
46
47#ifndef lint
48static const char rcsid[] = "$FreeBSD: head/usr.sbin/ypserv/yp_server.c 21673 1997-01-14 07:20:47Z jkh $";
49#endif /* not lint */
50
51int forked = 0;
52int children = 0;
53static char *master_string = "YP_MASTER_NAME";
54static char *order_string = "YP_LAST_MODIFIED";
55static int master_sz = sizeof("YP_MASTER_NAME") - 1;
56static int order_sz = sizeof("YP_LAST_MODIFIED") - 1;
57
58/*
59 * NIS v2 support. This is where most of the action happens.
60 */
61
62void *
63ypproc_null_2_svc(void *argp, struct svc_req *rqstp)
64{
65 static char * result;
66 static char rval = 0;
67
68#ifdef DB_CACHE
69 if (yp_access(NULL, NULL, (struct svc_req *)rqstp))
70#else
71 if (yp_access(NULL, (struct svc_req *)rqstp))
72#endif
73 return(NULL);
74
75 result = &rval;
76
77 return((void *) &result);
78}
79
80bool_t *
81ypproc_domain_2_svc(domainname *argp, struct svc_req *rqstp)
82{
83 static bool_t result;
84
85#ifdef DB_CACHE
86 if (yp_access(NULL, NULL, (struct svc_req *)rqstp)) {
87#else
88 if (yp_access(NULL, (struct svc_req *)rqstp)) {
89#endif
90 result = FALSE;
91 return (&result);
92 }
93
94 if (argp == NULL || yp_validdomain(*argp))
95 result = FALSE;
96 else
97 result = TRUE;
98
99 return (&result);
100}
101
102bool_t *
103ypproc_domain_nonack_2_svc(domainname *argp, struct svc_req *rqstp)
104{
105 static bool_t result;
106
107#ifdef DB_CACHE
108 if (yp_access(NULL, NULL, (struct svc_req *)rqstp))
109#else
110 if (yp_access(NULL, (struct svc_req *)rqstp))
111#endif
112 return (NULL);
113
114 if (argp == NULL || yp_validdomain(*argp))
115 return (NULL);
116 else
117 result = TRUE;
118
119 return (&result);
120}
121
122ypresp_val *
123ypproc_match_2_svc(ypreq_key *argp, struct svc_req *rqstp)
124{
125 static ypresp_val result;
126
127 result.val.valdat_val = "";
128 result.val.valdat_len = 0;
129
130#ifdef DB_CACHE
131 if (yp_access(argp->map, argp->domain, (struct svc_req *)rqstp)) {
132#else
133 if (yp_access(argp->map, (struct svc_req *)rqstp)) {
134#endif
135 result.stat = YP_YPERR;
136 return (&result);
137 }
138
139 if (argp->domain == NULL || argp->map == NULL) {
140 result.stat = YP_BADARGS;
141 return (&result);
142 }
143
144 if (yp_select_map(argp->map, argp->domain, &argp->key, 1) != YP_TRUE) {
145 result.stat = yp_errno;
146 return(&result);
147 }
148
149 result.stat = yp_getbykey(&argp->key, &result.val);
150
151 /*
152 * Do DNS lookups for hosts maps if database lookup failed.
153 */
154
155#ifdef DB_CACHE
156 if (result.stat != YP_TRUE &&
157 (yp_testflag(argp->map, argp->domain, YP_INTERDOMAIN) ||
158 (strstr(argp->map, "hosts") && do_dns))) {
159#else
160 if (do_dns && result.stat != YP_TRUE && strstr(argp->map, "hosts")) {
161#endif
162
163 /* NUL terminate! NUL terminate!! NUL TERMINATE!!! */
164 argp->key.keydat_val[argp->key.keydat_len] = '\0';
165
166 if (debug)
167 yp_error("Doing DNS lookup of %.*s",
168 argp->key.keydat_len,
169 argp->key.keydat_val);
170
171 if (!strcmp(argp->map, "hosts.byname"))
172 result.stat = yp_async_lookup_name(rqstp,
173 (char *)argp->key.keydat_val);
174 else if (!strcmp(argp->map, "hosts.byaddr"))
175 result.stat = yp_async_lookup_addr(rqstp,
176 (char *)argp->key.keydat_val);
177
178 if (result.stat == YP_TRUE)
179 return(NULL);
180 }
181
182 return (&result);
183}
184
185ypresp_key_val *
186ypproc_first_2_svc(ypreq_nokey *argp, struct svc_req *rqstp)
187{
188 static ypresp_key_val result;
189
190 result.val.valdat_val = result.key.keydat_val = "";
191 result.val.valdat_len = result.key.keydat_len = 0;
192
193#ifdef DB_CACHE
194 if (yp_access(argp->map, argp->domain, (struct svc_req *)rqstp)) {
195#else
196 if (yp_access(argp->map, (struct svc_req *)rqstp)) {
197#endif
198 result.stat = YP_YPERR;
199 return (&result);
200 }
201
202 if (argp->domain == NULL) {
203 result.stat = YP_BADARGS;
204 return (&result);
205 }
206
207 if (yp_select_map(argp->map, argp->domain, &result.key, 0) != YP_TRUE) {
208 result.stat = yp_errno;
209 return(&result);
210 }
211
212 result.stat = yp_firstbykey(&result.key, &result.val);
213
214 return (&result);
215}
216
217ypresp_key_val *
218ypproc_next_2_svc(ypreq_key *argp, struct svc_req *rqstp)
219{
220 static ypresp_key_val result;
221
222 result.val.valdat_val = result.key.keydat_val = "";
223 result.val.valdat_len = result.key.keydat_len = 0;
224
225#ifdef DB_CACHE
226 if (yp_access(argp->map, argp->domain, (struct svc_req *)rqstp)) {
227#else
228 if (yp_access(argp->map, (struct svc_req *)rqstp)) {
229#endif
230 result.stat = YP_YPERR;
231 return (&result);
232 }
233
234 if (argp->domain == NULL || argp->map == NULL) {
235 result.stat = YP_BADARGS;
236 return (&result);
237 }
238
239 if (yp_select_map(argp->map, argp->domain, &argp->key, 0) != YP_TRUE) {
240 result.stat = yp_errno;
241 return(&result);
242 }
243
244 result.key.keydat_len = argp->key.keydat_len;
245 result.key.keydat_val = argp->key.keydat_val;
246
247 result.stat = yp_nextbykey(&result.key, &result.val);
248
249 return (&result);
250}
251
252static void ypxfr_callback(rval,addr,transid,prognum,port)
253 ypxfrstat rval;
254 struct sockaddr_in *addr;
255 unsigned int transid;
256 unsigned int prognum;
257 unsigned long port;
258{
259 CLIENT *clnt;
260 int sock = RPC_ANYSOCK;
261 struct timeval timeout;
262 yppushresp_xfr ypxfr_resp;
263 struct rpc_err err;
264
265 timeout.tv_sec = 5;
266 timeout.tv_usec = 0;
267 addr->sin_port = htons(port);
268
269 if ((clnt = clntudp_create(addr,prognum,1,timeout,&sock)) == NULL) {
270 yp_error("%s: %s", inet_ntoa(addr->sin_addr),
271 clnt_spcreateerror("failed to establish callback handle"));
272 return;
273 }
274
275 ypxfr_resp.status = rval;
276 ypxfr_resp.transid = transid;
277
278 /* Turn the timeout off -- we don't want to block. */
279 timeout.tv_sec = 0;
280 if (clnt_control(clnt, CLSET_TIMEOUT, (char *)&timeout) == FALSE)
281 yp_error("failed to set timeout on ypproc_xfr callback");
282
283 if (yppushproc_xfrresp_1(&ypxfr_resp, clnt) == NULL) {
284 clnt_geterr(clnt, &err);
285 if (err.re_status != RPC_SUCCESS &&
286 err.re_status != RPC_TIMEDOUT)
287 yp_error("%s", clnt_sperror(clnt,
288 "ypxfr callback failed"));
289 }
290
291 clnt_destroy(clnt);
292 return;
293}
294
295#define YPXFR_RETURN(CODE) \
296 /* Order is important: send regular RPC reply, then callback */ \
297 result.xfrstat = CODE; \
298 svc_sendreply(rqstp->rq_xprt, xdr_ypresp_xfr, (char *)&result); \
299 ypxfr_callback(CODE,rqhost,argp->transid, \
300 argp->prog,argp->port); \
301 return(NULL);
302
303ypresp_xfr *
304ypproc_xfr_2_svc(ypreq_xfr *argp, struct svc_req *rqstp)
305{
306 static ypresp_xfr result;
307 struct sockaddr_in *rqhost;
308
309 result.transid = argp->transid;
310 rqhost = svc_getcaller(rqstp->rq_xprt);
311
312#ifdef DB_CACHE
313 if (yp_access(argp->map_parms.map,
314 argp->map_parms.domain, (struct svc_req *)rqstp)) {
315#else
316 if (yp_access(argp->map_parms.map, (struct svc_req *)rqstp)) {
317#endif
318 YPXFR_RETURN(YPXFR_REFUSED);
319 }
320
321 if (argp->map_parms.domain == NULL) {
322 YPXFR_RETURN(YPXFR_BADARGS);
323 }
324
325 if (yp_validdomain(argp->map_parms.domain)) {
326 YPXFR_RETURN(YPXFR_NODOM);
327 }
328
329 switch(fork()) {
330 case 0:
331 {
332 char g[11], t[11], p[11];
333 char ypxfr_command[MAXPATHLEN + 2];
334
335 sprintf (ypxfr_command, "%sypxfr", _PATH_LIBEXEC);
336 sprintf (t, "%u", argp->transid);
337 sprintf (g, "%u", argp->prog);
338 sprintf (p, "%u", argp->port);
339 if (debug)
340 close(0); close(1); close(2);
341 if (strcmp(yp_dir, _PATH_YP)) {
342 execl(ypxfr_command, "ypxfr",
343 "-d", argp->map_parms.domain,
344 "-h", argp->map_parms.peer,
345 "-p", yp_dir, "-C", t,
346 g, inet_ntoa(rqhost->sin_addr),
347 p, argp->map_parms.map,
348 NULL);
349 } else {
350 execl(ypxfr_command, "ypxfr",
351 "-d", argp->map_parms.domain,
352 "-h", argp->map_parms.peer,
353 "-C", t,
354 g, inet_ntoa(rqhost->sin_addr),
355 p, argp->map_parms.map,
356 NULL);
357 }
358 forked++;
359 yp_error("ypxfr execl(%s): %s", ypxfr_command, strerror(errno));
360 YPXFR_RETURN(YPXFR_XFRERR);
361 break;
362 }
363 case -1:
364 yp_error("ypxfr fork(): %s", strerror(errno));
365 YPXFR_RETURN(YPXFR_XFRERR);
366 break;
367 default:
368 result.xfrstat = YPXFR_SUCC;
369 children++;
370 forked = 0;
371 break;
372 }
373
374 return (&result);
375}
376#undef YPXFR_RETURN
377
378void *
379ypproc_clear_2_svc(void *argp, struct svc_req *rqstp)
380{
381 static char * result;
382 static char rval = 0;
383
384#ifdef DB_CACHE
385 if (yp_access(NULL, NULL, (struct svc_req *)rqstp))
386#else
387 if (yp_access(NULL, (struct svc_req *)rqstp))
388#endif
389 return (NULL);
390#ifdef DB_CACHE
391 /* clear out the database cache */
392 yp_flush_all();
393#endif
394 /* Re-read the securenets database for the hell of it. */
395 load_securenets();
396
397 result = &rval;
398 return((void *) &result);
399}
400
401/*
402 * For ypproc_all, we have to send a stream of ypresp_all structures
403 * via TCP, but the XDR filter generated from the yp.x protocol
404 * definition file only serializes one such structure. This means that
405 * to send the whole stream, you need a wrapper which feeds all the
406 * records into the underlying XDR routine until it hits an 'EOF.'
407 * But to use the wrapper, you have to violate the boundaries between
408 * RPC layers by calling svc_sendreply() directly from the ypproc_all
409 * service routine instead of letting the RPC dispatcher do it.
410 *
411 * Bleah.
412 */
413
414/*
415 * Custom XDR routine for serialzing results of ypproc_all: keep
416 * reading from the database and spew until we run out of records
417 * or encounter an error.
418 */
419static bool_t
420xdr_my_ypresp_all(register XDR *xdrs, ypresp_all *objp)
421{
422 while (1) {
423 /* Get a record. */
424 if ((objp->ypresp_all_u.val.stat =
425 yp_nextbykey(&objp->ypresp_all_u.val.key,
426 &objp->ypresp_all_u.val.val)) == YP_TRUE) {
427 objp->more = TRUE;
428 } else {
429 objp->more = FALSE;
430 }
431
432 /* Serialize. */
433 if (!xdr_ypresp_all(xdrs, objp))
434 return(FALSE);
435 if (objp->more == FALSE)
436 return(TRUE);
437 }
438}
439
440ypresp_all *
441ypproc_all_2_svc(ypreq_nokey *argp, struct svc_req *rqstp)
442{
443 static ypresp_all result;
444
445 /*
446 * Set this here so that the client will be forced to make
447 * at least one attempt to read from us even if all we're
448 * doing is returning an error.
449 */
450 result.more = TRUE;
451 result.ypresp_all_u.val.key.keydat_len = 0;
452 result.ypresp_all_u.val.key.keydat_val = "";
453
454#ifdef DB_CACHE
455 if (yp_access(argp->map, argp->domain, (struct svc_req *)rqstp)) {
456#else
457 if (yp_access(argp->map, (struct svc_req *)rqstp)) {
458#endif
459 result.ypresp_all_u.val.stat = YP_YPERR;
460 return (&result);
461 }
462
463 if (argp->domain == NULL || argp->map == NULL) {
464 result.ypresp_all_u.val.stat = YP_BADARGS;
465 return (&result);
466 }
467
468 /*
469 * XXX If we hit the child limit, fail the request.
470 * If we don't, and the map is large, we could block for
471 * a long time in the parent.
472 */
473 if (children >= MAX_CHILDREN) {
474 result.ypresp_all_u.val.stat = YP_YPERR;
475 return(&result);
476 }
477
478 /*
479 * The ypproc_all procedure can take a while to complete.
480 * Best to handle it in a subprocess so the parent doesn't
481 * block. (Is there a better way to do this? Maybe with
482 * async socket I/O?)
483 */
484 if (!debug && children < MAX_CHILDREN && fork()) {
485 children++;
486 forked = 0;
487 return (NULL);
488 } else {
489 forked++;
490 }
491
492 if (yp_select_map(argp->map, argp->domain,
493 &result.ypresp_all_u.val.key, 0) != YP_TRUE) {
494 result.ypresp_all_u.val.stat = yp_errno;
495 return(&result);
496 }
497
498 /* Kick off the actual data transfer. */
499 svc_sendreply(rqstp->rq_xprt, xdr_my_ypresp_all, (char *)&result);
500
501 /*
502 * Returning NULL prevents the dispatcher from calling
503 * svc_sendreply() since we already did it.
504 */
505 return (NULL);
506}
507
508ypresp_master *
509ypproc_master_2_svc(ypreq_nokey *argp, struct svc_req *rqstp)
510{
511 static ypresp_master result;
512 static char ypvalbuf[YPMAXRECORD];
513 keydat key = { master_sz, master_string };
514 valdat val;
515
516 result.peer = "";
517
518#ifdef DB_CACHE
519 if (yp_access(argp->map, argp->domain, (struct svc_req *)rqstp)) {
520#else
521 if (yp_access(argp->map, (struct svc_req *)rqstp)) {
522#endif
523 result.stat = YP_YPERR;
524 return(&result);
525 }
526
527 if (argp->domain == NULL) {
528 result.stat = YP_BADARGS;
529 return (&result);
530 }
531
532 if (yp_select_map(argp->map, argp->domain, &key, 1) != YP_TRUE) {
533 result.stat = yp_errno;
534 return(&result);
535 }
536
537 /*
538 * Note that we copy the data retrieved from the database to
539 * a private buffer and NUL terminate the buffer rather than
540 * terminating the data in place. We do this because by stuffing
541 * a '\0' into data.data, we will actually be corrupting memory
542 * allocated by the DB package. This is a bad thing now that we
543 * cache DB handles rather than closing the database immediately.
544 */
545 result.stat = yp_getbykey(&key, &val);
546 if (result.stat == YP_TRUE) {
547 bcopy((char *)val.valdat_val, (char *)&ypvalbuf,
548 val.valdat_len);
549 ypvalbuf[val.valdat_len] = '\0';
550 result.peer = (char *)&ypvalbuf;
551 } else
552 result.peer = "";
553
554 return (&result);
555}
556
557ypresp_order *
558ypproc_order_2_svc(ypreq_nokey *argp, struct svc_req *rqstp)
559{
560 static ypresp_order result;
561 keydat key = { order_sz, order_string };
562 valdat val;
563
564 result.ordernum = 0;
565
566#ifdef DB_CACHE
567 if (yp_access(argp->map, argp->domain, (struct svc_req *)rqstp)) {
568#else
569 if (yp_access(argp->map, (struct svc_req *)rqstp)) {
570#endif
571 result.stat = YP_YPERR;
572 return(&result);
573 }
574
575 if (argp->domain == NULL) {
576 result.stat = YP_BADARGS;
577 return (&result);
578 }
579
580 /*
581 * We could just check the timestamp on the map file,
582 * but that's a hack: we'll only know the last time the file
583 * was touched, not the last time the database contents were
584 * updated.
585 */
586
587 if (yp_select_map(argp->map, argp->domain, &key, 1) != YP_TRUE) {
588 result.stat = yp_errno;
589 return(&result);
590 }
591
592 result.stat = yp_getbykey(&key, &val);
593
594 if (result.stat == YP_TRUE)
595 result.ordernum = atoi((char *)val.valdat_val);
596 else
597 result.ordernum = 0;
598
599 return (&result);
600}
601
602static void yp_maplist_free(yp_maplist)
603 struct ypmaplist *yp_maplist;
604{
605 register struct ypmaplist *next;
606
607 while(yp_maplist) {
608 next = yp_maplist->next;
609 free(yp_maplist->map);
610 free(yp_maplist);
611 yp_maplist = next;
612 }
613 return;
614}
615
616static struct ypmaplist *yp_maplist_create(domain)
617 const char *domain;
618{
619 char yp_mapdir[MAXPATHLEN + 2];
620 char yp_mapname[MAXPATHLEN + 2];
621 struct ypmaplist *cur = NULL;
622 struct ypmaplist *yp_maplist = NULL;
623 DIR *dird;
624 struct dirent *dirp;
625 struct stat statbuf;
626
627 snprintf(yp_mapdir, sizeof(yp_mapdir), "%s/%s", yp_dir, domain);
628
629 if ((dird = opendir(yp_mapdir)) == NULL) {
630 yp_error("opendir(%s) failed: %s", yp_mapdir, strerror(errno));
631 return(NULL);
632 }
633
634 while ((dirp = readdir(dird)) != NULL) {
635 if (strcmp(dirp->d_name, ".") && strcmp(dirp->d_name, "..")) {
636 snprintf(yp_mapname, sizeof(yp_mapname), "%s/%s",
637 yp_mapdir,dirp->d_name);
638 if (stat(yp_mapname, &statbuf) < 0 ||
639 !S_ISREG(statbuf.st_mode))
640 continue;
641 if ((cur = (struct ypmaplist *)
642 malloc(sizeof(struct ypmaplist))) == NULL) {
643 yp_error("malloc() failed: %s",strerror(errno));
644 closedir(dird);
645 yp_maplist_free(yp_maplist);
646 return(NULL);
647 }
648 if ((cur->map = (char *)strdup(dirp->d_name)) == NULL) {
649 yp_error("strdup() failed: %s",strerror(errno));
650 closedir(dird);
651 yp_maplist_free(yp_maplist);
652 return(NULL);
653 }
654 cur->next = yp_maplist;
655 yp_maplist = cur;
656 if (debug)
657 yp_error("map: %s", yp_maplist->map);
658 }
659
660 }
661 closedir(dird);
662 return(yp_maplist);
663}
664
665ypresp_maplist *
666ypproc_maplist_2_svc(domainname *argp, struct svc_req *rqstp)
667{
668 static ypresp_maplist result = { 0, NULL };
669
670#ifdef DB_CACHE
671 if (yp_access(NULL, NULL, (struct svc_req *)rqstp)) {
672#else
673 if (yp_access(NULL, (struct svc_req *)rqstp)) {
674#endif
675 result.stat = YP_YPERR;
676 return(&result);
677 }
678
679 if (argp == NULL) {
680 result.stat = YP_BADARGS;
681 return (&result);
682 }
683
684 if (yp_validdomain(*argp)) {
685 result.stat = YP_NODOM;
686 return (&result);
687 }
688
689 /*
690 * We have to construct a linked list for the ypproc_maplist
691 * procedure using dynamically allocated memory. Since the XDR
692 * layer won't free this list for us, we have to deal with it
693 * ourselves. We call yp_maplist_free() first to free any
694 * previously allocated data we may have accumulated to insure
695 * that we have only one linked list in memory at any given
696 * time.
697 */
698
699 yp_maplist_free(result.maps);
700
701 if ((result.maps = yp_maplist_create(*argp)) == NULL) {
702 yp_error("yp_maplist_create failed");
703 result.stat = YP_YPERR;
704 return(&result);
705 } else
706 result.stat = YP_TRUE;
707
708 return (&result);
709}
710
711/*
712 * NIS v1 support. The nullproc, domain and domain_nonack
713 * functions from v1 are identical to those in v2, so all
714 * we have to do is hand off to them.
715 *
716 * The other functions are mostly just wrappers around their v2
717 * counterparts. For example, for the v1 'match' procedure, we
718 * crack open the argument structure, make a request to the v2
719 * 'match' function, repackage the data into a v1 response and
720 * then send it on its way.
721 *
722 * Note that we don't support the pull, push and get procedures.
723 * There's little documentation available to show what they
724 * do, and I suspect they're meant largely for map transfers
725 * between master and slave servers.
726 */
727
728void *
729ypoldproc_null_1_svc(void *argp, struct svc_req *rqstp)
730{
731 return(ypproc_null_2_svc(argp, rqstp));
732}
733
734bool_t *
735ypoldproc_domain_1_svc(domainname *argp, struct svc_req *rqstp)
736{
737 return(ypproc_domain_2_svc(argp, rqstp));
738}
739
740bool_t *
741ypoldproc_domain_nonack_1_svc(domainname *argp, struct svc_req *rqstp)
742{
743 return (ypproc_domain_nonack_2_svc(argp, rqstp));
744}
745
746/*
747 * the 'match' procedure sends a response of type YPRESP_VAL
748 */
749ypresponse *
750ypoldproc_match_1_svc(yprequest *argp, struct svc_req *rqstp)
751{
752 static ypresponse result;
753 ypresp_val *v2_result;
754
755 result.yp_resptype = YPRESP_VAL;
756 result.ypresponse_u.yp_resp_valtype.val.valdat_val = "";
757 result.ypresponse_u.yp_resp_valtype.val.valdat_len = 0;
758
759 if (argp->yp_reqtype != YPREQ_KEY) {
760 result.ypresponse_u.yp_resp_valtype.stat = YP_BADARGS;
761 return(&result);
762 }
763
764 v2_result = ypproc_match_2_svc(&argp->yprequest_u.yp_req_keytype,rqstp);
765 if (v2_result == NULL)
766 return(NULL);
767
768 bcopy((char *)v2_result,
769 (char *)&result.ypresponse_u.yp_resp_valtype,
770 sizeof(ypresp_val));
771
772 return (&result);
773}
774
775/*
776 * the 'first' procedure sends a response of type YPRESP_KEY_VAL
777 */
778ypresponse *
779ypoldproc_first_1_svc(yprequest *argp, struct svc_req *rqstp)
780{
781 static ypresponse result;
782 ypresp_key_val *v2_result;
783
784 result.yp_resptype = YPRESP_KEY_VAL;
785 result.ypresponse_u.yp_resp_key_valtype.val.valdat_val =
786 result.ypresponse_u.yp_resp_key_valtype.key.keydat_val = "";
787 result.ypresponse_u.yp_resp_key_valtype.val.valdat_len =
788 result.ypresponse_u.yp_resp_key_valtype.key.keydat_len = 0;
789
790 if (argp->yp_reqtype != YPREQ_NOKEY) {
791 result.ypresponse_u.yp_resp_key_valtype.stat = YP_BADARGS;
792 return(&result);
793 }
794
795 v2_result = ypproc_first_2_svc(&argp->yprequest_u.yp_req_nokeytype,
796 rqstp);
797 if (v2_result == NULL)
798 return(NULL);
799
800 bcopy((char *)v2_result,
801 (char *)&result.ypresponse_u.yp_resp_key_valtype,
802 sizeof(ypresp_key_val));
803
804 return (&result);
805}
806
807/*
808 * the 'next' procedure sends a response of type YPRESP_KEY_VAL
809 */
810ypresponse *
811ypoldproc_next_1_svc(yprequest *argp, struct svc_req *rqstp)
812{
813 static ypresponse result;
814 ypresp_key_val *v2_result;
815
816 result.yp_resptype = YPRESP_KEY_VAL;
817 result.ypresponse_u.yp_resp_key_valtype.val.valdat_val =
818 result.ypresponse_u.yp_resp_key_valtype.key.keydat_val = "";
819 result.ypresponse_u.yp_resp_key_valtype.val.valdat_len =
820 result.ypresponse_u.yp_resp_key_valtype.key.keydat_len = 0;
821
822 if (argp->yp_reqtype != YPREQ_KEY) {
823 result.ypresponse_u.yp_resp_key_valtype.stat = YP_BADARGS;
824 return(&result);
825 }
826
827 v2_result = ypproc_next_2_svc(&argp->yprequest_u.yp_req_keytype,rqstp);
828 if (v2_result == NULL)
829 return(NULL);
830
831 bcopy((char *)v2_result,
832 (char *)&result.ypresponse_u.yp_resp_key_valtype,
833 sizeof(ypresp_key_val));
834
835 return (&result);
836}
837
838/*
839 * the 'poll' procedure sends a response of type YPRESP_MAP_PARMS
840 */
841ypresponse *
842ypoldproc_poll_1_svc(yprequest *argp, struct svc_req *rqstp)
843{
844 static ypresponse result;
845 ypresp_master *v2_result1;
846 ypresp_order *v2_result2;
847
848 result.yp_resptype = YPRESP_MAP_PARMS;
849 result.ypresponse_u.yp_resp_map_parmstype.domain =
850 argp->yprequest_u.yp_req_nokeytype.domain;
851 result.ypresponse_u.yp_resp_map_parmstype.map =
852 argp->yprequest_u.yp_req_nokeytype.map;
853 /*
854 * Hmm... there is no 'status' value in the
855 * yp_resp_map_parmstype structure, so I have to
856 * guess at what to do to indicate a failure.
857 * I hope this is right.
858 */
859 result.ypresponse_u.yp_resp_map_parmstype.ordernum = 0;
860 result.ypresponse_u.yp_resp_map_parmstype.peer = "";
861
862 if (argp->yp_reqtype != YPREQ_MAP_PARMS) {
863 return(&result);
864 }
865
866 v2_result1 = ypproc_master_2_svc(&argp->yprequest_u.yp_req_nokeytype,
867 rqstp);
868 if (v2_result1 == NULL)
869 return(NULL);
870
871 if (v2_result1->stat != YP_TRUE) {
872 return(&result);
873 }
874
875 v2_result2 = ypproc_order_2_svc(&argp->yprequest_u.yp_req_nokeytype,
876 rqstp);
877 if (v2_result2 == NULL)
878 return(NULL);
879
880 if (v2_result2->stat != YP_TRUE) {
881 return(&result);
882 }
883
884 result.ypresponse_u.yp_resp_map_parmstype.peer =
885 v2_result1->peer;
886 result.ypresponse_u.yp_resp_map_parmstype.ordernum =
887 v2_result2->ordernum;
888
889 return (&result);
890}
891
892ypresponse *
893ypoldproc_push_1_svc(yprequest *argp, struct svc_req *rqstp)
894{
895 static ypresponse result;
896
897 /*
898 * Not implemented.
899 */
900
901 return (&result);
902}
903
904ypresponse *
905ypoldproc_pull_1_svc(yprequest *argp, struct svc_req *rqstp)
906{
907 static ypresponse result;
908
909 /*
910 * Not implemented.
911 */
912
913 return (&result);
914}
915
916ypresponse *
917ypoldproc_get_1_svc(yprequest *argp, struct svc_req *rqstp)
918{
919 static ypresponse result;
920
921 /*
922 * Not implemented.
923 */
924
925 return (&result);
926}