xref: /minix3/tests/fs/nfs/nfsservice/rpcbind/pmap_svc.c (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc /*	$NetBSD: pmap_svc.c,v 1.2 2013/10/19 17:45:00 christos Exp $	*/
211be35a1SLionel Sambuc 
311be35a1SLionel Sambuc /*
411be35a1SLionel Sambuc  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
511be35a1SLionel Sambuc  * unrestricted use provided that this legend is included on all tape
611be35a1SLionel Sambuc  * media and as a part of the software program in whole or part.  Users
711be35a1SLionel Sambuc  * may copy or modify Sun RPC without charge, but are not authorized
811be35a1SLionel Sambuc  * to license or distribute it to anyone else except as part of a product or
911be35a1SLionel Sambuc  * program developed by the user.
1011be35a1SLionel Sambuc  *
1111be35a1SLionel Sambuc  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
1211be35a1SLionel Sambuc  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
1311be35a1SLionel Sambuc  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
1411be35a1SLionel Sambuc  *
1511be35a1SLionel Sambuc  * Sun RPC is provided with no support and without any obligation on the
1611be35a1SLionel Sambuc  * part of Sun Microsystems, Inc. to assist in its use, correction,
1711be35a1SLionel Sambuc  * modification or enhancement.
1811be35a1SLionel Sambuc  *
1911be35a1SLionel Sambuc  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
2011be35a1SLionel Sambuc  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
2111be35a1SLionel Sambuc  * OR ANY PART THEREOF.
2211be35a1SLionel Sambuc  *
2311be35a1SLionel Sambuc  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
2411be35a1SLionel Sambuc  * or profits or other special, indirect and consequential damages, even if
2511be35a1SLionel Sambuc  * Sun has been advised of the possibility of such damages.
2611be35a1SLionel Sambuc  *
2711be35a1SLionel Sambuc  * Sun Microsystems, Inc.
2811be35a1SLionel Sambuc  * 2550 Garcia Avenue
2911be35a1SLionel Sambuc  * Mountain View, California  94043
3011be35a1SLionel Sambuc  */
3111be35a1SLionel Sambuc /*
3211be35a1SLionel Sambuc  * Copyright (c) 1984 - 1991 by Sun Microsystems, Inc.
3311be35a1SLionel Sambuc  */
3411be35a1SLionel Sambuc 
3511be35a1SLionel Sambuc /* #ident	"@(#)pmap_svc.c	1.14	93/07/05 SMI" */
3611be35a1SLionel Sambuc 
3711be35a1SLionel Sambuc #if 0
3811be35a1SLionel Sambuc #ifndef lint
3911be35a1SLionel Sambuc static	char sccsid[] = "@(#)pmap_svc.c 1.23 89/04/05 Copyr 1984 Sun Micro";
4011be35a1SLionel Sambuc #endif
4111be35a1SLionel Sambuc #endif
4211be35a1SLionel Sambuc 
4311be35a1SLionel Sambuc /*
4411be35a1SLionel Sambuc  * pmap_svc.c
4511be35a1SLionel Sambuc  * The server procedure for the version 2 portmapper.
4611be35a1SLionel Sambuc  * All the portmapper related interface from the portmap side.
4711be35a1SLionel Sambuc  */
4811be35a1SLionel Sambuc 
4911be35a1SLionel Sambuc #ifdef PORTMAP
5011be35a1SLionel Sambuc #include <sys/types.h>
5111be35a1SLionel Sambuc #include <sys/socket.h>
5211be35a1SLionel Sambuc #include <stdio.h>
5311be35a1SLionel Sambuc #include <rpc/rpc.h>
5411be35a1SLionel Sambuc #include <rpc/pmap_prot.h>
5511be35a1SLionel Sambuc #include <rpc/rpcb_prot.h>
5611be35a1SLionel Sambuc #ifdef RPCBIND_DEBUG
5711be35a1SLionel Sambuc #include <stdlib.h>
5811be35a1SLionel Sambuc #endif
5911be35a1SLionel Sambuc #include "rpcbind.h"
6011be35a1SLionel Sambuc 
6111be35a1SLionel Sambuc static struct pmaplist *find_service_pmap(rpcprog_t, rpcvers_t, rpcprot_t);
6211be35a1SLionel Sambuc static bool_t pmapproc_change(struct svc_req *, SVCXPRT *, u_long);
6311be35a1SLionel Sambuc static bool_t pmapproc_getport(struct svc_req *, SVCXPRT *);
6411be35a1SLionel Sambuc static bool_t pmapproc_dump(struct svc_req *, SVCXPRT *);
6511be35a1SLionel Sambuc 
6611be35a1SLionel Sambuc /*
6711be35a1SLionel Sambuc  * Called for all the version 2 inquiries.
6811be35a1SLionel Sambuc  */
6911be35a1SLionel Sambuc void
pmap_service(struct svc_req * rqstp,SVCXPRT * xprt)7011be35a1SLionel Sambuc pmap_service(struct svc_req *rqstp, SVCXPRT *xprt)
7111be35a1SLionel Sambuc {
7211be35a1SLionel Sambuc 	rpcbs_procinfo(RPCBVERS_2_STAT, rqstp->rq_proc);
7311be35a1SLionel Sambuc 	switch (rqstp->rq_proc) {
7411be35a1SLionel Sambuc 	case PMAPPROC_NULL:
7511be35a1SLionel Sambuc 		/*
7611be35a1SLionel Sambuc 		 * Null proc call
7711be35a1SLionel Sambuc 		 */
7811be35a1SLionel Sambuc #ifdef RPCBIND_DEBUG
7911be35a1SLionel Sambuc 		if (debugging)
8011be35a1SLionel Sambuc 			fprintf(stderr, "PMAPPROC_NULL\n");
8111be35a1SLionel Sambuc #endif
8211be35a1SLionel Sambuc 		check_access(xprt, rqstp->rq_proc, NULL, PMAPVERS);
8311be35a1SLionel Sambuc 		if ((!svc_sendreply(xprt, (xdrproc_t) xdr_void, NULL)) &&
8411be35a1SLionel Sambuc 			debugging) {
8511be35a1SLionel Sambuc 			if (doabort) {
8611be35a1SLionel Sambuc 				rpcbind_abort();
8711be35a1SLionel Sambuc 			}
8811be35a1SLionel Sambuc 		}
8911be35a1SLionel Sambuc 		break;
9011be35a1SLionel Sambuc 
9111be35a1SLionel Sambuc 	case PMAPPROC_SET:
9211be35a1SLionel Sambuc 		/*
9311be35a1SLionel Sambuc 		 * Set a program, version to port mapping
9411be35a1SLionel Sambuc 		 */
9511be35a1SLionel Sambuc 		pmapproc_change(rqstp, xprt, rqstp->rq_proc);
9611be35a1SLionel Sambuc 		break;
9711be35a1SLionel Sambuc 
9811be35a1SLionel Sambuc 	case PMAPPROC_UNSET:
9911be35a1SLionel Sambuc 		/*
10011be35a1SLionel Sambuc 		 * Remove a program, version to port mapping.
10111be35a1SLionel Sambuc 		 */
10211be35a1SLionel Sambuc 		pmapproc_change(rqstp, xprt, rqstp->rq_proc);
10311be35a1SLionel Sambuc 		break;
10411be35a1SLionel Sambuc 
10511be35a1SLionel Sambuc 	case PMAPPROC_GETPORT:
10611be35a1SLionel Sambuc 		/*
10711be35a1SLionel Sambuc 		 * Lookup the mapping for a program, version and return its
10811be35a1SLionel Sambuc 		 * port number.
10911be35a1SLionel Sambuc 		 */
11011be35a1SLionel Sambuc 		pmapproc_getport(rqstp, xprt);
11111be35a1SLionel Sambuc 		break;
11211be35a1SLionel Sambuc 
11311be35a1SLionel Sambuc 	case PMAPPROC_DUMP:
11411be35a1SLionel Sambuc 		/*
11511be35a1SLionel Sambuc 		 * Return the current set of mapped program, version
11611be35a1SLionel Sambuc 		 */
11711be35a1SLionel Sambuc #ifdef RPCBIND_DEBUG
11811be35a1SLionel Sambuc 		if (debugging)
11911be35a1SLionel Sambuc 			fprintf(stderr, "PMAPPROC_DUMP\n");
12011be35a1SLionel Sambuc #endif
12111be35a1SLionel Sambuc 		pmapproc_dump(rqstp, xprt);
12211be35a1SLionel Sambuc 		break;
12311be35a1SLionel Sambuc 
12411be35a1SLionel Sambuc 	case PMAPPROC_CALLIT:
12511be35a1SLionel Sambuc 		/*
12611be35a1SLionel Sambuc 		 * Calls a procedure on the local machine. If the requested
12711be35a1SLionel Sambuc 		 * procedure is not registered this procedure does not return
12811be35a1SLionel Sambuc 		 * error information!!
12911be35a1SLionel Sambuc 		 * This procedure is only supported on rpc/udp and calls via
13011be35a1SLionel Sambuc 		 * rpc/udp. It passes null authentication parameters.
13111be35a1SLionel Sambuc 		 */
13211be35a1SLionel Sambuc 		rpcbproc_callit_com(rqstp, xprt, PMAPPROC_CALLIT, PMAPVERS);
13311be35a1SLionel Sambuc 		break;
13411be35a1SLionel Sambuc 
13511be35a1SLionel Sambuc 	default:
13611be35a1SLionel Sambuc 		svcerr_noproc(xprt);
13711be35a1SLionel Sambuc 		break;
13811be35a1SLionel Sambuc 	}
13911be35a1SLionel Sambuc }
14011be35a1SLionel Sambuc 
14111be35a1SLionel Sambuc /*
14211be35a1SLionel Sambuc  * returns the item with the given program, version number. If that version
14311be35a1SLionel Sambuc  * number is not found, it returns the item with that program number, so that
14411be35a1SLionel Sambuc  * the port number is now returned to the caller. The caller when makes a
14511be35a1SLionel Sambuc  * call to this program, version number, the call will fail and it will
14611be35a1SLionel Sambuc  * return with PROGVERS_MISMATCH. The user can then determine the highest
14711be35a1SLionel Sambuc  * and the lowest version number for this program using clnt_geterr() and
14811be35a1SLionel Sambuc  * use those program version numbers.
14911be35a1SLionel Sambuc  */
15011be35a1SLionel Sambuc static struct pmaplist *
find_service_pmap(rpcprog_t prog,rpcvers_t vers,rpcprot_t prot)15111be35a1SLionel Sambuc find_service_pmap(rpcprog_t prog, rpcvers_t vers, rpcprot_t prot)
15211be35a1SLionel Sambuc {
15311be35a1SLionel Sambuc 	register struct pmaplist *hit = NULL;
15411be35a1SLionel Sambuc 	register struct pmaplist *pml;
15511be35a1SLionel Sambuc 
15611be35a1SLionel Sambuc 	for (pml = list_pml; pml != NULL; pml = pml->pml_next) {
15711be35a1SLionel Sambuc 		if ((pml->pml_map.pm_prog != prog) ||
15811be35a1SLionel Sambuc 			(pml->pml_map.pm_prot != prot))
15911be35a1SLionel Sambuc 			continue;
16011be35a1SLionel Sambuc 		hit = pml;
16111be35a1SLionel Sambuc 		if (pml->pml_map.pm_vers == vers)
16211be35a1SLionel Sambuc 			break;
16311be35a1SLionel Sambuc 	}
16411be35a1SLionel Sambuc 	return (hit);
16511be35a1SLionel Sambuc }
16611be35a1SLionel Sambuc 
16711be35a1SLionel Sambuc static bool_t
pmapproc_change(struct svc_req * rqstp,SVCXPRT * xprt,unsigned long op)16811be35a1SLionel Sambuc pmapproc_change(struct svc_req *rqstp, SVCXPRT *xprt, unsigned long op)
16911be35a1SLionel Sambuc {
17011be35a1SLionel Sambuc 	struct pmap reg;
17111be35a1SLionel Sambuc 	RPCB rpcbreg;
17211be35a1SLionel Sambuc 	long ans;
17311be35a1SLionel Sambuc 	struct sockcred *sc;
17411be35a1SLionel Sambuc 	char uidbuf[32];
17511be35a1SLionel Sambuc 
17611be35a1SLionel Sambuc #ifdef RPCBIND_DEBUG
17711be35a1SLionel Sambuc 	if (debugging)
17811be35a1SLionel Sambuc 		fprintf(stderr, "%s request for (%lu, %lu) : ",
17911be35a1SLionel Sambuc 		    op == PMAPPROC_SET ? "PMAP_SET" : "PMAP_UNSET",
18011be35a1SLionel Sambuc 		    reg.pm_prog, reg.pm_vers);
18111be35a1SLionel Sambuc #endif
18211be35a1SLionel Sambuc 
18311be35a1SLionel Sambuc 	if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)&reg)) {
18411be35a1SLionel Sambuc 		svcerr_decode(xprt);
18511be35a1SLionel Sambuc 		return (FALSE);
18611be35a1SLionel Sambuc 	}
18711be35a1SLionel Sambuc 
18811be35a1SLionel Sambuc 	if (!check_access(xprt, op, &reg, PMAPVERS)) {
18911be35a1SLionel Sambuc 		svcerr_weakauth(xprt);
19011be35a1SLionel Sambuc 		return FALSE;
19111be35a1SLionel Sambuc 	}
19211be35a1SLionel Sambuc 
193*84d9c625SLionel Sambuc 	(void)svc_getcaller(xprt);
19411be35a1SLionel Sambuc 	sc = __svc_getcallercreds(xprt);
19511be35a1SLionel Sambuc 
19611be35a1SLionel Sambuc 	/*
19711be35a1SLionel Sambuc 	 * Can't use getpwnam here. We might end up calling ourselves
19811be35a1SLionel Sambuc 	 * and looping.
19911be35a1SLionel Sambuc 	 */
20011be35a1SLionel Sambuc 	if (sc == NULL)
20111be35a1SLionel Sambuc 		rpcbreg.r_owner = __UNCONST(rpcbind_unknown);
20211be35a1SLionel Sambuc 	else if (sc->sc_uid == 0)
20311be35a1SLionel Sambuc 		rpcbreg.r_owner = __UNCONST(rpcbind_superuser);
20411be35a1SLionel Sambuc 	else {
20511be35a1SLionel Sambuc 		/* r_owner will be strdup-ed later */
20611be35a1SLionel Sambuc 		snprintf(uidbuf, sizeof uidbuf, "%d", sc->sc_uid);
20711be35a1SLionel Sambuc 		rpcbreg.r_owner = uidbuf;
20811be35a1SLionel Sambuc 	}
20911be35a1SLionel Sambuc 
21011be35a1SLionel Sambuc 	rpcbreg.r_prog = reg.pm_prog;
21111be35a1SLionel Sambuc 	rpcbreg.r_vers = reg.pm_vers;
21211be35a1SLionel Sambuc 
21311be35a1SLionel Sambuc 	if (op == PMAPPROC_SET) {
21411be35a1SLionel Sambuc 		char buf[32];
21511be35a1SLionel Sambuc 
21611be35a1SLionel Sambuc 		snprintf(buf, sizeof(buf), "0.0.0.0.%d.%d",
21711be35a1SLionel Sambuc 		    (int)((reg.pm_port >> 8) & 0xff),
21811be35a1SLionel Sambuc 		    (int)(reg.pm_port & 0xff));
21911be35a1SLionel Sambuc 		rpcbreg.r_addr = buf;
22011be35a1SLionel Sambuc 		if (reg.pm_prot == IPPROTO_UDP) {
22111be35a1SLionel Sambuc 			rpcbreg.r_netid = __UNCONST(udptrans);
22211be35a1SLionel Sambuc 		} else if (reg.pm_prot == IPPROTO_TCP) {
22311be35a1SLionel Sambuc 			rpcbreg.r_netid = __UNCONST(tcptrans);
22411be35a1SLionel Sambuc 		} else {
22511be35a1SLionel Sambuc 			ans = FALSE;
22611be35a1SLionel Sambuc 			goto done_change;
22711be35a1SLionel Sambuc 		}
22811be35a1SLionel Sambuc 		ans = map_set(&rpcbreg, rpcbreg.r_owner);
22911be35a1SLionel Sambuc 	} else if (op == PMAPPROC_UNSET) {
23011be35a1SLionel Sambuc 		bool_t ans1, ans2;
23111be35a1SLionel Sambuc 
23211be35a1SLionel Sambuc 		rpcbreg.r_addr = NULL;
23311be35a1SLionel Sambuc 		rpcbreg.r_netid = __UNCONST(tcptrans);
23411be35a1SLionel Sambuc 		ans1 = map_unset(&rpcbreg, rpcbreg.r_owner);
23511be35a1SLionel Sambuc 		rpcbreg.r_netid = __UNCONST(udptrans);
23611be35a1SLionel Sambuc 		ans2 = map_unset(&rpcbreg, rpcbreg.r_owner);
23711be35a1SLionel Sambuc 		ans = ans1 || ans2;
23811be35a1SLionel Sambuc 	} else {
23911be35a1SLionel Sambuc 		ans = FALSE;
24011be35a1SLionel Sambuc 	}
24111be35a1SLionel Sambuc done_change:
24211be35a1SLionel Sambuc 	if ((!svc_sendreply(xprt, (xdrproc_t) xdr_long, (caddr_t) &ans)) &&
24311be35a1SLionel Sambuc 	    debugging) {
24411be35a1SLionel Sambuc 		fprintf(stderr, "portmap: svc_sendreply\n");
24511be35a1SLionel Sambuc 		if (doabort) {
24611be35a1SLionel Sambuc 			rpcbind_abort();
24711be35a1SLionel Sambuc 		}
24811be35a1SLionel Sambuc 	}
24911be35a1SLionel Sambuc #ifdef RPCBIND_DEBUG
25011be35a1SLionel Sambuc 	if (debugging)
25111be35a1SLionel Sambuc 		fprintf(stderr, "%s\n", ans == TRUE ? "succeeded" : "failed");
25211be35a1SLionel Sambuc #endif
25311be35a1SLionel Sambuc 	if (op == PMAPPROC_SET)
25411be35a1SLionel Sambuc 		rpcbs_set(RPCBVERS_2_STAT, ans);
25511be35a1SLionel Sambuc 	else
25611be35a1SLionel Sambuc 		rpcbs_unset(RPCBVERS_2_STAT, ans);
25711be35a1SLionel Sambuc 	return (TRUE);
25811be35a1SLionel Sambuc }
25911be35a1SLionel Sambuc 
26011be35a1SLionel Sambuc /* ARGSUSED */
26111be35a1SLionel Sambuc static bool_t
pmapproc_getport(struct svc_req * rqstp,SVCXPRT * xprt)26211be35a1SLionel Sambuc pmapproc_getport(struct svc_req *rqstp, SVCXPRT *xprt)
26311be35a1SLionel Sambuc {
26411be35a1SLionel Sambuc 	struct pmap reg;
26511be35a1SLionel Sambuc 	long lport;
26611be35a1SLionel Sambuc 	int port = 0;
26711be35a1SLionel Sambuc 	struct pmaplist *fnd;
26811be35a1SLionel Sambuc #ifdef RPCBIND_DEBUG
26911be35a1SLionel Sambuc 	char *uaddr;
27011be35a1SLionel Sambuc #endif
27111be35a1SLionel Sambuc 
27211be35a1SLionel Sambuc 	if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)&reg)) {
27311be35a1SLionel Sambuc 		svcerr_decode(xprt);
27411be35a1SLionel Sambuc 		return (FALSE);
27511be35a1SLionel Sambuc 	}
27611be35a1SLionel Sambuc 
27711be35a1SLionel Sambuc 	if (!check_access(xprt, PMAPPROC_GETPORT, &reg, PMAPVERS)) {
27811be35a1SLionel Sambuc 		svcerr_weakauth(xprt);
27911be35a1SLionel Sambuc 		return FALSE;
28011be35a1SLionel Sambuc 	}
28111be35a1SLionel Sambuc 
28211be35a1SLionel Sambuc #ifdef RPCBIND_DEBUG
28311be35a1SLionel Sambuc 	if (debugging) {
28411be35a1SLionel Sambuc 		uaddr =  taddr2uaddr(rpcbind_get_conf(xprt->xp_netid),
28511be35a1SLionel Sambuc 			    svc_getrpccaller(xprt));
28611be35a1SLionel Sambuc 		fprintf(stderr, "PMAP_GETPORT req for (%lu, %lu, %s) from %s :",
28711be35a1SLionel Sambuc 			reg.pm_prog, reg.pm_vers,
28811be35a1SLionel Sambuc 			reg.pm_prot == IPPROTO_UDP ? "udp" : "tcp", uaddr);
28911be35a1SLionel Sambuc 		free(uaddr);
29011be35a1SLionel Sambuc 	}
29111be35a1SLionel Sambuc #endif
29211be35a1SLionel Sambuc 	fnd = find_service_pmap(reg.pm_prog, reg.pm_vers, reg.pm_prot);
29311be35a1SLionel Sambuc 	if (fnd) {
29411be35a1SLionel Sambuc 		char serveuaddr[32];
29511be35a1SLionel Sambuc 		int h1, h2, h3, h4, p1, p2;
29611be35a1SLionel Sambuc 		const char *netid, *ua;
29711be35a1SLionel Sambuc 
29811be35a1SLionel Sambuc 		if (reg.pm_prot == IPPROTO_UDP) {
29911be35a1SLionel Sambuc 			ua = udp_uaddr;
30011be35a1SLionel Sambuc 			netid = udptrans;
30111be35a1SLionel Sambuc 		} else {
30211be35a1SLionel Sambuc 			ua = tcp_uaddr; /* To get the len */
30311be35a1SLionel Sambuc 			netid = tcptrans;
30411be35a1SLionel Sambuc 		}
30511be35a1SLionel Sambuc 		if (ua == NULL) {
30611be35a1SLionel Sambuc 			goto sendreply;
30711be35a1SLionel Sambuc 		}
30811be35a1SLionel Sambuc 		if (sscanf(ua, "%d.%d.%d.%d.%d.%d", &h1, &h2, &h3,
30911be35a1SLionel Sambuc 				&h4, &p1, &p2) == 6) {
31011be35a1SLionel Sambuc 			p1 = (fnd->pml_map.pm_port >> 8) & 0xff;
31111be35a1SLionel Sambuc 			p2 = (fnd->pml_map.pm_port) & 0xff;
31211be35a1SLionel Sambuc 			snprintf(serveuaddr, sizeof(serveuaddr),
31311be35a1SLionel Sambuc 			    "%d.%d.%d.%d.%d.%d", h1, h2, h3, h4, p1, p2);
31411be35a1SLionel Sambuc 			if (is_bound(netid, serveuaddr)) {
31511be35a1SLionel Sambuc 				port = fnd->pml_map.pm_port;
31611be35a1SLionel Sambuc 			} else { /* this service is dead; delete it */
31711be35a1SLionel Sambuc 				delete_prog(reg.pm_prog);
31811be35a1SLionel Sambuc 			}
31911be35a1SLionel Sambuc 		}
32011be35a1SLionel Sambuc 	}
32111be35a1SLionel Sambuc sendreply:
32211be35a1SLionel Sambuc 	lport = port;
32311be35a1SLionel Sambuc 	if ((!svc_sendreply(xprt, (xdrproc_t) xdr_long, (caddr_t)&lport)) &&
32411be35a1SLionel Sambuc 			debugging) {
32511be35a1SLionel Sambuc 		(void) fprintf(stderr, "portmap: svc_sendreply\n");
32611be35a1SLionel Sambuc 		if (doabort) {
32711be35a1SLionel Sambuc 			rpcbind_abort();
32811be35a1SLionel Sambuc 		}
32911be35a1SLionel Sambuc 	}
33011be35a1SLionel Sambuc #ifdef RPCBIND_DEBUG
33111be35a1SLionel Sambuc 	if (debugging)
33211be35a1SLionel Sambuc 		fprintf(stderr, "port = %d\n", port);
33311be35a1SLionel Sambuc #endif
33411be35a1SLionel Sambuc 	rpcbs_getaddr(RPCBVERS_2_STAT, reg.pm_prog, reg.pm_vers,
33511be35a1SLionel Sambuc 		reg.pm_prot == IPPROTO_UDP ? udptrans : tcptrans,
33611be35a1SLionel Sambuc 		port ? udptrans : "");
33711be35a1SLionel Sambuc 
33811be35a1SLionel Sambuc 	return (TRUE);
33911be35a1SLionel Sambuc }
34011be35a1SLionel Sambuc 
34111be35a1SLionel Sambuc /* ARGSUSED */
34211be35a1SLionel Sambuc static bool_t
pmapproc_dump(struct svc_req * rqstp,SVCXPRT * xprt)34311be35a1SLionel Sambuc pmapproc_dump(struct svc_req *rqstp, SVCXPRT *xprt)
34411be35a1SLionel Sambuc {
34511be35a1SLionel Sambuc 	if (!svc_getargs(xprt, (xdrproc_t)xdr_void, NULL)) {
34611be35a1SLionel Sambuc 		svcerr_decode(xprt);
34711be35a1SLionel Sambuc 		return (FALSE);
34811be35a1SLionel Sambuc 	}
34911be35a1SLionel Sambuc 
35011be35a1SLionel Sambuc 	if (!check_access(xprt, PMAPPROC_DUMP, NULL, PMAPVERS)) {
35111be35a1SLionel Sambuc 		svcerr_weakauth(xprt);
35211be35a1SLionel Sambuc 		return FALSE;
35311be35a1SLionel Sambuc 	}
35411be35a1SLionel Sambuc 
35511be35a1SLionel Sambuc 	if ((!svc_sendreply(xprt, (xdrproc_t) xdr_pmaplist_ptr,
35611be35a1SLionel Sambuc 			(caddr_t)&list_pml)) && debugging) {
35711be35a1SLionel Sambuc 		if (debugging)
35811be35a1SLionel Sambuc 			(void) fprintf(stderr, "portmap: svc_sendreply\n");
35911be35a1SLionel Sambuc 		if (doabort) {
36011be35a1SLionel Sambuc 			rpcbind_abort();
36111be35a1SLionel Sambuc 		}
36211be35a1SLionel Sambuc 	}
36311be35a1SLionel Sambuc 	return (TRUE);
36411be35a1SLionel Sambuc }
36511be35a1SLionel Sambuc 
36611be35a1SLionel Sambuc #endif /* PORTMAP */
367