Print this page
4729 __rpcb_findaddr_timed should try rpcbind protocol 4 first

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libnsl/rpc/rpcb_clnt.c
          +++ new/usr/src/lib/libnsl/rpc/rpcb_clnt.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * When distributing Covered Code, include this CDDL HEADER in each
  15   15   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16   16   * If applicable, add the following below this CDDL HEADER, with the
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  
  23   23  /*
       24 + * Copyright (c) 2014 Gary Mills
  24   25   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  25   26   * Use is subject to license terms.
  26   27   */
  27   28  
  28   29  /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  29   30  /* All Rights Reserved */
  30   31  /*
  31   32   * Portions of this source code were derived from Berkeley
  32   33   * 4.3 BSD under license from the Regents of the University of
  33   34   * California.
  34   35   */
  35   36  
  36      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  37      -
  38   37  /*
  39   38   * interface to rpcbind rpc service.
  40   39   */
  41   40  
  42   41  #include "mt.h"
  43   42  #include "rpc_mt.h"
  44   43  #include <assert.h>
  45   44  #include <rpc/rpc.h>
  46   45  #include <rpc/rpcb_prot.h>
  47   46  #include <netconfig.h>
↓ open down ↓ 114 lines elided ↑ open up ↑
 162  161  check_cache(char *host, char *netid)
 163  162  {
 164  163          struct address_cache *cptr;
 165  164  
 166  165          /* READ LOCK HELD ON ENTRY: rpcbaddr_cache_lock */
 167  166  
 168  167          assert(RW_READ_HELD(&rpcbaddr_cache_lock));
 169  168          for (cptr = front; cptr != NULL; cptr = cptr->ac_next) {
 170  169                  if ((strcmp(cptr->ac_host, host) == 0) &&
 171  170                      (strcmp(cptr->ac_netid, netid) == 0) &&
 172      -                        (time(NULL) <= cptr->ac_maxtime)) {
      171 +                    (time(NULL) <= cptr->ac_maxtime)) {
 173  172  #ifdef ND_DEBUG
 174  173                          fprintf(stderr, "Found cache entry for %s: %s\n",
 175      -                                host, netid);
      174 +                            host, netid);
 176  175  #endif
 177  176                          return (cptr);
 178  177                  }
 179  178          }
 180  179          return (NULL);
 181  180  }
 182  181  
 183  182  static void
 184  183  delete_cache(struct netbuf *addr)
 185  184  {
↓ open down ↓ 29 lines elided ↑ open up ↑
 215  214          ad_cache = malloc(sizeof (struct address_cache));
 216  215          if (!ad_cache) {
 217  216                  goto memerr;
 218  217          }
 219  218          ad_cache->ac_maxtime = time(NULL) + CACHE_TTL;
 220  219          ad_cache->ac_host = strdup(host);
 221  220          ad_cache->ac_netid = strdup(netid);
 222  221          ad_cache->ac_uaddr = uaddr ? strdup(uaddr) : NULL;
 223  222          ad_cache->ac_taddr = malloc(sizeof (struct netbuf));
 224  223          if (!ad_cache->ac_host || !ad_cache->ac_netid || !ad_cache->ac_taddr ||
 225      -                (uaddr && !ad_cache->ac_uaddr)) {
      224 +            (uaddr && !ad_cache->ac_uaddr)) {
 226  225                  goto memerr1;
 227  226          }
 228  227  
 229  228          ad_cache->ac_taddr->len = ad_cache->ac_taddr->maxlen = taddr->len;
 230  229          ad_cache->ac_taddr->buf = malloc(taddr->len);
 231  230          if (ad_cache->ac_taddr->buf == NULL) {
 232  231                  goto memerr1;
 233  232          }
 234  233  
 235  234          (void) memcpy(ad_cache->ac_taddr->buf, taddr->buf, taddr->len);
↓ open down ↓ 12 lines elided ↑ open up ↑
 248  247                  /* Free the last entry */
 249  248                  cptr = front;
 250  249                  prevptr = NULL;
 251  250                  while (cptr->ac_next) {
 252  251                          prevptr = cptr;
 253  252                          cptr = cptr->ac_next;
 254  253                  }
 255  254  
 256  255  #ifdef ND_DEBUG
 257  256                  fprintf(stderr, "Deleted from cache: %s : %s\n",
 258      -                        cptr->ac_host, cptr->ac_netid);
      257 +                    cptr->ac_host, cptr->ac_netid);
 259  258  #endif
 260  259                  free(cptr->ac_host);
 261  260                  free(cptr->ac_netid);
 262  261                  free(cptr->ac_taddr->buf);
 263  262                  free(cptr->ac_taddr);
 264  263                  if (cptr->ac_uaddr)
 265  264                          free(cptr->ac_uaddr);
 266  265  
 267  266                  if (prevptr) {
 268  267                          prevptr->ac_next = NULL;
↓ open down ↓ 53 lines elided ↑ open up ↑
 322  321  
 323  322  /* VARIABLES PROTECTED BY rpcbaddr_cache_lock:  ad_cache */
 324  323  
 325  324          /* Get the address of the rpcbind.  Check cache first */
 326  325          addr_to_delete.len = 0;
 327  326          (void) rw_rdlock(&rpcbaddr_cache_lock);
 328  327          ad_cache = check_cache(host, nconf->nc_netid);
 329  328          if (ad_cache != NULL) {
 330  329                  addr = ad_cache->ac_taddr;
 331  330                  client = _clnt_tli_create_timed(RPC_ANYFD, nconf, addr,
 332      -                                RPCBPROG, RPCBVERS4, 0, 0, tp);
      331 +                    RPCBPROG, RPCBVERS4, 0, 0, tp);
 333  332                  if (client != NULL) {
 334  333                          if (targaddr) {
 335  334                                  /*
 336  335                                   * case where a client handle is created
 337  336                                   * without a targaddr and the handle is
 338  337                                   * requested with a targaddr
 339  338                                   */
 340  339                                  if (ad_cache->ac_uaddr != NULL) {
 341  340                                          *targaddr = strdup(ad_cache->ac_uaddr);
 342  341                                          if (*targaddr == NULL) {
 343  342                                                  syslog(LOG_ERR,
 344  343                                                  "_getclnthandle_timed: strdup "
 345  344                                                  "failed.");
 346  345                                                  rpc_createerr.cf_stat =
 347      -                                                        RPC_SYSTEMERROR;
      346 +                                                    RPC_SYSTEMERROR;
 348  347                                                  (void) rw_unlock(
 349      -                                                        &rpcbaddr_cache_lock);
      348 +                                                    &rpcbaddr_cache_lock);
 350  349                                                  return (NULL);
 351  350                                          }
 352  351                                  } else {
 353  352                                          *targaddr = NULL;
 354  353                                  }
 355  354                          }
 356  355                          (void) rw_unlock(&rpcbaddr_cache_lock);
 357  356                          return (client);
 358  357                  }
 359  358                  if (rpc_createerr.cf_stat == RPC_SYSTEMERROR) {
↓ open down ↓ 17 lines elided ↑ open up ↑
 377  376                  (void) rw_wrlock(&rpcbaddr_cache_lock);
 378  377                  delete_cache(&addr_to_delete);
 379  378                  (void) rw_unlock(&rpcbaddr_cache_lock);
 380  379                  free(addr_to_delete.buf);
 381  380          }
 382  381          rpcbind_hs.h_host = host;
 383  382          rpcbind_hs.h_serv = "rpcbind";
 384  383  #ifdef ND_DEBUG
 385  384          fprintf(stderr, "rpcbind client routines: diagnostics :\n");
 386  385          fprintf(stderr, "\tGetting address for (%s, %s, %s) ... \n",
 387      -                rpcbind_hs.h_host, rpcbind_hs.h_serv, nconf->nc_netid);
      386 +            rpcbind_hs.h_host, rpcbind_hs.h_serv, nconf->nc_netid);
 388  387  #endif
 389  388  
 390  389          if ((neterr = netdir_getbyname(nconf, &rpcbind_hs, &nas)) != 0) {
 391  390                  if (neterr == ND_NOHOST)
 392  391                          rpc_createerr.cf_stat = RPC_UNKNOWNHOST;
 393  392                  else
 394  393                          rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE;
 395  394                  return (NULL);
 396  395          }
 397  396          /* XXX nas should perhaps be cached for better performance */
