yp_server.c revision 20907
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[] = "$Id: yp_server.c,v 1.3 1996/12/24 18:43:53 wpaul Exp $"; 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 * The ypproc_all procedure can take a while to complete. 470 * Best to handle it in a subprocess so the parent doesn't 471 * block. (Is there a better way to do this? Maybe with 472 * async socket I/O?) 473 */ 474 if (!debug && children < MAX_CHILDREN && fork()) { 475 children++; 476 forked = 0; 477 return (NULL); 478 } else { 479 forked++; 480 } 481 482 if (yp_select_map(argp->map, argp->domain, 483 &result.ypresp_all_u.val.key, 0) != YP_TRUE) { 484 result.ypresp_all_u.val.stat = yp_errno; 485 return(&result); 486 } 487 488 /* Kick off the actual data transfer. */ 489 svc_sendreply(rqstp->rq_xprt, xdr_my_ypresp_all, (char *)&result); 490 491 /* 492 * Returning NULL prevents the dispatcher from calling 493 * svc_sendreply() since we already did it. 494 */ 495 return (NULL); 496} 497 498ypresp_master * 499ypproc_master_2_svc(ypreq_nokey *argp, struct svc_req *rqstp) 500{ 501 static ypresp_master result; 502 static char ypvalbuf[YPMAXRECORD]; 503 keydat key = { master_sz, master_string }; 504 valdat val; 505 506 result.peer = ""; 507 508#ifdef DB_CACHE 509 if (yp_access(argp->map, argp->domain, (struct svc_req *)rqstp)) { 510#else 511 if (yp_access(argp->map, (struct svc_req *)rqstp)) { 512#endif 513 result.stat = YP_YPERR; 514 return(&result); 515 } 516 517 if (argp->domain == NULL) { 518 result.stat = YP_BADARGS; 519 return (&result); 520 } 521 522 if (yp_select_map(argp->map, argp->domain, &key, 1) != YP_TRUE) { 523 result.stat = yp_errno; 524 return(&result); 525 } 526 527 /* 528 * Note that we copy the data retrieved from the database to 529 * a private buffer and NUL terminate the buffer rather than 530 * terminating the data in place. We do this because by stuffing 531 * a '\0' into data.data, we will actually be corrupting memory 532 * allocated by the DB package. This is a bad thing now that we 533 * cache DB handles rather than closing the database immediately. 534 */ 535 result.stat = yp_getbykey(&key, &val); 536 if (result.stat == YP_TRUE) { 537 bcopy((char *)val.valdat_val, (char *)&ypvalbuf, 538 val.valdat_len); 539 ypvalbuf[val.valdat_len] = '\0'; 540 result.peer = (char *)&ypvalbuf; 541 } else 542 result.peer = ""; 543 544 return (&result); 545} 546 547ypresp_order * 548ypproc_order_2_svc(ypreq_nokey *argp, struct svc_req *rqstp) 549{ 550 static ypresp_order result; 551 keydat key = { order_sz, order_string }; 552 valdat val; 553 554 result.ordernum = 0; 555 556#ifdef DB_CACHE 557 if (yp_access(argp->map, argp->domain, (struct svc_req *)rqstp)) { 558#else 559 if (yp_access(argp->map, (struct svc_req *)rqstp)) { 560#endif 561 result.stat = YP_YPERR; 562 return(&result); 563 } 564 565 if (argp->domain == NULL) { 566 result.stat = YP_BADARGS; 567 return (&result); 568 } 569 570 /* 571 * We could just check the timestamp on the map file, 572 * but that's a hack: we'll only know the last time the file 573 * was touched, not the last time the database contents were 574 * updated. 575 */ 576 577 if (yp_select_map(argp->map, argp->domain, &key, 1) != YP_TRUE) { 578 result.stat = yp_errno; 579 return(&result); 580 } 581 582 result.stat = yp_getbykey(&key, &val); 583 584 if (result.stat == YP_TRUE) 585 result.ordernum = atoi((char *)val.valdat_val); 586 else 587 result.ordernum = 0; 588 589 return (&result); 590} 591 592static void yp_maplist_free(yp_maplist) 593 struct ypmaplist *yp_maplist; 594{ 595 register struct ypmaplist *next; 596 597 while(yp_maplist) { 598 next = yp_maplist->next; 599 free(yp_maplist->map); 600 free(yp_maplist); 601 yp_maplist = next; 602 } 603 return; 604} 605 606static struct ypmaplist *yp_maplist_create(domain) 607 const char *domain; 608{ 609 char yp_mapdir[MAXPATHLEN + 2]; 610 char yp_mapname[MAXPATHLEN + 2]; 611 struct ypmaplist *cur = NULL; 612 struct ypmaplist *yp_maplist = NULL; 613 DIR *dird; 614 struct dirent *dirp; 615 struct stat statbuf; 616 617 snprintf(yp_mapdir, sizeof(yp_mapdir), "%s/%s", yp_dir, domain); 618 619 if ((dird = opendir(yp_mapdir)) == NULL) { 620 yp_error("opendir(%s) failed: %s", yp_mapdir, strerror(errno)); 621 return(NULL); 622 } 623 624 while ((dirp = readdir(dird)) != NULL) { 625 if (strcmp(dirp->d_name, ".") && strcmp(dirp->d_name, "..")) { 626 snprintf(yp_mapname, sizeof(yp_mapname), "%s/%s", 627 yp_mapdir,dirp->d_name); 628 if (stat(yp_mapname, &statbuf) < 0 || 629 !S_ISREG(statbuf.st_mode)) 630 continue; 631 if ((cur = (struct ypmaplist *) 632 malloc(sizeof(struct ypmaplist))) == NULL) { 633 yp_error("malloc() failed: %s",strerror(errno)); 634 closedir(dird); 635 yp_maplist_free(yp_maplist); 636 return(NULL); 637 } 638 if ((cur->map = (char *)strdup(dirp->d_name)) == NULL) { 639 yp_error("strdup() failed: %s",strerror(errno)); 640 closedir(dird); 641 yp_maplist_free(yp_maplist); 642 return(NULL); 643 } 644 cur->next = yp_maplist; 645 yp_maplist = cur; 646 if (debug) 647 yp_error("map: %s", yp_maplist->map); 648 } 649 650 } 651 closedir(dird); 652 return(yp_maplist); 653} 654 655ypresp_maplist * 656ypproc_maplist_2_svc(domainname *argp, struct svc_req *rqstp) 657{ 658 static ypresp_maplist result = { 0, NULL }; 659 660#ifdef DB_CACHE 661 if (yp_access(NULL, NULL, (struct svc_req *)rqstp)) { 662#else 663 if (yp_access(NULL, (struct svc_req *)rqstp)) { 664#endif 665 result.stat = YP_YPERR; 666 return(&result); 667 } 668 669 if (argp == NULL) { 670 result.stat = YP_BADARGS; 671 return (&result); 672 } 673 674 if (yp_validdomain(*argp)) { 675 result.stat = YP_NODOM; 676 return (&result); 677 } 678 679 /* 680 * We have to construct a linked list for the ypproc_maplist 681 * procedure using dynamically allocated memory. Since the XDR 682 * layer won't free this list for us, we have to deal with it 683 * ourselves. We call yp_maplist_free() first to free any 684 * previously allocated data we may have accumulated to insure 685 * that we have only one linked list in memory at any given 686 * time. 687 */ 688 689 yp_maplist_free(result.maps); 690 691 if ((result.maps = yp_maplist_create(*argp)) == NULL) { 692 yp_error("yp_maplist_create failed"); 693 result.stat = YP_YPERR; 694 return(&result); 695 } else 696 result.stat = YP_TRUE; 697 698 return (&result); 699} 700 701/* 702 * NIS v1 support. The nullproc, domain and domain_nonack 703 * functions from v1 are identical to those in v2, so all 704 * we have to do is hand off to them. 705 * 706 * The other functions are mostly just wrappers around their v2 707 * counterparts. For example, for the v1 'match' procedure, we 708 * crack open the argument structure, make a request to the v2 709 * 'match' function, repackage the data into a v1 response and 710 * then send it on its way. 711 * 712 * Note that we don't support the pull, push and get procedures. 713 * There's little documentation available to show what they 714 * do, and I suspect they're meant largely for map transfers 715 * between master and slave servers. 716 */ 717 718void * 719ypoldproc_null_1_svc(void *argp, struct svc_req *rqstp) 720{ 721 return(ypproc_null_2_svc(argp, rqstp)); 722} 723 724bool_t * 725ypoldproc_domain_1_svc(domainname *argp, struct svc_req *rqstp) 726{ 727 return(ypproc_domain_2_svc(argp, rqstp)); 728} 729 730bool_t * 731ypoldproc_domain_nonack_1_svc(domainname *argp, struct svc_req *rqstp) 732{ 733 return (ypproc_domain_nonack_2_svc(argp, rqstp)); 734} 735 736/* 737 * the 'match' procedure sends a response of type YPRESP_VAL 738 */ 739ypresponse * 740ypoldproc_match_1_svc(yprequest *argp, struct svc_req *rqstp) 741{ 742 static ypresponse result; 743 ypresp_val *v2_result; 744 745 result.yp_resptype = YPRESP_VAL; 746 result.ypresponse_u.yp_resp_valtype.val.valdat_val = ""; 747 result.ypresponse_u.yp_resp_valtype.val.valdat_len = 0; 748 749 if (argp->yp_reqtype != YPREQ_KEY) { 750 result.ypresponse_u.yp_resp_valtype.stat = YP_BADARGS; 751 return(&result); 752 } 753 754 v2_result = ypproc_match_2_svc(&argp->yprequest_u.yp_req_keytype,rqstp); 755 if (v2_result == NULL) 756 return(NULL); 757 758 bcopy((char *)v2_result, 759 (char *)&result.ypresponse_u.yp_resp_valtype, 760 sizeof(ypresp_val)); 761 762 return (&result); 763} 764 765/* 766 * the 'first' procedure sends a response of type YPRESP_KEY_VAL 767 */ 768ypresponse * 769ypoldproc_first_1_svc(yprequest *argp, struct svc_req *rqstp) 770{ 771 static ypresponse result; 772 ypresp_key_val *v2_result; 773 774 result.yp_resptype = YPRESP_KEY_VAL; 775 result.ypresponse_u.yp_resp_key_valtype.val.valdat_val = 776 result.ypresponse_u.yp_resp_key_valtype.key.keydat_val = ""; 777 result.ypresponse_u.yp_resp_key_valtype.val.valdat_len = 778 result.ypresponse_u.yp_resp_key_valtype.key.keydat_len = 0; 779 780 if (argp->yp_reqtype != YPREQ_NOKEY) { 781 result.ypresponse_u.yp_resp_key_valtype.stat = YP_BADARGS; 782 return(&result); 783 } 784 785 v2_result = ypproc_first_2_svc(&argp->yprequest_u.yp_req_nokeytype, 786 rqstp); 787 if (v2_result == NULL) 788 return(NULL); 789 790 bcopy((char *)v2_result, 791 (char *)&result.ypresponse_u.yp_resp_key_valtype, 792 sizeof(ypresp_key_val)); 793 794 return (&result); 795} 796 797/* 798 * the 'next' procedure sends a response of type YPRESP_KEY_VAL 799 */ 800ypresponse * 801ypoldproc_next_1_svc(yprequest *argp, struct svc_req *rqstp) 802{ 803 static ypresponse result; 804 ypresp_key_val *v2_result; 805 806 result.yp_resptype = YPRESP_KEY_VAL; 807 result.ypresponse_u.yp_resp_key_valtype.val.valdat_val = 808 result.ypresponse_u.yp_resp_key_valtype.key.keydat_val = ""; 809 result.ypresponse_u.yp_resp_key_valtype.val.valdat_len = 810 result.ypresponse_u.yp_resp_key_valtype.key.keydat_len = 0; 811 812 if (argp->yp_reqtype != YPREQ_KEY) { 813 result.ypresponse_u.yp_resp_key_valtype.stat = YP_BADARGS; 814 return(&result); 815 } 816 817 v2_result = ypproc_next_2_svc(&argp->yprequest_u.yp_req_keytype,rqstp); 818 if (v2_result == NULL) 819 return(NULL); 820 821 bcopy((char *)v2_result, 822 (char *)&result.ypresponse_u.yp_resp_key_valtype, 823 sizeof(ypresp_key_val)); 824 825 return (&result); 826} 827 828/* 829 * the 'poll' procedure sends a response of type YPRESP_MAP_PARMS 830 */ 831ypresponse * 832ypoldproc_poll_1_svc(yprequest *argp, struct svc_req *rqstp) 833{ 834 static ypresponse result; 835 ypresp_master *v2_result1; 836 ypresp_order *v2_result2; 837 838 result.yp_resptype = YPRESP_MAP_PARMS; 839 result.ypresponse_u.yp_resp_map_parmstype.domain = 840 argp->yprequest_u.yp_req_nokeytype.domain; 841 result.ypresponse_u.yp_resp_map_parmstype.map = 842 argp->yprequest_u.yp_req_nokeytype.map; 843 /* 844 * Hmm... there is no 'status' value in the 845 * yp_resp_map_parmstype structure, so I have to 846 * guess at what to do to indicate a failure. 847 * I hope this is right. 848 */ 849 result.ypresponse_u.yp_resp_map_parmstype.ordernum = 0; 850 result.ypresponse_u.yp_resp_map_parmstype.peer = ""; 851 852 if (argp->yp_reqtype != YPREQ_MAP_PARMS) { 853 return(&result); 854 } 855 856 v2_result1 = ypproc_master_2_svc(&argp->yprequest_u.yp_req_nokeytype, 857 rqstp); 858 if (v2_result1 == NULL) 859 return(NULL); 860 861 if (v2_result1->stat != YP_TRUE) { 862 return(&result); 863 } 864 865 v2_result2 = ypproc_order_2_svc(&argp->yprequest_u.yp_req_nokeytype, 866 rqstp); 867 if (v2_result2 == NULL) 868 return(NULL); 869 870 if (v2_result2->stat != YP_TRUE) { 871 return(&result); 872 } 873 874 result.ypresponse_u.yp_resp_map_parmstype.peer = 875 v2_result1->peer; 876 result.ypresponse_u.yp_resp_map_parmstype.ordernum = 877 v2_result2->ordernum; 878 879 return (&result); 880} 881 882ypresponse * 883ypoldproc_push_1_svc(yprequest *argp, struct svc_req *rqstp) 884{ 885 static ypresponse result; 886 887 /* 888 * Not implemented. 889 */ 890 891 return (&result); 892} 893 894ypresponse * 895ypoldproc_pull_1_svc(yprequest *argp, struct svc_req *rqstp) 896{ 897 static ypresponse result; 898 899 /* 900 * Not implemented. 901 */ 902 903 return (&result); 904} 905 906ypresponse * 907ypoldproc_get_1_svc(yprequest *argp, struct svc_req *rqstp) 908{ 909 static ypresponse result; 910 911 /* 912 * Not implemented. 913 */ 914 915 return (&result); 916} 917