home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / security / portmap_3.shar.Z / portmap_3.shar / portmap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-20  |  15.6 KB  |  624 lines

  1. /*-
  2.  * Copyright (c) 1990 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  */
  33.  
  34. #ifndef lint
  35. char copyright[] =
  36. "@(#) Copyright (c) 1990 The Regents of the University of California.\n\
  37.  All rights reserved.\n";
  38. #endif /* not lint */
  39.  
  40. #ifndef lint
  41. static char sccsid[] = "@(#)portmap.c    5.4 (Berkeley) 4/19/91";
  42. #endif /* not lint */
  43.  
  44. /*
  45. @(#)portmap.c    2.3 88/08/11 4.0 RPCSRC
  46. static char sccsid[] = "@(#)portmap.c 1.32 87/08/06 Copyr 1984 Sun Micro";
  47. */
  48.  
  49. /*
  50.  * portmap.c, Implements the program,version to port number mapping for
  51.  * rpc.
  52.  */
  53.  
  54. /*
  55.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  56.  * unrestricted use provided that this legend is included on all tape
  57.  * media and as a part of the software program in whole or part.  Users
  58.  * may copy or modify Sun RPC without charge, but are not authorized
  59.  * to license or distribute it to anyone else except as part of a product or
  60.  * program developed by the user.
  61.  * 
  62.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  63.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  64.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  65.  * 
  66.  * Sun RPC is provided with no support and without any obligation on the
  67.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  68.  * modification or enhancement.
  69.  * 
  70.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  71.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  72.  * OR ANY PART THEREOF.
  73.  * 
  74.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  75.  * or profits or other special, indirect and consequential damages, even if
  76.  * Sun has been advised of the possibility of such damages.
  77.  * 
  78.  * Sun Microsystems, Inc.
  79.  * 2550 Garcia Avenue
  80.  * Mountain View, California  94043
  81.  */
  82.  
  83. #include <rpc/rpc.h>
  84. #include <rpc/pmap_prot.h>
  85. #include <stdio.h>
  86. #include <syslog.h>
  87. #include <netdb.h>
  88. #include <sys/socket.h>
  89. #include <sys/ioctl.h>
  90. #include <sys/wait.h>
  91. #include <sys/signal.h>
  92. #include <sys/time.h>
  93. #include <sys/resource.h>
  94. #ifdef SYSV40
  95. #include <netinet/in.h>
  96. #endif
  97.  
  98. extern char *strerror();
  99. extern char *malloc();
  100.  
  101. #ifndef LOG_PERROR
  102. #define LOG_PERROR 0
  103. #endif
  104.  
  105. #ifndef LOG_DAEMON
  106. #define LOG_DAEMON 0
  107. #endif
  108.  
  109. #ifndef svc_getcaller        /* SYSV4 */
  110. #  define svc_getcaller svc_getrpccaller
  111. #endif
  112.  
  113. void reg_service();
  114. void reap();
  115. static void callit();
  116. struct pmaplist *pmaplist;
  117. int debugging = 0;
  118. extern int errno;
  119.  
  120. #include "pmap_check.h"
  121.  
  122. main(argc, argv)
  123.     int argc;
  124.     char **argv;
  125. {
  126.     SVCXPRT *xprt;
  127.     int sock, c;
  128.     struct sockaddr_in addr;
  129.     int len = sizeof(struct sockaddr_in);
  130.     register struct pmaplist *pml;
  131.  
  132.     while ((c = getopt(argc, argv, "dv")) != EOF) {
  133.         switch (c) {
  134.  
  135.         case 'd':
  136.             debugging = 1;
  137.             break;
  138.  
  139.         case 'v':
  140.             verboselog = 1;
  141.             break;
  142.  
  143.         default:
  144.             (void) fprintf(stderr, "usage: %s [-dv]\n", argv[0]);
  145.             (void) fprintf(stderr, "-d: debugging mode\n");
  146.             (void) fprintf(stderr, "-v: verbose logging\n");
  147.             exit(1);
  148.         }
  149.     }
  150.  
  151.     if (!debugging && daemon(0, 0)) {
  152.         (void) fprintf(stderr, "portmap: fork: %s", strerror(errno));
  153.         exit(1);
  154.     }
  155.  
  156. #ifdef LOG_MAIL
  157.     openlog("portmap", debugging ? LOG_PID | LOG_PERROR : LOG_PID,
  158.         FACILITY);
  159. #else
  160.     openlog("portmap", debugging ? LOG_PID | LOG_PERROR : LOG_PID);
  161. #endif
  162.  
  163.     if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
  164.         syslog(LOG_ERR, "cannot create udp socket: %m");
  165.         exit(1);
  166.     }
  167.  
  168.     addr.sin_addr.s_addr = 0;
  169.     addr.sin_family = AF_INET;
  170.     addr.sin_port = htons(PMAPPORT);
  171.     if (bind(sock, (struct sockaddr *)&addr, len) != 0) {
  172.         syslog(LOG_ERR, "cannot bind udp: %m");
  173.         exit(1);
  174.     }
  175.  
  176.     if ((xprt = svcudp_create(sock)) == (SVCXPRT *)NULL) {
  177.         syslog(LOG_ERR, "couldn't do udp_create");
  178.         exit(1);
  179.     }
  180.     /* make an entry for ourself */
  181.     pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist));
  182.     pml->pml_next = 0;
  183.     pml->pml_map.pm_prog = PMAPPROG;
  184.     pml->pml_map.pm_vers = PMAPVERS;
  185.     pml->pml_map.pm_prot = IPPROTO_UDP;
  186.     pml->pml_map.pm_port = PMAPPORT;
  187.     pmaplist = pml;
  188.  
  189.     if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
  190.         syslog(LOG_ERR, "cannot create tcp socket: %m");
  191.         exit(1);
  192.     }
  193.     if (bind(sock, (struct sockaddr *)&addr, len) != 0) {
  194.         syslog(LOG_ERR, "cannot bind udp: %m");
  195.         exit(1);
  196.     }
  197.     if ((xprt = svctcp_create(sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE))
  198.         == (SVCXPRT *)NULL) {
  199.         syslog(LOG_ERR, "couldn't do tcp_create");
  200.         exit(1);
  201.     }
  202.     /* make an entry for ourself */
  203.     pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist));
  204.     pml->pml_map.pm_prog = PMAPPROG;
  205.     pml->pml_map.pm_vers = PMAPVERS;
  206.     pml->pml_map.pm_prot = IPPROTO_TCP;
  207.     pml->pml_map.pm_port = PMAPPORT;
  208.     pml->pml_next = pmaplist;
  209.     pmaplist = pml;
  210.  
  211.     (void)svc_register(xprt, PMAPPROG, PMAPVERS, reg_service, FALSE);
  212.  
  213.     /* additional initializations */
  214.     check_startup();
  215. #ifdef IGNORE_SIGCHLD            /* Lionel Cons <cons@dxcern.cern.ch> */
  216.     (void)signal(SIGCHLD, SIG_IGN);
  217. #else
  218.     (void)signal(SIGCHLD, reap);
  219. #endif
  220.     svc_run();
  221.     syslog(LOG_ERR, "run_svc returned unexpectedly");
  222.     abort();
  223. }
  224.  
  225. #ifndef lint
  226. /* need to override perror calls in rpc library */
  227. void
  228. perror(what)
  229.     const char *what;
  230. {
  231.  
  232.     syslog(LOG_ERR, "%s: %m", what);
  233. }
  234. #endif
  235.  
  236. static struct pmaplist *
  237. find_service(prog, vers, prot)
  238.     u_long prog, vers, prot;
  239. {
  240.     register struct pmaplist *hit = NULL;
  241.     register struct pmaplist *pml;
  242.  
  243.     for (pml = pmaplist; pml != NULL; pml = pml->pml_next) {
  244.         if ((pml->pml_map.pm_prog != prog) ||
  245.             (pml->pml_map.pm_prot != prot))
  246.             continue;
  247.         hit = pml;
  248.         if (pml->pml_map.pm_vers == vers)
  249.             break;
  250.     }
  251.     return (hit);
  252. }
  253.  
  254. /* 
  255.  * 1 OK, 0 not
  256.  */
  257. void
  258. reg_service(rqstp, xprt)
  259.     struct svc_req *rqstp;
  260.     SVCXPRT *xprt;
  261. {
  262.     struct pmap reg;
  263.     struct pmaplist *pml, *prevpml, *fnd;
  264.     int ans, port;
  265.     caddr_t t;
  266.     
  267.     /*
  268.      * Later wrappers change the logging severity on the fly. Reset to
  269.      * defaults before handling the next request.
  270.      */
  271.     allow_severity = LOG_INFO;
  272.     deny_severity = LOG_WARNING;
  273.  
  274.     if (debugging)
  275.         (void) fprintf(stderr, "server: about do a switch\n");
  276.     switch (rqstp->rq_proc) {
  277.  
  278.     case PMAPPROC_NULL:
  279.         /*
  280.          * Null proc call
  281.          */
  282.         /* remote host authorization check */
  283.         check_default(svc_getcaller(xprt), rqstp->rq_proc, (u_long) 0);
  284.         if (!svc_sendreply(xprt, xdr_void, (caddr_t)0) && debugging) {
  285.             abort();
  286.         }
  287.         break;
  288.  
  289.     case PMAPPROC_SET:
  290.         /*
  291.          * Set a program,version to port mapping
  292.          */
  293.         if (!svc_getargs(xprt, xdr_pmap, ®))
  294.             svcerr_decode(xprt);
  295.         else {
  296.             /* reject non-local requests, protect priv. ports */
  297.             if (!check_setunset(svc_getcaller(xprt), 
  298.                 rqstp->rq_proc, reg.pm_prog, reg.pm_port)) {
  299.                 ans = 0;
  300.                 goto done;
  301.             } 
  302.             /*
  303.              * check to see if already used
  304.              * find_service returns a hit even if
  305.              * the versions don't match, so check for it
  306.              */
  307.             fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot);
  308.             if (fnd && fnd->pml_map.pm_vers == reg.pm_vers) {
  309.                 if (fnd->pml_map.pm_port == reg.pm_port) {
  310.                     ans = 1;
  311.                     goto done;
  312.                 }
  313.                 else {
  314.                     ans = 0;
  315.                     goto done;
  316.                 }
  317.             } else {
  318.                 /* 
  319.                  * add to END of list
  320.                  */
  321.                 pml = (struct pmaplist *)
  322.                     malloc((u_int)sizeof(struct pmaplist));
  323.                 pml->pml_map = reg;
  324.                 pml->pml_next = 0;
  325.                 if (pmaplist == 0) {
  326.                     pmaplist = pml;
  327.                 } else {
  328.                     for (fnd= pmaplist; fnd->pml_next != 0;
  329.                         fnd = fnd->pml_next);
  330.                     fnd->pml_next = pml;
  331.                 }
  332.                 ans = 1;
  333.             }
  334.         done:
  335.             if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&ans)) &&
  336.                 debugging) {
  337.                 (void) fprintf(stderr, "svc_sendreply\n");
  338.                 abort();
  339.             }
  340.         }
  341.         break;
  342.  
  343.     case PMAPPROC_UNSET:
  344.         /*
  345.          * Remove a program,version to port mapping.
  346.          */
  347.         if (!svc_getargs(xprt, xdr_pmap, ®))
  348.             svcerr_decode(xprt);
  349.         else {
  350.             ans = 0;
  351.             /* reject non-local requests */
  352.             if (!check_setunset(svc_getcaller(xprt), 
  353.                 rqstp->rq_proc, reg.pm_prog, (u_long) 0))
  354.                 goto done;
  355.             for (prevpml = NULL, pml = pmaplist; pml != NULL; ) {
  356.                 if ((pml->pml_map.pm_prog != reg.pm_prog) ||
  357.                     (pml->pml_map.pm_vers != reg.pm_vers)) {
  358.                     /* both pml & prevpml move forwards */
  359.                     prevpml = pml;
  360.                     pml = pml->pml_next;
  361.                     continue;
  362.                 }
  363.                 /* found it; pml moves forward, prevpml stays */
  364.                 /* privileged port check */
  365.                 if (!check_privileged_port(svc_getcaller(xprt), 
  366.                     rqstp->rq_proc, 
  367.                     reg.pm_prog, 
  368.                     pml->pml_map.pm_port)) {
  369.                     ans = 0;
  370.                     break;
  371.                 }
  372.                 ans = 1;
  373.                 t = (caddr_t)pml;
  374.                 pml = pml->pml_next;
  375.                 if (prevpml == NULL)
  376.                     pmaplist = pml;
  377.                 else
  378.                     prevpml->pml_next = pml;
  379.                 free(t);
  380.             }
  381.             if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&ans)) &&
  382.                 debugging) {
  383.                 (void) fprintf(stderr, "svc_sendreply\n");
  384.                 abort();
  385.             }
  386.         }
  387.         break;
  388.  
  389.     case PMAPPROC_GETPORT:
  390.         /*
  391.          * Lookup the mapping for a program,version and return its port
  392.          */
  393.         if (!svc_getargs(xprt, xdr_pmap, ®))
  394.             svcerr_decode(xprt);
  395.         else {
  396.             /* remote host authorization check */
  397.             if (!check_default(svc_getcaller(xprt), 
  398.                 rqstp->rq_proc, 
  399.                 reg.pm_prog)) {
  400.                 ans = 0;
  401.                 goto done;
  402.             }
  403.             fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot);
  404.             if (fnd)
  405.                 port = fnd->pml_map.pm_port;
  406.             else
  407.                 port = 0;
  408.             if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&port)) &&
  409.                 debugging) {
  410.                 (void) fprintf(stderr, "svc_sendreply\n");
  411.                 abort();
  412.             }
  413.         }
  414.         break;
  415.  
  416.     case PMAPPROC_DUMP:
  417.         /*
  418.          * Return the current set of mapped program,version
  419.          */
  420.         if (!svc_getargs(xprt, xdr_void, NULL))
  421.             svcerr_decode(xprt);
  422.         else {
  423.             /* remote host authorization check */
  424.             struct pmaplist *p;
  425.             if (!check_default(svc_getcaller(xprt), 
  426.                 rqstp->rq_proc, (u_long) 0)) {
  427.                 p = 0;    /* send empty list */
  428.             } else {
  429.                 p = pmaplist;
  430.             }
  431.             if ((!svc_sendreply(xprt, xdr_pmaplist,
  432.                 (caddr_t)&p)) && debugging) {
  433.                 (void) fprintf(stderr, "svc_sendreply\n");
  434.                 abort();
  435.             }
  436.         }
  437.         break;
  438.  
  439.     case PMAPPROC_CALLIT:
  440.         /*
  441.          * Calls a procedure on the local machine.  If the requested
  442.          * procedure is not registered this procedure does not return
  443.          * error information!!
  444.          * This procedure is only supported on rpc/udp and calls via 
  445.          * rpc/udp.  It passes null authentication parameters.
  446.          */
  447.         callit(rqstp, xprt);
  448.         break;
  449.  
  450.     default:
  451.         /* remote host authorization check */
  452.         check_default(svc_getcaller(xprt), rqstp->rq_proc, (u_long) 0);
  453.         svcerr_noproc(xprt);
  454.         break;
  455.     }
  456. }
  457.  
  458.  
  459. /*
  460.  * Stuff for the rmtcall service
  461.  */
  462. #define ARGSIZE 9000
  463.  
  464. struct encap_parms {
  465.     u_long arglen;
  466.     char *args;
  467. };
  468.  
  469. static bool_t
  470. xdr_encap_parms(xdrs, epp)
  471.     XDR *xdrs;
  472.     struct encap_parms *epp;
  473. {
  474.  
  475.     return (xdr_bytes(xdrs, &(epp->args), &(epp->arglen), ARGSIZE));
  476. }
  477.  
  478. struct rmtcallargs {
  479.     u_long    rmt_prog;
  480.     u_long    rmt_vers;
  481.     u_long    rmt_port;
  482.     u_long    rmt_proc;
  483.     struct encap_parms rmt_args;
  484. };
  485.  
  486. static bool_t
  487. xdr_rmtcall_args(xdrs, cap)
  488.     register XDR *xdrs;
  489.     register struct rmtcallargs *cap;
  490. {
  491.  
  492.     /* does not get a port number */
  493.     if (xdr_u_long(xdrs, &(cap->rmt_prog)) &&
  494.         xdr_u_long(xdrs, &(cap->rmt_vers)) &&
  495.         xdr_u_long(xdrs, &(cap->rmt_proc))) {
  496.         return (xdr_encap_parms(xdrs, &(cap->rmt_args)));
  497.     }
  498.     return (FALSE);
  499. }
  500.  
  501. static bool_t
  502. xdr_rmtcall_result(xdrs, cap)
  503.     register XDR *xdrs;
  504.     register struct rmtcallargs *cap;
  505. {
  506.     if (xdr_u_long(xdrs, &(cap->rmt_port)))
  507.         return (xdr_encap_parms(xdrs, &(cap->rmt_args)));
  508.     return (FALSE);
  509. }
  510.  
  511. /*
  512.  * only worries about the struct encap_parms part of struct rmtcallargs.
  513.  * The arglen must already be set!!
  514.  */
  515. static bool_t
  516. xdr_opaque_parms(xdrs, cap)
  517.     XDR *xdrs;
  518.     struct rmtcallargs *cap;
  519. {
  520.  
  521.     return (xdr_opaque(xdrs, cap->rmt_args.args, cap->rmt_args.arglen));
  522. }
  523.  
  524. /*
  525.  * This routine finds and sets the length of incoming opaque paraters
  526.  * and then calls xdr_opaque_parms.
  527.  */
  528. static bool_t
  529. xdr_len_opaque_parms(xdrs, cap)
  530.     register XDR *xdrs;
  531.     struct rmtcallargs *cap;
  532. {
  533.     register u_int beginpos, lowpos, highpos, currpos, pos;
  534.  
  535.     beginpos = lowpos = pos = xdr_getpos(xdrs);
  536.     highpos = lowpos + ARGSIZE;
  537.     while ((int)(highpos - lowpos) >= 0) {
  538.         currpos = (lowpos + highpos) / 2;
  539.         if (xdr_setpos(xdrs, currpos)) {
  540.             pos = currpos;
  541.             lowpos = currpos + 1;
  542.         } else {
  543.             highpos = currpos - 1;
  544.         }
  545.     }
  546.     xdr_setpos(xdrs, beginpos);
  547.     cap->rmt_args.arglen = pos - beginpos;
  548.     return (xdr_opaque_parms(xdrs, cap));
  549. }
  550.  
  551. /*
  552.  * Call a remote procedure service
  553.  * This procedure is very quiet when things go wrong.
  554.  * The proc is written to support broadcast rpc.  In the broadcast case,
  555.  * a machine should shut-up instead of complain, less the requestor be
  556.  * overrun with complaints at the expense of not hearing a valid reply ...
  557.  *
  558.  * This now forks so that the program & process that it calls can call 
  559.  * back to the portmapper.
  560.  */
  561. static void
  562. callit(rqstp, xprt)
  563.     struct svc_req *rqstp;
  564.     SVCXPRT *xprt;
  565. {
  566.     struct rmtcallargs a;
  567.     struct pmaplist *pml;
  568.     u_short port;
  569.     struct sockaddr_in me;
  570.     int pid, so = -1;
  571.     CLIENT *client;
  572.     struct authunix_parms *au = (struct authunix_parms *)rqstp->rq_clntcred;
  573.     struct timeval timeout;
  574.     char buf[ARGSIZE];
  575.  
  576.     timeout.tv_sec = 5;
  577.     timeout.tv_usec = 0;
  578.     a.rmt_args.args = buf;
  579.     if (!svc_getargs(xprt, xdr_rmtcall_args, &a))
  580.         return;
  581.     /* host and service access control */
  582.     if (!check_callit(svc_getcaller(xprt), 
  583.         rqstp->rq_proc, a.rmt_prog, a.rmt_proc))
  584.         return;
  585.     if ((pml = find_service(a.rmt_prog, a.rmt_vers,
  586.         (u_long)IPPROTO_UDP)) == NULL)
  587.         return;
  588.     /*
  589.      * fork a child to do the work.  Parent immediately returns.
  590.      * Child exits upon completion.
  591.      */
  592.     if ((pid = fork()) != 0) {
  593.         if (pid < 0)
  594.             syslog(LOG_ERR, "CALLIT (prog %lu): fork: %m",
  595.                 a.rmt_prog);
  596.         return;
  597.     }
  598.     port = pml->pml_map.pm_port;
  599.     get_myaddress(&me);
  600.     me.sin_port = htons(port);
  601.     client = clntudp_create(&me, a.rmt_prog, a.rmt_vers, timeout, &so);
  602.     if (client != (CLIENT *)NULL) {
  603.         if (rqstp->rq_cred.oa_flavor == AUTH_UNIX) {
  604.             client->cl_auth = authunix_create(au->aup_machname,
  605.                au->aup_uid, au->aup_gid, au->aup_len, au->aup_gids);
  606.         }
  607.         a.rmt_port = (u_long)port;
  608.         if (clnt_call(client, a.rmt_proc, xdr_opaque_parms, &a,
  609.             xdr_len_opaque_parms, &a, timeout) == RPC_SUCCESS) {
  610.             svc_sendreply(xprt, xdr_rmtcall_result, (caddr_t)&a);
  611.         }
  612.         AUTH_DESTROY(client->cl_auth);
  613.         clnt_destroy(client);
  614.     }
  615.     (void)close(so);
  616.     exit(0);
  617. }
  618.  
  619. void
  620. reap()
  621. {
  622.     while (wait3((int *)NULL, WNOHANG, (struct rusage *)NULL) > 0);
  623. }
  624.