↓ open down ↓ 3 lines elided ↑ open up ↑
 401  400  #ifdef ND_DEBUG
 402  401  {
 403  402          int i;
 404  403          char *ua;
 405  404  
 406  405          ua = taddr2uaddr(nconf, &(nas->n_addrs[j]));
 407  406          fprintf(stderr, "Got it [%s]\n", ua);
 408  407          free(ua);
 409  408  
 410  409          fprintf(stderr, "\tnetbuf len = %d, maxlen = %d\n",
 411      -                addr->len, addr->maxlen);
      410 +            addr->len, addr->maxlen);
 412  411          fprintf(stderr, "\tAddress is ");
 413  412          for (i = 0; i < addr->len; i++)
 414  413                  fprintf(stderr, "%u.", addr->buf[i]);
 415  414          fprintf(stderr, "\n");
 416  415  }
 417  416  #endif
 418  417          client = _clnt_tli_create_timed(RPC_ANYFD, nconf, addr, RPCBPROG,
 419  418                                  RPCBVERS4, 0, 0, tp);
 420  419          if (client)
 421  420                  break;
↓ open down ↓ 29 lines elided ↑ open up ↑
 451  450  /* VARIABLES PROTECTED BY loopnconf_lock: loopnconf */
 452  451          (void) mutex_lock(&loopnconf_lock);
 453  452          if (loopnconf == NULL) {
 454  453                  struct utsname utsname;
 455  454                  struct netconfig *nconf, *tmpnconf = NULL;
 456  455                  void *nc_handle;
 457  456  
 458  457                  if (hostname == NULL) {
 459  458  #if defined(__i386) && !defined(__amd64)
 460  459                          if ((_nuname(&utsname) == -1) ||
      460 +                            ((hostname = strdup(utsname.nodename)) == NULL)) {
 461  461  #else
 462  462                          if ((uname(&utsname) == -1) ||
 463      -#endif
 464  463                              ((hostname = strdup(utsname.nodename)) == NULL)) {
      464 +#endif
 465  465                                  syslog(LOG_ERR, "local_rpcb : strdup failed.");
 466  466                                  rpc_createerr.cf_stat = RPC_UNKNOWNHOST;
 467  467                                  (void) mutex_unlock(&loopnconf_lock);
 468  468                                  return (NULL);
 469  469                          }
 470  470                  }
 471  471                  nc_handle = setnetconfig();
 472  472                  if (nc_handle == NULL) {
 473  473                          /* fails to open netconfig file */
 474  474                          rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
↓ open down ↓ 40 lines elided ↑ open up ↑
 515  515          }
 516  516          if (address == NULL) {
 517  517                  rpc_createerr.cf_stat = RPC_UNKNOWNADDR;
 518  518                  return (FALSE);
 519  519          }
 520  520          client = local_rpcb();
 521  521          if (!client)
 522  522                  return (FALSE);
 523  523  
 524  524          parms.r_addr = taddr2uaddr((struct netconfig *)nconf,
 525      -                        (struct netbuf *)address); /* convert to universal */
      525 +            (struct netbuf *)address); /* convert to universal */
 526  526          if (!parms.r_addr) {
 527  527                  rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE;
 528  528                  return (FALSE); /* no universal address */
 529  529          }
 530  530          parms.r_prog = program;
 531  531          parms.r_vers = version;
 532  532          parms.r_netid = nconf->nc_netid;
 533  533          /*
 534  534           * Though uid is not being used directly, we still send it for
 535  535           * completeness.  For non-unix platforms, perhaps some other
 536  536           * string or an empty string can be sent.
 537  537           */
 538  538          (void) sprintf(uidbuf, "%d", (int)geteuid());
 539  539          parms.r_owner = uidbuf;
 540  540  
 541  541          CLNT_CALL(client, RPCBPROC_SET, (xdrproc_t)xdr_rpcb, (char *)&parms,
 542      -                        (xdrproc_t)xdr_bool, (char *)&rslt, tottimeout);
      542 +            (xdrproc_t)xdr_bool, (char *)&rslt, tottimeout);
 543  543  
 544  544          CLNT_DESTROY(client);
 545  545          free(parms.r_addr);
 546  546          return (rslt);
 547  547  }
 548  548  
 549  549  /*
 550  550   * Remove the mapping between program, version and netbuf address.
 551  551   * Calls the rpcbind service to do the un-mapping.
 552  552   * If netbuf is NULL, unset for all the transports, otherwise unset
↓ open down ↓ 16 lines elided ↑ open up ↑
 569  569          parms.r_vers = version;
 570  570          if (nconf)
 571  571                  parms.r_netid = nconf->nc_netid;
 572  572          else
 573  573                  parms.r_netid = (char *)&nullstring[0]; /* unsets  all */
 574  574          parms.r_addr = (char *)&nullstring[0];
 575  575          (void) sprintf(uidbuf, "%d", (int)geteuid());
 576  576          parms.r_owner = uidbuf;
 577  577  
 578  578          CLNT_CALL(client, RPCBPROC_UNSET, (xdrproc_t)xdr_rpcb, (char *)&parms,
 579      -                        (xdrproc_t)xdr_bool, (char *)&rslt, tottimeout);
      579 +            (xdrproc_t)xdr_bool, (char *)&rslt, tottimeout);
 580  580  
 581  581          CLNT_DESTROY(client);
 582  582          return (rslt);
 583  583  }
 584  584  
 585  585  /*
 586  586   * From the merged list, find the appropriate entry
 587  587   */
 588  588  static struct netbuf *
 589  589  got_entry(rpcb_entry_list_ptr relp, struct netconfig *nconf)
