1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23 /* 24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 /* 30 * Portions of this source code were derived from Berkeley 31 * 4.3 BSD under license from the Regents of the University of 32 * California. 33 */ 34 35 #pragma ident "%Z%%M% %I% %E% SMI" 36 37 /* 38 * rpcb_clnt.c 39 * interface to rpcbind rpc service. 40 */ 41 42 #include "mt.h" 43 #include "rpc_mt.h" 44 #include <assert.h> 45 #include <rpc/rpc.h> 46 #include <rpc/rpcb_prot.h> 47 #include <netconfig.h> 48 #include <netdir.h> 49 #include <rpc/nettype.h> 50 #include <syslog.h> 51 #ifdef PORTMAP 52 #include <netinet/in.h> /* FOR IPPROTO_TCP/UDP definitions */ 53 #include <rpc/pmap_prot.h> 54 #endif 55 #ifdef ND_DEBUG 56 #include <stdio.h> 57 #endif 58 #include <sys/utsname.h> 59 #include <errno.h> 60 #include <stdlib.h> 61 #include <string.h> 62 #include <unistd.h> 63 64 #if !(defined(__i386) && !defined(__amd64)) 65 extern int _uname(); 66 #endif 67 68 static struct timeval tottimeout = { 60, 0 }; 69 static const struct timeval rmttimeout = { 3, 0 }; 70 static struct timeval rpcbrmttime = { 15, 0 }; 71 72 extern bool_t xdr_wrapstring(XDR *, char **); 73 74 static const char nullstring[] = "\000"; 75 76 extern CLIENT *_clnt_tli_create_timed(int, const struct netconfig *, 77 struct netbuf *, rpcprog_t, rpcvers_t, uint_t, uint_t, 78 const struct timeval *); 79 80 static CLIENT *_getclnthandle_timed(char *, struct netconfig *, char **, 81 struct timeval *); 82 83 84 /* 85 * The life time of a cached entry should not exceed 5 minutes 86 * since automountd attempts an unmount every 5 minutes. 87 * It is arbitrarily set a little lower (3 min = 180 sec) 88 * to reduce the time during which an entry is stale. 89 */ 90 #define CACHE_TTL 180 91 #define CACHESIZE 6 92 93 struct address_cache { 94 char *ac_host; 95 char *ac_netid; 96 char *ac_uaddr; 97 struct netbuf *ac_taddr; 98 struct address_cache *ac_next; 99 time_t ac_maxtime; 100 }; 101 102 static struct address_cache *front; 103 static int cachesize; 104 105 extern int lowvers; 106 extern int authdes_cachesz; 107 /* 108 * This routine adjusts the timeout used for calls to the remote rpcbind. 109 * Also, this routine can be used to set the use of portmapper version 2 110 * only when doing rpc_broadcasts 111 * These are private routines that may not be provided in future releases. 112 */ 113 bool_t 114 __rpc_control(int request, void *info) 115 { 116 switch (request) { 117 case CLCR_GET_RPCB_TIMEOUT: 118 *(struct timeval *)info = tottimeout; 119 break; 120 case CLCR_SET_RPCB_TIMEOUT: 121 tottimeout = *(struct timeval *)info; 122 break; 123 case CLCR_GET_LOWVERS: 124 *(int *)info = lowvers; 125 break; 126 case CLCR_SET_LOWVERS: 127 lowvers = *(int *)info; 128 break; 129 case CLCR_GET_RPCB_RMTTIME: 130 *(struct timeval *)info = rpcbrmttime; 131 break; 132 case CLCR_SET_RPCB_RMTTIME: 133 rpcbrmttime = *(struct timeval *)info; 134 break; 135 case CLCR_GET_CRED_CACHE_SZ: 136 *(int *)info = authdes_cachesz; 137 break; 138 case CLCR_SET_CRED_CACHE_SZ: 139 authdes_cachesz = *(int *)info; 140 break; 141 default: 142 return (FALSE); 143 } 144 return (TRUE); 145 } 146 147 /* 148 * It might seem that a reader/writer lock would be more reasonable here. 149 * However because getclnthandle(), the only user of the cache functions, 150 * may do a delete_cache() operation if a check_cache() fails to return an 151 * address useful to clnt_tli_create(), we may as well use a mutex. 152 */ 153 /* 154 * As it turns out, if the cache lock is *not* a reader/writer lock, we will 155 * block all clnt_create's if we are trying to connect to a host that's down, 156 * since the lock will be held all during that time. 157 */ 158 extern rwlock_t rpcbaddr_cache_lock; 159 160 /* 161 * The routines check_cache(), add_cache(), delete_cache() manage the 162 * cache of rpcbind addresses for (host, netid). 163 */ 164 165 static struct address_cache * 166 check_cache(char *host, char *netid) 167 { 168 struct address_cache *cptr; 169 170 /* READ LOCK HELD ON ENTRY: rpcbaddr_cache_lock */ 171 172 assert(RW_READ_HELD(&rpcbaddr_cache_lock)); 173 for (cptr = front; cptr != NULL; cptr = cptr->ac_next) { 174 if ((strcmp(cptr->ac_host, host) == 0) && 175 (strcmp(cptr->ac_netid, netid) == 0) && 176 (time(NULL) <= cptr->ac_maxtime)) { 177 #ifdef ND_DEBUG 178 fprintf(stderr, "Found cache entry for %s: %s\n", 179 host, netid); 180 #endif 181 return (cptr); 182 } 183 } 184 return (NULL); 185 } 186 187 static void 188 delete_cache(struct netbuf *addr) 189 { 190 struct address_cache *cptr, *prevptr = NULL; 191 192 /* WRITE LOCK HELD ON ENTRY: rpcbaddr_cache_lock */ 193 assert(RW_WRITE_HELD(&rpcbaddr_cache_lock)); 194 for (cptr = front; cptr != NULL; cptr = cptr->ac_next) { 195 if (!memcmp(cptr->ac_taddr->buf, addr->buf, addr->len)) { 196 free(cptr->ac_host); 197 free(cptr->ac_netid); 198 free(cptr->ac_taddr->buf); 199 free(cptr->ac_taddr); 200 if (cptr->ac_uaddr) 201 free(cptr->ac_uaddr); 202 if (prevptr) 203 prevptr->ac_next = cptr->ac_next; 204 else 205 front = cptr->ac_next; 206 free(cptr); 207 cachesize--; 208 break; 209 } 210 prevptr = cptr; 211 } 212 } 213 214 static void 215 add_cache(char *host, char *netid, struct netbuf *taddr, char *uaddr) 216 { 217 struct address_cache *ad_cache, *cptr, *prevptr; 218 219 ad_cache = malloc(sizeof (struct address_cache)); 220 if (!ad_cache) { 221 goto memerr; 222 } 223 ad_cache->ac_maxtime = time(NULL) + CACHE_TTL; 224 ad_cache->ac_host = strdup(host); 225 ad_cache->ac_netid = strdup(netid); 226 ad_cache->ac_uaddr = uaddr ? strdup(uaddr) : NULL; 227 ad_cache->ac_taddr = malloc(sizeof (struct netbuf)); 228 if (!ad_cache->ac_host || !ad_cache->ac_netid || !ad_cache->ac_taddr || 229 (uaddr && !ad_cache->ac_uaddr)) { 230 goto memerr1; 231 } 232 233 ad_cache->ac_taddr->len = ad_cache->ac_taddr->maxlen = taddr->len; 234 ad_cache->ac_taddr->buf = malloc(taddr->len); 235 if (ad_cache->ac_taddr->buf == NULL) { 236 goto memerr1; 237 } 238 239 (void) memcpy(ad_cache->ac_taddr->buf, taddr->buf, taddr->len); 240 #ifdef ND_DEBUG 241 (void) fprintf(stderr, "Added to cache: %s : %s\n", host, netid); 242 #endif 243 244 /* VARIABLES PROTECTED BY rpcbaddr_cache_lock: cptr */ 245 246 (void) rw_wrlock(&rpcbaddr_cache_lock); 247 if (cachesize < CACHESIZE) { 248 ad_cache->ac_next = front; 249 front = ad_cache; 250 cachesize++; 251 } else { 252 /* Free the last entry */ 253 cptr = front; 254 prevptr = NULL; 255 while (cptr->ac_next) { 256 prevptr = cptr; 257 cptr = cptr->ac_next; 258 } 259 260 #ifdef ND_DEBUG 261 fprintf(stderr, "Deleted from cache: %s : %s\n", 262 cptr->ac_host, cptr->ac_netid); 263 #endif 264 free(cptr->ac_host); 265 free(cptr->ac_netid); 266 free(cptr->ac_taddr->buf); 267 free(cptr->ac_taddr); 268 if (cptr->ac_uaddr) 269 free(cptr->ac_uaddr); 270 271 if (prevptr) { 272 prevptr->ac_next = NULL; 273 ad_cache->ac_next = front; 274 front = ad_cache; 275 } else { 276 front = ad_cache; 277 ad_cache->ac_next = NULL; 278 } 279 free(cptr); 280 } 281 (void) rw_unlock(&rpcbaddr_cache_lock); 282 return; 283 memerr1: 284 if (ad_cache->ac_host) 285 free(ad_cache->ac_host); 286 if (ad_cache->ac_netid) 287 free(ad_cache->ac_netid); 288 if (ad_cache->ac_uaddr) 289 free(ad_cache->ac_uaddr); 290 if (ad_cache->ac_taddr) 291 free(ad_cache->ac_taddr); 292 free(ad_cache); 293 memerr: 294 syslog(LOG_ERR, "add_cache : out of memory."); 295 } 296 297 /* 298 * This routine will return a client handle that is connected to the 299 * rpcbind. Returns NULL on error and free's everything. 300 */ 301 static CLIENT * 302 getclnthandle(char *host, struct netconfig *nconf, char **targaddr) 303 { 304 return (_getclnthandle_timed(host, nconf, targaddr, NULL)); 305 } 306 307 /* 308 * Same as getclnthandle() except it takes an extra timeout argument. 309 * This is for bug 4049792: clnt_create_timed does not timeout. 310 * 311 * If tp is NULL, use default timeout to get a client handle. 312 */ 313 static CLIENT * 314 _getclnthandle_timed(char *host, struct netconfig *nconf, char **targaddr, 315 struct timeval *tp) 316 { 317 CLIENT *client = NULL; 318 struct netbuf *addr; 319 struct netbuf addr_to_delete; 320 struct nd_addrlist *nas; 321 struct nd_hostserv rpcbind_hs; 322 struct address_cache *ad_cache; 323 char *tmpaddr; 324 int neterr; 325 int j; 326 327 /* VARIABLES PROTECTED BY rpcbaddr_cache_lock: ad_cache */ 328 329 /* Get the address of the rpcbind. Check cache first */ 330 addr_to_delete.len = 0; 331 (void) rw_rdlock(&rpcbaddr_cache_lock); 332 ad_cache = check_cache(host, nconf->nc_netid); 333 if (ad_cache != NULL) { 334 addr = ad_cache->ac_taddr; 335 client = _clnt_tli_create_timed(RPC_ANYFD, nconf, addr, 336 RPCBPROG, RPCBVERS4, 0, 0, tp); 337 if (client != NULL) { 338 if (targaddr) { 339 /* 340 * case where a client handle is created 341 * without a targaddr and the handle is 342 * requested with a targaddr 343 */ 344 if (ad_cache->ac_uaddr != NULL) { 345 *targaddr = strdup(ad_cache->ac_uaddr); 346 if (*targaddr == NULL) { 347 syslog(LOG_ERR, 348 "_getclnthandle_timed: strdup " 349 "failed."); 350 rpc_createerr.cf_stat = 351 RPC_SYSTEMERROR; 352 (void) rw_unlock( 353 &rpcbaddr_cache_lock); 354 return (NULL); 355 } 356 } else { 357 *targaddr = NULL; 358 } 359 } 360 (void) rw_unlock(&rpcbaddr_cache_lock); 361 return (client); 362 } 363 if (rpc_createerr.cf_stat == RPC_SYSTEMERROR) { 364 (void) rw_unlock(&rpcbaddr_cache_lock); 365 return (NULL); 366 } 367 addr_to_delete.len = addr->len; 368 addr_to_delete.buf = malloc(addr->len); 369 if (addr_to_delete.buf == NULL) { 370 addr_to_delete.len = 0; 371 } else { 372 (void) memcpy(addr_to_delete.buf, addr->buf, addr->len); 373 } 374 } 375 (void) rw_unlock(&rpcbaddr_cache_lock); 376 if (addr_to_delete.len != 0) { 377 /* 378 * Assume this may be due to cache data being 379 * outdated 380 */ 381 (void) rw_wrlock(&rpcbaddr_cache_lock); 382 delete_cache(&addr_to_delete); 383 (void) rw_unlock(&rpcbaddr_cache_lock); 384 free(addr_to_delete.buf); 385 } 386 rpcbind_hs.h_host = host; 387 rpcbind_hs.h_serv = "rpcbind"; 388 #ifdef ND_DEBUG 389 fprintf(stderr, "rpcbind client routines: diagnostics :\n"); 390 fprintf(stderr, "\tGetting address for (%s, %s, %s) ... \n", 391 rpcbind_hs.h_host, rpcbind_hs.h_serv, nconf->nc_netid); 392 #endif 393 394 if ((neterr = netdir_getbyname(nconf, &rpcbind_hs, &nas)) != 0) { 395 if (neterr == ND_NOHOST) 396 rpc_createerr.cf_stat = RPC_UNKNOWNHOST; 397 else 398 rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE; 399 return (NULL); 400 } 401 /* XXX nas should perhaps be cached for better performance */ 402 403 for (j = 0; j < nas->n_cnt; j++) { 404 addr = &(nas->n_addrs[j]); 405 #ifdef ND_DEBUG 406 { 407 int i; 408 char *ua; 409 410 ua = taddr2uaddr(nconf, &(nas->n_addrs[j])); 411 fprintf(stderr, "Got it [%s]\n", ua); 412 free(ua); 413 414 fprintf(stderr, "\tnetbuf len = %d, maxlen = %d\n", 415 addr->len, addr->maxlen); 416 fprintf(stderr, "\tAddress is "); 417 for (i = 0; i < addr->len; i++) 418 fprintf(stderr, "%u.", addr->buf[i]); 419 fprintf(stderr, "\n"); 420 } 421 #endif 422 client = _clnt_tli_create_timed(RPC_ANYFD, nconf, addr, RPCBPROG, 423 RPCBVERS4, 0, 0, tp); 424 if (client) 425 break; 426 } 427 #ifdef ND_DEBUG 428 if (!client) { 429 clnt_pcreateerror("rpcbind clnt interface"); 430 } 431 #endif 432 433 if (client) { 434 tmpaddr = targaddr ? taddr2uaddr(nconf, addr) : NULL; 435 add_cache(host, nconf->nc_netid, addr, tmpaddr); 436 if (targaddr) { 437 *targaddr = tmpaddr; 438 } 439 } 440 netdir_free((char *)nas, ND_ADDRLIST); 441 return (client); 442 } 443 444 /* 445 * This routine will return a client handle that is connected to the local 446 * rpcbind. Returns NULL on error and free's everything. 447 */ 448 static CLIENT * 449 local_rpcb(void) 450 { 451 static struct netconfig *loopnconf; 452 static char *hostname; 453 extern mutex_t loopnconf_lock; 454 455 /* VARIABLES PROTECTED BY loopnconf_lock: loopnconf */ 456 (void) mutex_lock(&loopnconf_lock); 457 if (loopnconf == NULL) { 458 struct utsname utsname; 459 struct netconfig *nconf, *tmpnconf = NULL; 460 void *nc_handle; 461 462 if (hostname == NULL) { 463 #if defined(__i386) && !defined(__amd64) 464 if ((_nuname(&utsname) == -1) || 465 #else 466 if ((_uname(&utsname) == -1) || 467 #endif 468 ((hostname = strdup(utsname.nodename)) == NULL)) { 469 syslog(LOG_ERR, "local_rpcb : strdup failed."); 470 rpc_createerr.cf_stat = RPC_UNKNOWNHOST; 471 (void) mutex_unlock(&loopnconf_lock); 472 return (NULL); 473 } 474 } 475 nc_handle = setnetconfig(); 476 if (nc_handle == NULL) { 477 /* fails to open netconfig file */ 478 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; 479 (void) mutex_unlock(&loopnconf_lock); 480 return (NULL); 481 } 482 while (nconf = getnetconfig(nc_handle)) { 483 if (strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) { 484 tmpnconf = nconf; 485 if (nconf->nc_semantics == NC_TPI_CLTS) 486 break; 487 } 488 } 489 if (tmpnconf == NULL) { 490 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; 491 (void) mutex_unlock(&loopnconf_lock); 492 return (NULL); 493 } 494 loopnconf = getnetconfigent(tmpnconf->nc_netid); 495 /* loopnconf is never freed */ 496 (void) endnetconfig(nc_handle); 497 } 498 (void) mutex_unlock(&loopnconf_lock); 499 return (getclnthandle(hostname, loopnconf, NULL)); 500 } 501 502 /* 503 * Set a mapping between program, version and address. 504 * Calls the rpcbind service to do the mapping. 505 */ 506 bool_t 507 rpcb_set(const rpcprog_t program, const rpcvers_t version, 508 const struct netconfig *nconf, const struct netbuf *address) 509 { 510 CLIENT *client; 511 bool_t rslt = FALSE; 512 RPCB parms; 513 char uidbuf[32]; 514 515 /* parameter checking */ 516 if (nconf == NULL) { 517 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; 518 return (FALSE); 519 } 520 if (address == NULL) { 521 rpc_createerr.cf_stat = RPC_UNKNOWNADDR; 522 return (FALSE); 523 } 524 client = local_rpcb(); 525 if (!client) 526 return (FALSE); 527 528 parms.r_addr = taddr2uaddr((struct netconfig *)nconf, 529 (struct netbuf *)address); /* convert to universal */ 530 if (!parms.r_addr) { 531 rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE; 532 return (FALSE); /* no universal address */ 533 } 534 parms.r_prog = program; 535 parms.r_vers = version; 536 parms.r_netid = nconf->nc_netid; 537 /* 538 * Though uid is not being used directly, we still send it for 539 * completeness. For non-unix platforms, perhaps some other 540 * string or an empty string can be sent. 541 */ 542 (void) sprintf(uidbuf, "%d", (int)geteuid()); 543 parms.r_owner = uidbuf; 544 545 CLNT_CALL(client, RPCBPROC_SET, (xdrproc_t)xdr_rpcb, (char *)&parms, 546 (xdrproc_t)xdr_bool, (char *)&rslt, tottimeout); 547 548 CLNT_DESTROY(client); 549 free(parms.r_addr); 550 return (rslt); 551 } 552 553 /* 554 * Remove the mapping between program, version and netbuf address. 555 * Calls the rpcbind service to do the un-mapping. 556 * If netbuf is NULL, unset for all the transports, otherwise unset 557 * only for the given transport. 558 */ 559 bool_t 560 rpcb_unset(const rpcprog_t program, const rpcvers_t version, 561 const struct netconfig *nconf) 562 { 563 CLIENT *client; 564 bool_t rslt = FALSE; 565 RPCB parms; 566 char uidbuf[32]; 567 568 client = local_rpcb(); 569 if (!client) 570 return (FALSE); 571 572 parms.r_prog = program; 573 parms.r_vers = version; 574 if (nconf) 575 parms.r_netid = nconf->nc_netid; 576 else 577 parms.r_netid = (char *)&nullstring[0]; /* unsets all */ 578 parms.r_addr = (char *)&nullstring[0]; 579 (void) sprintf(uidbuf, "%d", (int)geteuid()); 580 parms.r_owner = uidbuf; 581 582 CLNT_CALL(client, RPCBPROC_UNSET, (xdrproc_t)xdr_rpcb, (char *)&parms, 583 (xdrproc_t)xdr_bool, (char *)&rslt, tottimeout); 584 585 CLNT_DESTROY(client); 586 return (rslt); 587 } 588 589 /* 590 * From the merged list, find the appropriate entry 591 */ 592 static struct netbuf * 593 got_entry(rpcb_entry_list_ptr relp, struct netconfig *nconf) 594 { 595 struct netbuf *na = NULL; 596 rpcb_entry_list_ptr sp; 597 rpcb_entry *rmap; 598 599 for (sp = relp; sp != NULL; sp = sp->rpcb_entry_next) { 600 rmap = &sp->rpcb_entry_map; 601 if ((strcmp(nconf->nc_proto, rmap->r_nc_proto) == 0) && 602 (strcmp(nconf->nc_protofmly, rmap->r_nc_protofmly) == 0) && 603 (nconf->nc_semantics == rmap->r_nc_semantics) && 604 (rmap->r_maddr != NULL) && (rmap->r_maddr[0] != NULL)) { 605 na = uaddr2taddr(nconf, rmap->r_maddr); 606 #ifdef ND_DEBUG 607 fprintf(stderr, "\tRemote address is [%s].\n", 608 rmap->r_maddr); 609 if (!na) 610 fprintf(stderr, 611 "\tCouldn't resolve remote address!\n"); 612 #endif 613 break; 614 } 615 } 616 return (na); 617 } 618 619 /* 620 * Quick check to see if rpcbind is up. Tries to connect over 621 * local transport. 622 */ 623 bool_t 624 __rpcbind_is_up(void) 625 { 626 struct utsname name; 627 char uaddr[SYS_NMLN]; 628 struct netbuf *addr; 629 int fd; 630 struct t_call *sndcall; 631 struct netconfig *netconf; 632 bool_t res; 633 634 #if defined(__i386) && !defined(__amd64) 635 if (_nuname(&name) == -1) 636 #else 637 if (_uname(&name) == -1) 638 #endif 639 return (TRUE); 640 641 if ((fd = t_open("/dev/ticotsord", O_RDWR, NULL)) == -1) 642 return (TRUE); 643 644 if (t_bind(fd, NULL, NULL) == -1) { 645 (void) t_close(fd); 646 return (TRUE); 647 } 648 649 /* LINTED pointer cast */ 650 if ((sndcall = (struct t_call *)t_alloc(fd, T_CALL, 0)) == NULL) { 651 (void) t_close(fd); 652 return (TRUE); 653 } 654 655 uaddr[0] = '\0'; 656 (void) strcpy(uaddr, name.nodename); 657 (void) strcat(uaddr, ".rpc"); 658 if ((netconf = getnetconfigent("ticotsord")) == NULL) { 659 (void) t_free((char *)sndcall, T_CALL); 660 (void) t_close(fd); 661 return (FALSE); 662 } 663 addr = uaddr2taddr(netconf, uaddr); 664 freenetconfigent(netconf); 665 if (addr == NULL || addr->buf == NULL) { 666 if (addr) 667 free(addr); 668 (void) t_free((char *)sndcall, T_CALL); 669 (void) t_close(fd); 670 return (FALSE); 671 } 672 sndcall->addr.maxlen = addr->maxlen; 673 sndcall->addr.len = addr->len; 674 sndcall->addr.buf = addr->buf; 675 676 if (t_connect(fd, sndcall, NULL) == -1) 677 res = FALSE; 678 else 679 res = TRUE; 680 681 sndcall->addr.maxlen = sndcall->addr.len = 0; 682 sndcall->addr.buf = NULL; 683 (void) t_free((char *)sndcall, T_CALL); 684 free(addr->buf); 685 free(addr); 686 (void) t_close(fd); 687 688 return (res); 689 } 690 691 692 /* 693 * An internal function which optimizes rpcb_getaddr function. It also 694 * returns the client handle that it uses to contact the remote rpcbind. 695 * 696 * The algorithm used: If the transports is TCP or UDP, it first tries 697 * version 2 (portmap), 4 and then 3 (svr4). This order should be 698 * changed in the next OS release to 4, 2 and 3. We are assuming that by 699 * that time, version 4 would be available on many machines on the network. 700 * With this algorithm, we get performance as well as a plan for 701 * obsoleting version 2. 702 * 703 * For all other transports, the algorithm remains as 4 and then 3. 704 * 705 * XXX: Due to some problems with t_connect(), we do not reuse the same client 706 * handle for COTS cases and hence in these cases we do not return the 707 * client handle. This code will change if t_connect() ever 708 * starts working properly. Also look under clnt_vc.c. 709 */ 710 struct netbuf * 711 __rpcb_findaddr_timed(rpcprog_t program, rpcvers_t version, 712 struct netconfig *nconf, char *host, CLIENT **clpp, struct timeval *tp) 713 { 714 static bool_t check_rpcbind = TRUE; 715 CLIENT *client = NULL; 716 RPCB parms; 717 enum clnt_stat clnt_st; 718 char *ua = NULL; 719 uint_t vers; 720 struct netbuf *address = NULL; 721 uint_t start_vers = RPCBVERS4; 722 723 /* parameter checking */ 724 if (nconf == NULL) { 725 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; 726 return (NULL); 727 } 728 729 parms.r_addr = NULL; 730 731 /* 732 * Use default total timeout if no timeout is specified. 733 */ 734 if (tp == NULL) 735 tp = &tottimeout; 736 737 #ifdef PORTMAP 738 /* Try version 2 for TCP or UDP */ 739 if (strcmp(nconf->nc_protofmly, NC_INET) == 0) { 740 ushort_t port = 0; 741 struct netbuf remote; 742 uint_t pmapvers = 2; 743 struct pmap pmapparms; 744 745 /* 746 * Try UDP only - there are some portmappers out 747 * there that use UDP only. 748 */ 749 if (strcmp(nconf->nc_proto, NC_TCP) == 0) { 750 struct netconfig *newnconf; 751 void *handle; 752 753 if ((handle = __rpc_setconf("udp")) == NULL) { 754 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; 755 return (NULL); 756 } 757 758 /* 759 * The following to reinforce that you can 760 * only request for remote address through 761 * the same transport you are requesting. 762 * ie. requesting unversial address 763 * of IPv4 has to be carried through IPv4. 764 * Can't use IPv6 to send out the request. 765 * The mergeaddr in rpcbind can't handle 766 * this. 767 */ 768 for (;;) { 769 if ((newnconf = __rpc_getconf(handle)) 770 == NULL) { 771 __rpc_endconf(handle); 772 rpc_createerr.cf_stat = 773 RPC_UNKNOWNPROTO; 774 return (NULL); 775 } 776 /* 777 * here check the protocol family to 778 * be consistent with the request one 779 */ 780 if (strcmp(newnconf->nc_protofmly, 781 nconf->nc_protofmly) == NULL) 782 break; 783 } 784 785 client = _getclnthandle_timed(host, newnconf, 786 &parms.r_addr, tp); 787 __rpc_endconf(handle); 788 } else { 789 client = _getclnthandle_timed(host, nconf, 790 &parms.r_addr, tp); 791 } 792 if (client == NULL) 793 return (NULL); 794 795 /* 796 * Set version and retry timeout. 797 */ 798 CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rpcbrmttime); 799 CLNT_CONTROL(client, CLSET_VERS, (char *)&pmapvers); 800 801 pmapparms.pm_prog = program; 802 pmapparms.pm_vers = version; 803 pmapparms.pm_prot = strcmp(nconf->nc_proto, NC_TCP) ? 804 IPPROTO_UDP : IPPROTO_TCP; 805 pmapparms.pm_port = 0; /* not needed */ 806 clnt_st = CLNT_CALL(client, PMAPPROC_GETPORT, 807 (xdrproc_t)xdr_pmap, (caddr_t)&pmapparms, 808 (xdrproc_t)xdr_u_short, (caddr_t)&port, 809 *tp); 810 if (clnt_st != RPC_SUCCESS) { 811 if ((clnt_st == RPC_PROGVERSMISMATCH) || 812 (clnt_st == RPC_PROGUNAVAIL)) 813 goto try_rpcbind; /* Try different versions */ 814 rpc_createerr.cf_stat = RPC_PMAPFAILURE; 815 clnt_geterr(client, &rpc_createerr.cf_error); 816 goto error; 817 } else if (port == 0) { 818 address = NULL; 819 rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; 820 goto error; 821 } 822 port = htons(port); 823 CLNT_CONTROL(client, CLGET_SVC_ADDR, (char *)&remote); 824 if (((address = malloc(sizeof (struct netbuf))) == NULL) || 825 ((address->buf = malloc(remote.len)) == NULL)) { 826 rpc_createerr.cf_stat = RPC_SYSTEMERROR; 827 clnt_geterr(client, &rpc_createerr.cf_error); 828 if (address) { 829 free(address); 830 address = NULL; 831 } 832 goto error; 833 } 834 (void) memcpy(address->buf, remote.buf, remote.len); 835 (void) memcpy(&address->buf[sizeof (short)], &port, 836 sizeof (short)); 837 address->len = address->maxlen = remote.len; 838 goto done; 839 } 840 #endif 841 842 try_rpcbind: 843 /* 844 * Check if rpcbind is up. This prevents needless delays when 845 * accessing applications such as the keyserver while booting 846 * disklessly. 847 */ 848 if (check_rpcbind && strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) { 849 if (!__rpcbind_is_up()) { 850 rpc_createerr.cf_stat = RPC_PMAPFAILURE; 851 rpc_createerr.cf_error.re_errno = 0; 852 rpc_createerr.cf_error.re_terrno = 0; 853 goto error; 854 } 855 check_rpcbind = FALSE; 856 } 857 858 /* 859 * Now we try version 4 and then 3. 860 * We also send the remote system the address we used to 861 * contact it in case it can help to connect back with us 862 */ 863 parms.r_prog = program; 864 parms.r_vers = version; 865 parms.r_owner = (char *)&nullstring[0]; /* not needed; */ 866 /* just for xdring */ 867 parms.r_netid = nconf->nc_netid; /* not really needed */ 868 869 /* 870 * If a COTS transport is being used, try getting address via CLTS 871 * transport. This works only with version 4. 872 */ 873 if (nconf->nc_semantics == NC_TPI_COTS_ORD || 874 nconf->nc_semantics == NC_TPI_COTS) { 875 void *handle; 876 struct netconfig *nconf_clts; 877 rpcb_entry_list_ptr relp = NULL; 878 879 if (client == NULL) { 880 /* This did not go through the above PORTMAP/TCP code */ 881 if ((handle = __rpc_setconf("datagram_v")) != NULL) { 882 while ((nconf_clts = __rpc_getconf(handle)) 883 != NULL) { 884 if (strcmp(nconf_clts->nc_protofmly, 885 nconf->nc_protofmly) != 0) { 886 continue; 887 } 888 client = _getclnthandle_timed(host, 889 nconf_clts, &parms.r_addr, 890 tp); 891 break; 892 } 893 __rpc_endconf(handle); 894 } 895 if (client == NULL) 896 goto regular_rpcbind; /* Go the regular way */ 897 } else { 898 /* This is a UDP PORTMAP handle. Change to version 4 */ 899 vers = RPCBVERS4; 900 CLNT_CONTROL(client, CLSET_VERS, (char *)&vers); 901 } 902 /* 903 * We also send the remote system the address we used to 904 * contact it in case it can help it connect back with us 905 */ 906 if (parms.r_addr == NULL) { 907 parms.r_addr = strdup(""); /* for XDRing */ 908 if (parms.r_addr == NULL) { 909 syslog(LOG_ERR, "__rpcb_findaddr_timed: " 910 "strdup failed."); 911 rpc_createerr.cf_stat = RPC_SYSTEMERROR; 912 address = NULL; 913 goto error; 914 } 915 } 916 917 CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rpcbrmttime); 918 919 clnt_st = CLNT_CALL(client, RPCBPROC_GETADDRLIST, 920 (xdrproc_t)xdr_rpcb, (char *)&parms, 921 (xdrproc_t)xdr_rpcb_entry_list_ptr, 922 (char *)&relp, *tp); 923 if (clnt_st == RPC_SUCCESS) { 924 if (address = got_entry(relp, nconf)) { 925 xdr_free((xdrproc_t)xdr_rpcb_entry_list_ptr, 926 (char *)&relp); 927 goto done; 928 } 929 /* Entry not found for this transport */ 930 xdr_free((xdrproc_t)xdr_rpcb_entry_list_ptr, 931 (char *)&relp); 932 /* 933 * XXX: should have perhaps returned with error but 934 * since the remote machine might not always be able 935 * to send the address on all transports, we try the 936 * regular way with regular_rpcbind 937 */ 938 goto regular_rpcbind; 939 } else if ((clnt_st == RPC_PROGVERSMISMATCH) || 940 (clnt_st == RPC_PROGUNAVAIL)) { 941 start_vers = RPCBVERS; /* Try version 3 now */ 942 goto regular_rpcbind; /* Try different versions */ 943 } else { 944 rpc_createerr.cf_stat = RPC_PMAPFAILURE; 945 clnt_geterr(client, &rpc_createerr.cf_error); 946 goto error; 947 } 948 } 949 950 regular_rpcbind: 951 952 /* Now the same transport is to be used to get the address */ 953 if (client && ((nconf->nc_semantics == NC_TPI_COTS_ORD) || 954 (nconf->nc_semantics == NC_TPI_COTS))) { 955 /* A CLTS type of client - destroy it */ 956 CLNT_DESTROY(client); 957 client = NULL; 958 free(parms.r_addr); 959 parms.r_addr = NULL; 960 } 961 962 if (client == NULL) { 963 client = _getclnthandle_timed(host, nconf, &parms.r_addr, tp); 964 if (client == NULL) { 965 address = NULL; 966 goto error; 967 } 968 } 969 if (parms.r_addr == NULL) { 970 parms.r_addr = strdup(""); /* for XDRing */ 971 if (parms.r_addr == NULL) { 972 syslog(LOG_ERR, "__rpcb_findaddr_timed: " 973 "strdup failed."); 974 address = NULL; 975 rpc_createerr.cf_stat = RPC_SYSTEMERROR; 976 goto error; 977 } 978 } 979 980 /* First try from start_vers and then version 3 (RPCBVERS) */ 981 982 CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rpcbrmttime); 983 for (vers = start_vers; vers >= RPCBVERS; vers--) { 984 /* Set the version */ 985 CLNT_CONTROL(client, CLSET_VERS, (char *)&vers); 986 clnt_st = CLNT_CALL(client, RPCBPROC_GETADDR, 987 (xdrproc_t)xdr_rpcb, (char *)&parms, 988 (xdrproc_t)xdr_wrapstring, 989 (char *)&ua, *tp); 990 if (clnt_st == RPC_SUCCESS) { 991 if ((ua == NULL) || (ua[0] == NULL)) { 992 if (ua != NULL) 993 xdr_free(xdr_wrapstring, (char *)&ua); 994 995 /* address unknown */ 996 rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; 997 goto error; 998 } 999 address = uaddr2taddr(nconf, ua); 1000 #ifdef ND_DEBUG 1001 fprintf(stderr, "\tRemote address is [%s]\n", ua); 1002 if (!address) 1003 fprintf(stderr, 1004 "\tCouldn't resolve remote address!\n"); 1005 #endif 1006 xdr_free((xdrproc_t)xdr_wrapstring, (char *)&ua); 1007 1008 if (!address) { 1009 /* We don't know about your universal address */ 1010 rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE; 1011 goto error; 1012 } 1013 goto done; 1014 } 1015 if (clnt_st == RPC_PROGVERSMISMATCH) { 1016 struct rpc_err rpcerr; 1017 1018 clnt_geterr(client, &rpcerr); 1019 if (rpcerr.re_vers.low > RPCBVERS4) 1020 goto error; /* a new version, can't handle */ 1021 } else if (clnt_st != RPC_PROGUNAVAIL) { 1022 /* Cant handle this error */ 1023 goto error; 1024 } 1025 } 1026 1027 if ((address == NULL) || (address->len == 0)) { 1028 rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; 1029 clnt_geterr(client, &rpc_createerr.cf_error); 1030 } 1031 1032 error: 1033 if (client) { 1034 CLNT_DESTROY(client); 1035 client = NULL; 1036 } 1037 done: 1038 if (nconf->nc_semantics != NC_TPI_CLTS) { 1039 /* This client is the connectionless one */ 1040 if (client) { 1041 CLNT_DESTROY(client); 1042 client = NULL; 1043 } 1044 } 1045 if (clpp) { 1046 *clpp = client; 1047 } else if (client) { 1048 CLNT_DESTROY(client); 1049 } 1050 if (parms.r_addr) 1051 free(parms.r_addr); 1052 return (address); 1053 } 1054 1055 1056 /* 1057 * Find the mapped address for program, version. 1058 * Calls the rpcbind service remotely to do the lookup. 1059 * Uses the transport specified in nconf. 1060 * Returns FALSE (0) if no map exists, else returns 1. 1061 * 1062 * Assuming that the address is all properly allocated 1063 */ 1064 int 1065 rpcb_getaddr(const rpcprog_t program, const rpcvers_t version, 1066 const struct netconfig *nconf, struct netbuf *address, const char *host) 1067 { 1068 struct netbuf *na; 1069 1070 if ((na = __rpcb_findaddr_timed(program, version, 1071 (struct netconfig *)nconf, (char *)host, NULL, NULL)) == NULL) 1072 return (FALSE); 1073 1074 if (na->len > address->maxlen) { 1075 /* Too long address */ 1076 netdir_free((char *)na, ND_ADDR); 1077 rpc_createerr.cf_stat = RPC_FAILED; 1078 return (FALSE); 1079 } 1080 (void) memcpy(address->buf, na->buf, (int)na->len); 1081 address->len = na->len; 1082 netdir_free((char *)na, ND_ADDR); 1083 return (TRUE); 1084 } 1085 1086 /* 1087 * Get a copy of the current maps. 1088 * Calls the rpcbind service remotely to get the maps. 1089 * 1090 * It returns only a list of the services 1091 * It returns NULL on failure. 1092 */ 1093 rpcblist * 1094 rpcb_getmaps(const struct netconfig *nconf, const char *host) 1095 { 1096 rpcblist_ptr head = NULL; 1097 CLIENT *client; 1098 enum clnt_stat clnt_st; 1099 int vers = 0; 1100 1101 client = getclnthandle((char *)host, 1102 (struct netconfig *)nconf, NULL); 1103 if (client == NULL) 1104 return (NULL); 1105 1106 clnt_st = CLNT_CALL(client, RPCBPROC_DUMP, 1107 (xdrproc_t)xdr_void, NULL, 1108 (xdrproc_t)xdr_rpcblist_ptr, 1109 (char *)&head, tottimeout); 1110 if (clnt_st == RPC_SUCCESS) 1111 goto done; 1112 1113 if ((clnt_st != RPC_PROGVERSMISMATCH) && 1114 (clnt_st != RPC_PROGUNAVAIL)) { 1115 rpc_createerr.cf_stat = RPC_RPCBFAILURE; 1116 clnt_geterr(client, &rpc_createerr.cf_error); 1117 goto done; 1118 } 1119 1120 /* fall back to earlier version */ 1121 CLNT_CONTROL(client, CLGET_VERS, (char *)&vers); 1122 if (vers == RPCBVERS4) { 1123 vers = RPCBVERS; 1124 CLNT_CONTROL(client, CLSET_VERS, (char *)&vers); 1125 if (CLNT_CALL(client, RPCBPROC_DUMP, 1126 (xdrproc_t)xdr_void, 1127 NULL, (xdrproc_t)xdr_rpcblist_ptr, 1128 (char *)&head, tottimeout) == RPC_SUCCESS) 1129 goto done; 1130 } 1131 rpc_createerr.cf_stat = RPC_RPCBFAILURE; 1132 clnt_geterr(client, &rpc_createerr.cf_error); 1133 1134 done: 1135 CLNT_DESTROY(client); 1136 return (head); 1137 } 1138 1139 /* 1140 * rpcbinder remote-call-service interface. 1141 * This routine is used to call the rpcbind remote call service 1142 * which will look up a service program in the address maps, and then 1143 * remotely call that routine with the given parameters. This allows 1144 * programs to do a lookup and call in one step. 1145 */ 1146 enum clnt_stat 1147 rpcb_rmtcall(const struct netconfig *nconf, const char *host, 1148 const rpcprog_t prog, const rpcvers_t vers, const rpcproc_t proc, 1149 const xdrproc_t xdrargs, const caddr_t argsp, const xdrproc_t xdrres, 1150 const caddr_t resp, const struct timeval tout, struct netbuf *addr_ptr) 1151 { 1152 CLIENT *client; 1153 enum clnt_stat stat; 1154 struct r_rpcb_rmtcallargs a; 1155 struct r_rpcb_rmtcallres r; 1156 int rpcb_vers; 1157 1158 client = getclnthandle((char *)host, (struct netconfig *)nconf, NULL); 1159 if (client == NULL) 1160 return (RPC_FAILED); 1161 CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rmttimeout); 1162 a.prog = prog; 1163 a.vers = vers; 1164 a.proc = proc; 1165 a.args.args_val = argsp; 1166 a.xdr_args = xdrargs; 1167 r.addr = NULL; 1168 r.results.results_val = resp; 1169 r.xdr_res = xdrres; 1170 1171 for (rpcb_vers = RPCBVERS4; rpcb_vers >= RPCBVERS; rpcb_vers--) { 1172 CLNT_CONTROL(client, CLSET_VERS, (char *)&rpcb_vers); 1173 stat = CLNT_CALL(client, RPCBPROC_CALLIT, 1174 (xdrproc_t)xdr_rpcb_rmtcallargs, (char *)&a, 1175 (xdrproc_t)xdr_rpcb_rmtcallres, (char *)&r, tout); 1176 if ((stat == RPC_SUCCESS) && (addr_ptr != NULL)) { 1177 struct netbuf *na; 1178 1179 na = uaddr2taddr((struct netconfig *)nconf, r.addr); 1180 if (!na) { 1181 stat = RPC_N2AXLATEFAILURE; 1182 ((struct netbuf *)addr_ptr)->len = 0; 1183 goto error; 1184 } 1185 if (na->len > addr_ptr->maxlen) { 1186 /* Too long address */ 1187 stat = RPC_FAILED; /* XXX A better error no */ 1188 netdir_free((char *)na, ND_ADDR); 1189 ((struct netbuf *)addr_ptr)->len = 0; 1190 goto error; 1191 } 1192 (void) memcpy(addr_ptr->buf, na->buf, (int)na->len); 1193 ((struct netbuf *)addr_ptr)->len = na->len; 1194 netdir_free((char *)na, ND_ADDR); 1195 break; 1196 } 1197 if ((stat != RPC_PROGVERSMISMATCH) && 1198 (stat != RPC_PROGUNAVAIL)) 1199 goto error; 1200 } 1201 error: 1202 CLNT_DESTROY(client); 1203 if (r.addr) 1204 xdr_free((xdrproc_t)xdr_wrapstring, (char *)&r.addr); 1205 return (stat); 1206 } 1207 1208 /* 1209 * Gets the time on the remote host. 1210 * Returns 1 if succeeds else 0. 1211 */ 1212 bool_t 1213 rpcb_gettime(const char *host, time_t *timep) 1214 { 1215 CLIENT *client = NULL; 1216 void *handle; 1217 struct netconfig *nconf; 1218 int vers; 1219 enum clnt_stat st; 1220 1221 if ((host == NULL) || (host[0] == NULL)) { 1222 (void) time(timep); 1223 return (TRUE); 1224 } 1225 1226 if ((handle = __rpc_setconf("netpath")) == NULL) { 1227 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; 1228 return (FALSE); 1229 } 1230 rpc_createerr.cf_stat = RPC_SUCCESS; 1231 while (client == NULL) { 1232 if ((nconf = __rpc_getconf(handle)) == NULL) { 1233 if (rpc_createerr.cf_stat == RPC_SUCCESS) 1234 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; 1235 break; 1236 } 1237 client = getclnthandle((char *)host, nconf, NULL); 1238 if (client) 1239 break; 1240 } 1241 __rpc_endconf(handle); 1242 if (client == NULL) 1243 return (FALSE); 1244 1245 st = CLNT_CALL(client, RPCBPROC_GETTIME, 1246 (xdrproc_t)xdr_void, NULL, 1247 (xdrproc_t)xdr_time_t, (char *)timep, tottimeout); 1248 1249 if ((st == RPC_PROGVERSMISMATCH) || (st == RPC_PROGUNAVAIL)) { 1250 CLNT_CONTROL(client, CLGET_VERS, (char *)&vers); 1251 if (vers == RPCBVERS4) { 1252 /* fall back to earlier version */ 1253 vers = RPCBVERS; 1254 CLNT_CONTROL(client, CLSET_VERS, (char *)&vers); 1255 st = CLNT_CALL(client, RPCBPROC_GETTIME, 1256 (xdrproc_t)xdr_void, NULL, 1257 (xdrproc_t)xdr_time_t, (char *)timep, 1258 tottimeout); 1259 } 1260 } 1261 CLNT_DESTROY(client); 1262 return (st == RPC_SUCCESS? TRUE : FALSE); 1263 } 1264 1265 /* 1266 * Converts taddr to universal address. This routine should never 1267 * really be called because local n2a libraries are always provided. 1268 */ 1269 char * 1270 rpcb_taddr2uaddr(struct netconfig *nconf, struct netbuf *taddr) 1271 { 1272 CLIENT *client; 1273 char *uaddr = NULL; 1274 1275 /* parameter checking */ 1276 if (nconf == NULL) { 1277 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; 1278 return (NULL); 1279 } 1280 if (taddr == NULL) { 1281 rpc_createerr.cf_stat = RPC_UNKNOWNADDR; 1282 return (NULL); 1283 } 1284 client = local_rpcb(); 1285 if (!client) 1286 return (NULL); 1287 1288 CLNT_CALL(client, RPCBPROC_TADDR2UADDR, (xdrproc_t)xdr_netbuf, 1289 (char *)taddr, (xdrproc_t)xdr_wrapstring, (char *)&uaddr, 1290 tottimeout); 1291 CLNT_DESTROY(client); 1292 return (uaddr); 1293 } 1294 1295 /* 1296 * Converts universal address to netbuf. This routine should never 1297 * really be called because local n2a libraries are always provided. 1298 */ 1299 struct netbuf * 1300 rpcb_uaddr2taddr(struct netconfig *nconf, char *uaddr) 1301 { 1302 CLIENT *client; 1303 struct netbuf *taddr; 1304 1305 /* parameter checking */ 1306 if (nconf == NULL) { 1307 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; 1308 return (NULL); 1309 } 1310 if (uaddr == NULL) { 1311 rpc_createerr.cf_stat = RPC_UNKNOWNADDR; 1312 return (NULL); 1313 } 1314 client = local_rpcb(); 1315 if (!client) 1316 return (NULL); 1317 1318 taddr = calloc(1, sizeof (struct netbuf)); 1319 if (taddr == NULL) { 1320 CLNT_DESTROY(client); 1321 return (NULL); 1322 } 1323 1324 if (CLNT_CALL(client, RPCBPROC_UADDR2TADDR, (xdrproc_t)xdr_wrapstring, 1325 (char *)&uaddr, (xdrproc_t)xdr_netbuf, (char *)taddr, 1326 tottimeout) != RPC_SUCCESS) { 1327 free(taddr); 1328 taddr = NULL; 1329 } 1330 CLNT_DESTROY(client); 1331 return (taddr); 1332 } 1333