↓ open down ↓ 4 lines elided ↑ open up ↑
 594  594  
 595  595          for (sp = relp; sp != NULL; sp = sp->rpcb_entry_next) {
 596  596                  rmap = &sp->rpcb_entry_map;
 597  597                  if ((strcmp(nconf->nc_proto, rmap->r_nc_proto) == 0) &&
 598  598                      (strcmp(nconf->nc_protofmly, rmap->r_nc_protofmly) == 0) &&
 599  599                      (nconf->nc_semantics == rmap->r_nc_semantics) &&
 600  600                      (rmap->r_maddr != NULL) && (rmap->r_maddr[0] != NULL)) {
 601  601                          na = uaddr2taddr(nconf, rmap->r_maddr);
 602  602  #ifdef ND_DEBUG
 603  603                          fprintf(stderr, "\tRemote address is [%s].\n",
 604      -                                rmap->r_maddr);
      604 +                            rmap->r_maddr);
 605  605                          if (!na)
 606  606                                  fprintf(stderr,
 607  607                                      "\tCouldn't resolve remote address!\n");
 608  608  #endif
 609  609                          break;
 610  610                  }
 611  611          }
 612  612          return (na);
 613  613  }
 614  614  
↓ open down ↓ 64 lines elided ↑ open up ↑
 679  679          (void) t_free((char *)sndcall, T_CALL);
 680  680          free(addr->buf);
 681  681          free(addr);
 682  682          (void) t_close(fd);
 683  683  
 684  684          return (res);
 685  685  }
 686  686  
 687  687  
 688  688  /*
 689      - * An internal function which optimizes rpcb_getaddr function.  It also
      689 + * An internal function which optimizes rpcb_getaddr function.  It returns
      690 + * the universal address of the remote service or NULL.  It also optionally
 690  691   * returns the client handle that it uses to contact the remote rpcbind.
 691  692   *
 692      - * The algorithm used: If the transports is TCP or UDP, it first tries
 693      - * version 2 (portmap), 4 and then 3 (svr4).  This order should be
 694      - * changed in the next OS release to 4, 2 and 3.  We are assuming that by
 695      - * that time, version 4 would be available on many machines on the network.
      693 + * The algorithm used: First try version 4.  Then try version 3 (svr4).
      694 + * Finally, if the transport is TCP or UDP, try version 2 (portmap).
      695 + * We assume that version 4 is now available on many machines on the network.
 696  696   * With this algorithm, we get performance as well as a plan for
 697  697   * obsoleting version 2.
 698  698   *
 699      - * For all other transports, the algorithm remains as 4 and then 3.
 700      - *
 701  699   * XXX: Due to some problems with t_connect(), we do not reuse the same client
 702  700   * handle for COTS cases and hence in these cases we do not return the
 703  701   * client handle.  This code will change if t_connect() ever
 704  702   * starts working properly.  Also look under clnt_vc.c.
 705  703   */
 706  704  struct netbuf *
 707  705  __rpcb_findaddr_timed(rpcprog_t program, rpcvers_t version,
 708  706          struct netconfig *nconf, char *host, CLIENT **clpp, struct timeval *tp)
 709  707  {
 710  708          static bool_t check_rpcbind = TRUE;
 711  709          CLIENT *client = NULL;
 712  710          RPCB parms;
 713  711          enum clnt_stat clnt_st;
 714  712          char *ua = NULL;
 715  713          uint_t vers;
 716  714          struct netbuf *address = NULL;
 717      -        uint_t start_vers = RPCBVERS4;
      715 +        void *handle;
      716 +        rpcb_entry_list_ptr relp = NULL;
      717 +        bool_t tmp_client = FALSE;
 718  718  
 719  719          /* parameter checking */
 720  720          if (nconf == NULL) {
 721  721                  rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
 722  722                  return (NULL);
 723  723          }
 724  724  
 725  725          parms.r_addr = NULL;
 726  726  
 727  727          /*
 728  728           * Use default total timeout if no timeout is specified.
 729  729           */
 730  730          if (tp == NULL)
 731  731                  tp = &tottimeout;
 732  732  
 733      -#ifdef PORTMAP
 734      -        /* Try version 2 for TCP or UDP */
 735      -        if (strcmp(nconf->nc_protofmly, NC_INET) == 0) {
 736      -                ushort_t port = 0;
 737      -                struct netbuf remote;
 738      -                uint_t pmapvers = 2;
 739      -                struct pmap pmapparms;
 740      -
 741      -                /*
 742      -                 * Try UDP only - there are some portmappers out
 743      -                 * there that use UDP only.
 744      -                 */
 745      -                if (strcmp(nconf->nc_proto, NC_TCP) == 0) {
 746      -                        struct netconfig *newnconf;
 747      -                        void *handle;
 748      -
 749      -                        if ((handle = __rpc_setconf("udp")) == NULL) {
 750      -                                rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
 751      -                                return (NULL);
 752      -                        }
 753      -
 754      -                        /*
 755      -                         * The following to reinforce that you can
 756      -                         * only request for remote address through
 757      -                         * the same transport you are requesting.
 758      -                         * ie. requesting unversial address
 759      -                         * of IPv4 has to be carried through IPv4.
 760      -                         * Can't use IPv6 to send out the request.
 761      -                         * The mergeaddr in rpcbind can't handle
 762      -                         * this.
 763      -                         */
 764      -                        for (;;) {
 765      -                                if ((newnconf = __rpc_getconf(handle))
 766      -                                                                    == NULL) {
 767      -                                        __rpc_endconf(handle);
 768      -                                        rpc_createerr.cf_stat =
 769      -                                            RPC_UNKNOWNPROTO;
 770      -                                        return (NULL);
 771      -                                }
 772      -                                /*
 773      -                                 * here check the protocol family to
 774      -                                 * be consistent with the request one
 775      -                                 */
 776      -                                if (strcmp(newnconf->nc_protofmly,
 777      -                                    nconf->nc_protofmly) == NULL)
 778      -                                        break;
 779      -                        }
 780      -
 781      -                        client = _getclnthandle_timed(host, newnconf,
 782      -                                        &parms.r_addr, tp);
 783      -                        __rpc_endconf(handle);
 784      -                } else {
 785      -                        client = _getclnthandle_timed(host, nconf,
 786      -                                        &parms.r_addr, tp);
 787      -                }
 788      -                if (client == NULL)
 789      -                        return (NULL);
 790      -
 791      -                /*
 792      -                 * Set version and retry timeout.
 793      -                 */
 794      -                CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rpcbrmttime);
 795      -                CLNT_CONTROL(client, CLSET_VERS, (char *)&pmapvers);
 796      -
 797      -                pmapparms.pm_prog = program;
 798      -                pmapparms.pm_vers = version;
 799      -                pmapparms.pm_prot = strcmp(nconf->nc_proto, NC_TCP) ?
 800      -                                    IPPROTO_UDP : IPPROTO_TCP;
 801      -                pmapparms.pm_port = 0;  /* not needed */
 802      -                clnt_st = CLNT_CALL(client, PMAPPROC_GETPORT,
 803      -                                    (xdrproc_t)xdr_pmap, (caddr_t)&pmapparms,
 804      -                                    (xdrproc_t)xdr_u_short, (caddr_t)&port,
 805      -                                    *tp);
 806      -                if (clnt_st != RPC_SUCCESS) {
 807      -                        if ((clnt_st == RPC_PROGVERSMISMATCH) ||
 808      -                            (clnt_st == RPC_PROGUNAVAIL))
 809      -                                goto try_rpcbind; /* Try different versions */
 810      -                        rpc_createerr.cf_stat = RPC_PMAPFAILURE;
 811      -                        clnt_geterr(client, &rpc_createerr.cf_error);
 812      -                        goto error;
 813      -                } else if (port == 0) {
 814      -                        address = NULL;
 815      -                        rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
 816      -                        goto error;
 817      -                }
 818      -                port = htons(port);
 819      -                CLNT_CONTROL(client, CLGET_SVC_ADDR, (char *)&remote);
 820      -                if (((address = malloc(sizeof (struct netbuf))) == NULL) ||
 821      -                    ((address->buf = malloc(remote.len)) == NULL)) {
 822      -                        rpc_createerr.cf_stat = RPC_SYSTEMERROR;
 823      -                        clnt_geterr(client, &rpc_createerr.cf_error);
 824      -                        if (address) {
 825      -                                free(address);
 826      -                                address = NULL;
 827      -                        }
 828      -                        goto error;
 829      -                }
 830      -                (void) memcpy(address->buf, remote.buf, remote.len);
 831      -                (void) memcpy(&address->buf[sizeof (short)], &port,
 832      -                                                                sizeof (short));
 833      -                address->len = address->maxlen = remote.len;
 834      -                goto done;
 835      -        }
 836      -#endif
 837      -
 838      -try_rpcbind:
 839  733          /*
 840  734           * Check if rpcbind is up.  This prevents needless delays when
 841  735           * accessing applications such as the keyserver while booting
 842  736           * disklessly.
 843  737           */
 844  738          if (check_rpcbind && strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) {
 845  739                  if (!__rpcbind_is_up()) {
 846  740                          rpc_createerr.cf_stat = RPC_PMAPFAILURE;
 847  741                          rpc_createerr.cf_error.re_errno = 0;
 848  742                          rpc_createerr.cf_error.re_terrno = 0;
 849  743                          goto error;
 850  744                  }
 851  745                  check_rpcbind = FALSE;
 852  746          }
 853  747  
 854  748          /*
 855      -         * Now we try version 4 and then 3.
 856      -         * We also send the remote system the address we used to
 857      -         * contact it in case it can help to connect back with us
      749 +         * First try version 4.
 858  750           */
 859  751          parms.r_prog = program;
 860  752          parms.r_vers = version;
 861  753          parms.r_owner = (char *)&nullstring[0]; /* not needed; */
 862  754          /* just for xdring */
 863  755          parms.r_netid = nconf->nc_netid; /* not really needed */
 864  756  
 865  757          /*
 866  758           * If a COTS transport is being used, try getting address via CLTS
 867  759           * transport.  This works only with version 4.
 868  760           */
 869  761          if (nconf->nc_semantics == NC_TPI_COTS_ORD ||
 870  762              nconf->nc_semantics == NC_TPI_COTS) {
 871      -                void *handle;
      763 +                handle = __rpc_setconf("datagram_v");
      764 +        } else {
      765 +                handle = __rpc_setconf(nconf->nc_proto);
      766 +        }
      767 +
      768 +        if (handle != NULL) {
 872  769                  struct netconfig *nconf_clts;
 873      -                rpcb_entry_list_ptr relp = NULL;
 874  770  
 875      -                if (client == NULL) {
 876      -                        /* This did not go through the above PORTMAP/TCP code */
 877      -                        if ((handle = __rpc_setconf("datagram_v")) != NULL) {
 878      -                                while ((nconf_clts = __rpc_getconf(handle))
 879      -                                    != NULL) {
 880      -                                        if (strcmp(nconf_clts->nc_protofmly,
 881      -                                            nconf->nc_protofmly) != 0) {
 882      -                                                continue;
 883      -                                        }
 884      -                                        client = _getclnthandle_timed(host,
 885      -                                                nconf_clts, &parms.r_addr,
 886      -                                                tp);
 887      -                                        break;
 888      -                                }
 889      -                                __rpc_endconf(handle);
      771 +                while ((nconf_clts = __rpc_getconf(handle))
      772 +                    != NULL) {
      773 +                        if (strcmp(nconf_clts->nc_protofmly,
      774 +                            nconf->nc_protofmly) != 0) {
      775 +                                continue;
 890  776                          }
 891      -                        if (client == NULL)
 892      -                                goto regular_rpcbind;   /* Go the regular way */
 893      -                } else {
 894      -                        /* This is a UDP PORTMAP handle.  Change to version 4 */
 895      -                        vers = RPCBVERS4;
 896      -                        CLNT_CONTROL(client, CLSET_VERS, (char *)&vers);
      777 +                        client = _getclnthandle_timed(host,
      778 +                            nconf_clts, &parms.r_addr,
      779 +                            tp);
      780 +                        break;
 897  781                  }
      782 +                __rpc_endconf(handle);
      783 +        }
      784 +        if (client != NULL) {
      785 +
      786 +                if (nconf->nc_semantics == NC_TPI_COTS_ORD ||
      787 +                    nconf->nc_semantics == NC_TPI_COTS)
      788 +                        tmp_client = TRUE;
      789 +
      790 +                /* Set rpcbind version 4 */
      791 +                vers = RPCBVERS4;
      792 +                CLNT_CONTROL(client, CLSET_VERS, (char *)&vers);
      793 +
 898  794                  /*
 899  795                   * We also send the remote system the address we used to
 900  796                   * contact it in case it can help it connect back with us
 901  797                   */
 902  798                  if (parms.r_addr == NULL) {
 903  799                          parms.r_addr = strdup(""); /* for XDRing */
 904  800                          if (parms.r_addr == NULL) {
 905  801                                  syslog(LOG_ERR, "__rpcb_findaddr_timed: "
 906      -                                        "strdup failed.");
      802 +                                    "strdup failed.");
 907  803                                  rpc_createerr.cf_stat = RPC_SYSTEMERROR;
 908  804                                  address = NULL;
 909  805                                  goto error;
 910  806                          }
 911  807                  }
 912  808  
 913      -                CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rpcbrmttime);
      809 +                CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT,
      810 +                    (char *)&rpcbrmttime);
 914  811  
 915  812                  clnt_st = CLNT_CALL(client, RPCBPROC_GETADDRLIST,
 916      -                                    (xdrproc_t)xdr_rpcb, (char *)&parms,
 917      -                                    (xdrproc_t)xdr_rpcb_entry_list_ptr,
 918      -                                    (char *)&relp, *tp);
 919      -                if (clnt_st == RPC_SUCCESS) {
      813 +                    (xdrproc_t)xdr_rpcb, (char *)&parms,
      814 +                    (xdrproc_t)xdr_rpcb_entry_list_ptr,
      815 +                    (char *)&relp, *tp);
      816 +                switch (clnt_st) {
      817 +                case RPC_SUCCESS:
 920  818                          if (address = got_entry(relp, nconf)) {
 921  819                                  xdr_free((xdrproc_t)xdr_rpcb_entry_list_ptr,
 922      -                                        (char *)&relp);
      820 +                                    (char *)&relp);
 923  821                                  goto done;
 924  822                          }
 925  823                          /* Entry not found for this transport */
 926  824                          xdr_free((xdrproc_t)xdr_rpcb_entry_list_ptr,
 927      -                                    (char *)&relp);
      825 +                            (char *)&relp);
 928  826                          /*
 929  827                           * XXX: should have perhaps returned with error but
 930  828                           * since the remote machine might not always be able
 931  829                           * to send the address on all transports, we try the
 932      -                         * regular way with regular_rpcbind
      830 +                         * regular way with version 3, then 2
 933  831                           */
 934      -                        goto regular_rpcbind;
 935      -                } else if ((clnt_st == RPC_PROGVERSMISMATCH) ||
 936      -                            (clnt_st == RPC_PROGUNAVAIL)) {
 937      -                        start_vers = RPCBVERS;  /* Try version 3 now */
 938      -                        goto regular_rpcbind; /* Try different versions */
 939      -                } else {
      832 +                        /* Try the next version */
      833 +                        break;
      834 +                case RPC_PROGVERSMISMATCH:
      835 +                case RPC_PROGUNAVAIL:
      836 +                        /* Try the next version */
      837 +                        break;
      838 +                default:
 940  839                          rpc_createerr.cf_stat = RPC_PMAPFAILURE;
 941  840                          clnt_geterr(client, &rpc_createerr.cf_error);
 942  841                          goto error;
      842 +                        break;
 943  843                  }
 944      -        }
      844 +        } /* End of version 4 */
 945  845  
 946      -regular_rpcbind:
      846 +        /*
      847 +         * Try version 3
      848 +         */
 947  849  
 948  850          /* Now the same transport is to be used to get the address */
 949  851          if (client && ((nconf->nc_semantics == NC_TPI_COTS_ORD) ||
 950  852              (nconf->nc_semantics == NC_TPI_COTS))) {
 951  853                  /* A CLTS type of client - destroy it */
 952  854                  CLNT_DESTROY(client);
 953  855                  client = NULL;
 954  856                  free(parms.r_addr);
 955  857                  parms.r_addr = NULL;
 956  858          }
 957  859  
 958  860          if (client == NULL) {
 959  861                  client = _getclnthandle_timed(host, nconf, &parms.r_addr, tp);
 960      -                if (client == NULL) {
 961      -                        address = NULL;
 962      -                        goto error;
 963      -                }
 964  862          }
 965      -        if (parms.r_addr == NULL) {
 966      -                parms.r_addr = strdup("");      /* for XDRing */
      863 +        if (client != NULL) {
      864 +                tmp_client = FALSE;
 967  865                  if (parms.r_addr == NULL) {
 968      -                        syslog(LOG_ERR, "__rpcb_findaddr_timed: "
 969      -                                "strdup failed.");
 970      -                        address = NULL;
 971      -                        rpc_createerr.cf_stat = RPC_SYSTEMERROR;
 972      -                        goto error;
      866 +                        parms.r_addr = strdup("");      /* for XDRing */
      867 +                        if (parms.r_addr == NULL) {
      868 +                                syslog(LOG_ERR, "__rpcb_findaddr_timed: "
      869 +                                    "strdup failed.");
      870 +                                address = NULL;
      871 +                                rpc_createerr.cf_stat = RPC_SYSTEMERROR;
      872 +                                goto error;
      873 +                        }
 973  874                  }
 974      -        }
 975  875  
 976      -        /* First try from start_vers and then version 3 (RPCBVERS) */
 977      -
 978      -        CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rpcbrmttime);
 979      -        for (vers = start_vers;  vers >= RPCBVERS; vers--) {
 980      -                /* Set the version */
      876 +                CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT,
      877 +                    (char *)&rpcbrmttime);
      878 +                vers = RPCBVERS; /* Set the version */
 981  879                  CLNT_CONTROL(client, CLSET_VERS, (char *)&vers);
 982  880                  clnt_st = CLNT_CALL(client, RPCBPROC_GETADDR,
 983      -                                    (xdrproc_t)xdr_rpcb, (char *)&parms,
 984      -                                    (xdrproc_t)xdr_wrapstring,
 985      -                                    (char *)&ua, *tp);
 986      -                if (clnt_st == RPC_SUCCESS) {
 987      -                        if ((ua == NULL) || (ua[0] == NULL)) {
 988      -                                if (ua != NULL)
 989      -                                        xdr_free(xdr_wrapstring, (char *)&ua);
 990      -
 991      -                                /* address unknown */
 992      -                                rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
 993      -                                goto error;
      881 +                    (xdrproc_t)xdr_rpcb, (char *)&parms,
      882 +                    (xdrproc_t)xdr_wrapstring,
      883 +                    (char *)&ua, *tp);
      884 +                switch (clnt_st) {
      885 +                case RPC_SUCCESS:
      886 +                        if ((ua != NULL) && (ua[0] != '\0')) {
      887 +                                address = uaddr2taddr(nconf, ua);
      888 +#ifdef ND_DEBUG
      889 +                                fprintf(stderr, "\tRemote address is [%s]\n",
      890 +                                    ua);
      891 +#endif
      892 +                                xdr_free((xdrproc_t)xdr_wrapstring,
      893 +                                    (char *)&ua);
      894 +                        } else if (ua != NULL) {
      895 +                                xdr_free(xdr_wrapstring, (char *)&ua);
 994  896                          }
 995      -                        address = uaddr2taddr(nconf, ua);
      897 +
      898 +                        if (ua != NULL && address != NULL) {
      899 +                                goto done;
      900 +                        } else if (address == NULL) {
      901 +                                /* We don't know about your universal addr */
 996  902  #ifdef ND_DEBUG
 997      -                        fprintf(stderr, "\tRemote address is [%s]\n", ua);
 998      -                        if (!address)
 999  903                                  fprintf(stderr,
1000      -                                        "\tCouldn't resolve remote address!\n");
      904 +                                    "\tCouldn't resolve remote address!\n");
1001  905  #endif
1002      -                        xdr_free((xdrproc_t)xdr_wrapstring, (char *)&ua);
1003      -
1004      -                        if (!address) {
1005      -                                /* We don't know about your universal address */
1006      -                                rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE;
      906 +                                rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
1007  907                                  goto error;
1008  908                          }
1009      -                        goto done;
      909 +                        /* Try the next version */
      910 +                        break;
      911 +                case RPC_PROGVERSMISMATCH:
      912 +                        clnt_geterr(client, &rpc_createerr.cf_error);
      913 +                        if (rpc_createerr.cf_error.re_vers.low > RPCBVERS4)
      914 +                                goto error;  /* a new version, can't handle */
      915 +                        /* Try the next version */
      916 +                        break;
      917 +                case RPC_PROGUNAVAIL:
      918 +                        /* Try the next version */
      919 +                        break;
      920 +                default:
      921 +                        clnt_geterr(client, &rpc_createerr.cf_error);
      922 +                        rpc_createerr.cf_stat = RPC_PMAPFAILURE;
      923 +                        goto error;
      924 +                        break;
1010  925                  }
1011      -                if (clnt_st == RPC_PROGVERSMISMATCH) {
1012      -                        struct rpc_err rpcerr;
      926 +        } else {
      927 +                address = NULL;
      928 +        } /* End of version 3 */
1013  929  
1014      -                        clnt_geterr(client, &rpcerr);
1015      -                        if (rpcerr.re_vers.low > RPCBVERS4)
1016      -                                goto error;  /* a new version, can't handle */
1017      -                } else if (clnt_st != RPC_PROGUNAVAIL) {
1018      -                        /* Cant handle this error */
      930 +        /*
      931 +         * Try version 2
      932 +         */
      933 +
      934 +#ifdef PORTMAP
      935 +        /* Try version 2 for TCP or UDP */
      936 +        if (strcmp(nconf->nc_protofmly, NC_INET) == 0) {
      937 +                ushort_t port = 0;
      938 +                struct netbuf remote;
      939 +                uint_t pmapvers = 2;
      940 +                struct pmap pmapparms;
      941 +
      942 +                /*
      943 +                 * Try UDP only - there are some portmappers out
      944 +                 * there that use UDP only.
      945 +                 */
      946 +                if (strcmp(nconf->nc_proto, NC_TCP) == 0) {
      947 +                        struct netconfig *newnconf;
      948 +
      949 +                        if (client) {
      950 +                                CLNT_DESTROY(client);
      951 +                                client = NULL;
      952 +                                free(parms.r_addr);
      953 +                                parms.r_addr = NULL;
      954 +                        }
      955 +                        if ((handle = __rpc_setconf("udp")) == NULL) {
      956 +                                rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
      957 +                                return (NULL);
      958 +                        }
      959 +
      960 +                        /*
      961 +                         * The following to reinforce that you can
      962 +                         * only request for remote address through
      963 +                         * the same transport you are requesting.
      964 +                         * ie. requesting unversial address
      965 +                         * of IPv4 has to be carried through IPv4.
      966 +                         * Can't use IPv6 to send out the request.
      967 +                         * The mergeaddr in rpcbind can't handle
      968 +                         * this.
      969 +                         */
      970 +                        for (;;) {
      971 +                                if ((newnconf = __rpc_getconf(handle))
      972 +                                    == NULL) {
      973 +                                        __rpc_endconf(handle);
      974 +                                        rpc_createerr.cf_stat =
      975 +                                            RPC_UNKNOWNPROTO;
      976 +                                        return (NULL);
      977 +                                }
      978 +                                /*
      979 +                                 * here check the protocol family to
      980 +                                 * be consistent with the request one
      981 +                                 */
      982 +                                if (strcmp(newnconf->nc_protofmly,
      983 +                                    nconf->nc_protofmly) == NULL)
      984 +                                        break;
      985 +                        }
      986 +
      987 +                        client = _getclnthandle_timed(host, newnconf,
      988 +                            &parms.r_addr, tp);
      989 +                        __rpc_endconf(handle);
      990 +                }
      991 +                if (client == NULL)
      992 +                        return (NULL);
      993 +
      994 +                if (strcmp(nconf->nc_proto, NC_TCP) == 0)
      995 +                        tmp_client = TRUE;
      996 +
      997 +                /*
      998 +                 * Set version and retry timeout.
      999 +                 */
     1000 +                CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rpcbrmttime);
     1001 +                CLNT_CONTROL(client, CLSET_VERS, (char *)&pmapvers);
     1002 +
     1003 +                pmapparms.pm_prog = program;
     1004 +                pmapparms.pm_vers = version;
     1005 +                pmapparms.pm_prot = strcmp(nconf->nc_proto, NC_TCP) ?
     1006 +                    IPPROTO_UDP : IPPROTO_TCP;
     1007 +                pmapparms.pm_port = 0;  /* not needed */
     1008 +                clnt_st = CLNT_CALL(client, PMAPPROC_GETPORT,
     1009 +                    (xdrproc_t)xdr_pmap, (caddr_t)&pmapparms,
     1010 +                    (xdrproc_t)xdr_u_short, (caddr_t)&port,
     1011 +                    *tp);
     1012 +                if (clnt_st != RPC_SUCCESS) {
     1013 +                        rpc_createerr.cf_stat = RPC_PMAPFAILURE;
     1014 +                        clnt_geterr(client, &rpc_createerr.cf_error);
1019 1015                          goto error;
     1016 +                } else if (port == 0) {
     1017 +                        address = NULL;
     1018 +                        rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
     1019 +                        goto error;
1020 1020                  }
     1021 +                port = htons(port);
     1022 +                CLNT_CONTROL(client, CLGET_SVC_ADDR, (char *)&remote);
     1023 +                if (((address = malloc(sizeof (struct netbuf))) == NULL) ||
     1024 +                    ((address->buf = malloc(remote.len)) == NULL)) {
     1025 +                        rpc_createerr.cf_stat = RPC_SYSTEMERROR;
     1026 +                        clnt_geterr(client, &rpc_createerr.cf_error);
     1027 +                        if (address) {
     1028 +                                free(address);
     1029 +                                address = NULL;
     1030 +                        }
     1031 +                        goto error;
     1032 +                }
     1033 +                (void) memcpy(address->buf, remote.buf, remote.len);
     1034 +                (void) memcpy(&address->buf[sizeof (short)], &port,
     1035 +                    sizeof (short));
     1036 +                address->len = address->maxlen = remote.len;
     1037 +                goto done;
1021 1038          }
     1039 +#endif
1022 1040  
1023      -        if ((address == NULL) || (address->len == 0)) {
1024      -                rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
1025      -                clnt_geterr(client, &rpc_createerr.cf_error);
1026      -        }
1027      -
1028 1041  error:
     1042 +        /* Return NULL address and NULL client */
1029 1043          if (client) {
1030 1044                  CLNT_DESTROY(client);
1031 1045                  client = NULL;
1032 1046          }
     1047 +
1033 1048  done:
1034      -        if (nconf->nc_semantics != NC_TPI_CLTS) {
1035      -                /* This client is the connectionless one */
     1049 +        /* Return an address and optional client */
     1050 +        if (tmp_client) {
     1051 +                /* This client is the temporary one */
1036 1052                  if (client) {
1037 1053                          CLNT_DESTROY(client);
1038 1054                          client = NULL;
1039 1055                  }
1040 1056          }
1041 1057          if (clpp) {
1042 1058                  *clpp = client;
1043 1059          } else if (client) {
1044 1060                  CLNT_DESTROY(client);
1045 1061          }
↓ open down ↓ 42 lines elided ↑ open up ↑
1088 1104   */
1089 1105  rpcblist *
1090 1106  rpcb_getmaps(const struct netconfig *nconf, const char *host)
1091 1107  {
1092 1108          rpcblist_ptr head = NULL;
1093 1109          CLIENT *client;
1094 1110          enum clnt_stat clnt_st;
1095 1111          int vers = 0;
1096 1112  
1097 1113          client = getclnthandle((char *)host,
1098      -                        (struct netconfig *)nconf, NULL);
     1114 +            (struct netconfig *)nconf, NULL);
1099 1115          if (client == NULL)
1100 1116                  return (NULL);
1101 1117  
1102 1118          clnt_st = CLNT_CALL(client, RPCBPROC_DUMP,
1103      -                        (xdrproc_t)xdr_void, NULL,
1104      -                        (xdrproc_t)xdr_rpcblist_ptr,
1105      -                        (char *)&head, tottimeout);
     1119 +            (xdrproc_t)xdr_void, NULL,
     1120 +            (xdrproc_t)xdr_rpcblist_ptr,
     1121 +            (char *)&head, tottimeout);
1106 1122          if (clnt_st == RPC_SUCCESS)
1107 1123                  goto done;
1108 1124  
1109 1125          if ((clnt_st != RPC_PROGVERSMISMATCH) &&
1110      -                    (clnt_st != RPC_PROGUNAVAIL)) {
     1126 +            (clnt_st != RPC_PROGUNAVAIL)) {
1111 1127                  rpc_createerr.cf_stat = RPC_RPCBFAILURE;
1112 1128                  clnt_geterr(client, &rpc_createerr.cf_error);
1113 1129                  goto done;
1114 1130          }
1115 1131  
1116 1132          /* fall back to earlier version */
1117 1133          CLNT_CONTROL(client, CLGET_VERS, (char *)&vers);
1118 1134          if (vers == RPCBVERS4) {
1119 1135                  vers = RPCBVERS;
1120 1136                  CLNT_CONTROL(client, CLSET_VERS, (char *)&vers);
1121 1137                  if (CLNT_CALL(client, RPCBPROC_DUMP,
1122      -                        (xdrproc_t)xdr_void,
1123      -                        NULL, (xdrproc_t)xdr_rpcblist_ptr,
1124      -                        (char *)&head, tottimeout) == RPC_SUCCESS)
     1138 +                    (xdrproc_t)xdr_void,
     1139 +                    NULL, (xdrproc_t)xdr_rpcblist_ptr,
     1140 +                    (char *)&head, tottimeout) == RPC_SUCCESS)
1125 1141                                  goto done;
1126 1142          }
1127 1143          rpc_createerr.cf_stat = RPC_RPCBFAILURE;
1128 1144          clnt_geterr(client, &rpc_createerr.cf_error);
1129 1145  
1130 1146  done:
1131 1147          CLNT_DESTROY(client);
1132 1148          return (head);
1133 1149  }
1134 1150  
↓ open down ↓ 25 lines elided ↑ open up ↑
1160 1176          a.proc = proc;
1161 1177          a.args.args_val = argsp;
1162 1178          a.xdr_args = xdrargs;
1163 1179          r.addr = NULL;
1164 1180          r.results.results_val = resp;
1165 1181          r.xdr_res = xdrres;
1166 1182  
1167 1183          for (rpcb_vers = RPCBVERS4; rpcb_vers >= RPCBVERS; rpcb_vers--) {
1168 1184                  CLNT_CONTROL(client, CLSET_VERS, (char *)&rpcb_vers);
1169 1185                  stat = CLNT_CALL(client, RPCBPROC_CALLIT,
1170      -                        (xdrproc_t)xdr_rpcb_rmtcallargs, (char *)&a,
1171      -                        (xdrproc_t)xdr_rpcb_rmtcallres, (char *)&r, tout);
     1186 +                    (xdrproc_t)xdr_rpcb_rmtcallargs, (char *)&a,
     1187 +                    (xdrproc_t)xdr_rpcb_rmtcallres, (char *)&r, tout);
1172 1188                  if ((stat == RPC_SUCCESS) && (addr_ptr != NULL)) {
1173 1189                          struct netbuf *na;
1174 1190  
1175 1191                          na = uaddr2taddr((struct netconfig *)nconf, r.addr);
1176 1192                          if (!na) {
1177 1193                                  stat = RPC_N2AXLATEFAILURE;
1178 1194                                  ((struct netbuf *)addr_ptr)->len = 0;
1179 1195                                  goto error;
1180 1196                          }
1181 1197                          if (na->len > addr_ptr->maxlen) {
↓ open down ↓ 2 lines elided ↑ open up ↑
1184 1200                                  netdir_free((char *)na, ND_ADDR);
1185 1201                                  ((struct netbuf *)addr_ptr)->len = 0;
1186 1202                                  goto error;
1187 1203                          }
1188 1204                          (void) memcpy(addr_ptr->buf, na->buf, (int)na->len);
1189 1205                          ((struct netbuf *)addr_ptr)->len = na->len;
1190 1206                          netdir_free((char *)na, ND_ADDR);
1191 1207                          break;
1192 1208                  }
1193 1209                  if ((stat != RPC_PROGVERSMISMATCH) &&
1194      -                            (stat != RPC_PROGUNAVAIL))
     1210 +                    (stat != RPC_PROGUNAVAIL))
1195 1211                          goto error;
1196 1212          }
1197 1213  error:
1198 1214          CLNT_DESTROY(client);
1199 1215          if (r.addr)
1200 1216                  xdr_free((xdrproc_t)xdr_wrapstring, (char *)&r.addr);
1201 1217          return (stat);
1202 1218  }
1203 1219  
1204 1220  /*
↓ open down ↓ 27 lines elided ↑ open up ↑
1232 1248                  }
1233 1249                  client = getclnthandle((char *)host, nconf, NULL);
1234 1250                  if (client)
1235 1251                          break;
1236 1252          }
1237 1253          __rpc_endconf(handle);
1238 1254          if (client == NULL)
1239 1255                  return (FALSE);
1240 1256  
1241 1257          st = CLNT_CALL(client, RPCBPROC_GETTIME,
1242      -                (xdrproc_t)xdr_void, NULL,
1243      -                (xdrproc_t)xdr_time_t, (char *)timep, tottimeout);
     1258 +            (xdrproc_t)xdr_void, NULL,
     1259 +            (xdrproc_t)xdr_time_t, (char *)timep, tottimeout);
1244 1260  
1245 1261          if ((st == RPC_PROGVERSMISMATCH) || (st == RPC_PROGUNAVAIL)) {
1246 1262                  CLNT_CONTROL(client, CLGET_VERS, (char *)&vers);
1247 1263                  if (vers == RPCBVERS4) {
1248 1264                          /* fall back to earlier version */
1249 1265                          vers = RPCBVERS;
1250 1266                          CLNT_CONTROL(client, CLSET_VERS, (char *)&vers);
1251 1267                          st = CLNT_CALL(client, RPCBPROC_GETTIME,
1252      -                                (xdrproc_t)xdr_void, NULL,
1253      -                                (xdrproc_t)xdr_time_t, (char *)timep,
1254      -                                tottimeout);
     1268 +                            (xdrproc_t)xdr_void, NULL,
     1269 +                            (xdrproc_t)xdr_time_t, (char *)timep,
     1270 +                            tottimeout);
1255 1271                  }
1256 1272          }
1257 1273          CLNT_DESTROY(client);
1258 1274          return (st == RPC_SUCCESS? TRUE : FALSE);
1259 1275  }
1260 1276  
1261 1277  /*
1262 1278   * Converts taddr to universal address.  This routine should never
1263 1279   * really be called because local n2a libraries are always provided.
1264 1280   */
↓ open down ↓ 10 lines elided ↑ open up ↑
1275 1291          }
1276 1292          if (taddr == NULL) {
1277 1293                  rpc_createerr.cf_stat = RPC_UNKNOWNADDR;
1278 1294                  return (NULL);
1279 1295          }
1280 1296          client = local_rpcb();
1281 1297          if (!client)
1282 1298                  return (NULL);
1283 1299  
1284 1300          CLNT_CALL(client, RPCBPROC_TADDR2UADDR, (xdrproc_t)xdr_netbuf,
1285      -                (char *)taddr, (xdrproc_t)xdr_wrapstring, (char *)&uaddr,
1286      -                tottimeout);
     1301 +            (char *)taddr, (xdrproc_t)xdr_wrapstring, (char *)&uaddr,
     1302 +            tottimeout);
1287 1303          CLNT_DESTROY(client);
1288 1304          return (uaddr);
1289 1305  }
1290 1306  
1291 1307  /*
1292 1308   * Converts universal address to netbuf.  This routine should never
1293 1309   * really be called because local n2a libraries are always provided.
1294 1310   */
1295 1311  struct netbuf *
1296 1312  rpcb_uaddr2taddr(struct netconfig *nconf, char *uaddr)
↓ open down ↓ 14 lines elided ↑ open up ↑
1311 1327          if (!client)
1312 1328                  return (NULL);
1313 1329  
1314 1330          taddr = calloc(1, sizeof (struct netbuf));
1315 1331          if (taddr == NULL) {
1316 1332                  CLNT_DESTROY(client);
1317 1333                  return (NULL);
1318 1334          }
1319 1335  
1320 1336          if (CLNT_CALL(client, RPCBPROC_UADDR2TADDR, (xdrproc_t)xdr_wrapstring,
1321      -                (char *)&uaddr, (xdrproc_t)xdr_netbuf, (char *)taddr,
1322      -                tottimeout) != RPC_SUCCESS) {
     1337 +            (char *)&uaddr, (xdrproc_t)xdr_netbuf, (char *)taddr,
     1338 +            tottimeout) != RPC_SUCCESS) {
1323 1339                  free(taddr);
1324 1340                  taddr = NULL;
1325 1341          }
1326 1342          CLNT_DESTROY(client);
1327 1343          return (taddr);
1328 1344  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX