/* * Called by svc_getreqset. There is a separate server handle for * every transport that it waits on. */ void rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp) { union { rpcb rpcbproc_set_4_arg; rpcb rpcbproc_unset_4_arg; rpcb rpcbproc_getaddr_4_local_arg; char *rpcbproc_uaddr2taddr_4_arg; struct netbuf rpcbproc_taddr2uaddr_4_arg; } argument; char *result; xdrproc_t xdr_argument, xdr_result; void *(*local) __P((void *, struct svc_req *, SVCXPRT *, rpcvers_t)); rpcprog_t setprog = 0; rpcbs_procinfo(RPCBVERS_4_STAT, rqstp->rq_proc); switch (rqstp->rq_proc) { case NULLPROC: /* * Null proc call */ #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_NULL\n"); #endif check_access(transp, rqstp->rq_proc, 0, RPCBVERS4); (void) svc_sendreply(transp, (xdrproc_t) xdr_void, (char *)NULL); return; case RPCBPROC_SET: /* * Check to see whether the message came from * loopback transports (for security reasons) */ xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_bool; local = rpcbproc_set_com; break; case RPCBPROC_UNSET: /* * Check to see whether the message came from * loopback transports (for security reasons) */ xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_bool; local = rpcbproc_unset_com; break; case RPCBPROC_GETADDR: xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_wrapstring; local = rpcbproc_getaddr_4_local; break; case RPCBPROC_GETVERSADDR: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_GETVERSADDR\n"); #endif xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_wrapstring; local = rpcbproc_getversaddr_4_local; break; case RPCBPROC_DUMP: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_DUMP\n"); #endif xdr_argument = (xdrproc_t)xdr_void; xdr_result = (xdrproc_t)xdr_rpcblist_ptr; local = rpcbproc_dump_4_local; break; case RPCBPROC_INDIRECT: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_INDIRECT\n"); #endif rpcbproc_callit_com(rqstp, transp, rqstp->rq_proc, RPCBVERS4); return; /* case RPCBPROC_CALLIT: */ case RPCBPROC_BCAST: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_BCAST\n"); #endif rpcbproc_callit_com(rqstp, transp, rqstp->rq_proc, RPCBVERS4); return; case RPCBPROC_GETTIME: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_GETTIME\n"); #endif xdr_argument = (xdrproc_t)xdr_void; xdr_result = (xdrproc_t)xdr_u_long; local = rpcbproc_gettime_com; break; case RPCBPROC_UADDR2TADDR: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_UADDR2TADDR\n"); #endif xdr_argument = (xdrproc_t)xdr_wrapstring; xdr_result = (xdrproc_t)xdr_netbuf; local = rpcbproc_uaddr2taddr_com; break; case RPCBPROC_TADDR2UADDR: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_TADDR2UADDR\n"); #endif xdr_argument = (xdrproc_t)xdr_netbuf; xdr_result = (xdrproc_t)xdr_wrapstring; local = rpcbproc_taddr2uaddr_com; break; case RPCBPROC_GETADDRLIST: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_GETADDRLIST\n"); #endif xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_rpcb_entry_list_ptr; local = rpcbproc_getaddrlist_4_local; break; case RPCBPROC_GETSTAT: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_GETSTAT\n"); #endif xdr_argument = (xdrproc_t)xdr_void; xdr_result = (xdrproc_t)xdr_rpcb_stat_byvers; local = rpcbproc_getstat; break; default: svcerr_noproc(transp); return; } memset((char *)&argument, 0, sizeof (argument)); if (!svc_getargs(transp, (xdrproc_t) xdr_argument, (char *)&argument)) { svcerr_decode(transp); if (debugging) (void) fprintf(stderr, "rpcbind: could not decode\n"); return; } if (rqstp->rq_proc == RPCBPROC_SET || rqstp->rq_proc == RPCBPROC_UNSET || rqstp->rq_proc == RPCBPROC_GETADDR) setprog = argument.rpcbproc_set_4_arg.r_prog; if (!check_access(transp, rqstp->rq_proc, setprog, RPCBVERS4)) { svcerr_weakauth(transp); goto done; } result = (*local)(&argument, rqstp, transp, RPCBVERS4); if (result != NULL && !svc_sendreply(transp, (xdrproc_t) xdr_result, result)) { svcerr_systemerr(transp); if (debugging) { (void) fprintf(stderr, "rpcbind: svc_sendreply\n"); if (doabort) { rpcbind_abort(); } } } done: if (!svc_freeargs(transp, (xdrproc_t) xdr_argument, (char *)&argument)) { if (debugging) { (void) fprintf(stderr, "unable to free arguments\n"); if (doabort) { rpcbind_abort(); } } } return; }
/* * Called by svc_getreqset. There is a separate server handle for * every transport that it waits on. */ void rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp) { union { RPCB rpcbproc_set_3_arg; RPCB rpcbproc_unset_3_arg; RPCB rpcbproc_getaddr_3_local_arg; struct rpcb_rmtcallargs rpcbproc_callit_3_arg; char *rpcbproc_uaddr2taddr_3_arg; struct netbuf rpcbproc_taddr2uaddr_3_arg; } argument; char *result; xdrproc_t xdr_argument, xdr_result; void *(*local)(void *, struct svc_req *, SVCXPRT *, rpcvers_t); rpcbs_procinfo(RPCBVERS_3_STAT, rqstp->rq_proc); switch (rqstp->rq_proc) { case NULLPROC: /* * Null proc call */ #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_NULL\n"); #endif /* This call just logs, no actual checks */ check_access(transp, rqstp->rq_proc, NULL, RPCBVERS); (void) svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL); return; case RPCBPROC_SET: xdr_argument = (xdrproc_t )xdr_rpcb; xdr_result = (xdrproc_t )xdr_bool; local = rpcbproc_set_com; break; case RPCBPROC_UNSET: xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_bool; local = rpcbproc_unset_com; break; case RPCBPROC_GETADDR: xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_wrapstring; local = rpcbproc_getaddr_3_local; break; case RPCBPROC_DUMP: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_DUMP\n"); #endif xdr_argument = (xdrproc_t)xdr_void; xdr_result = (xdrproc_t)xdr_rpcblist_ptr; local = rpcbproc_dump_3_local; break; case RPCBPROC_CALLIT: rpcbproc_callit_com(rqstp, transp, rqstp->rq_proc, RPCBVERS); return; case RPCBPROC_GETTIME: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_GETTIME\n"); #endif xdr_argument = (xdrproc_t)xdr_void; xdr_result = (xdrproc_t)xdr_u_long; local = rpcbproc_gettime_com; break; case RPCBPROC_UADDR2TADDR: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_UADDR2TADDR\n"); #endif xdr_argument = (xdrproc_t)xdr_wrapstring; xdr_result = (xdrproc_t)xdr_netbuf; local = rpcbproc_uaddr2taddr_com; break; case RPCBPROC_TADDR2UADDR: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_TADDR2UADDR\n"); #endif xdr_argument = (xdrproc_t)xdr_netbuf; xdr_result = (xdrproc_t)xdr_wrapstring; local = rpcbproc_taddr2uaddr_com; break; default: svcerr_noproc(transp); return; } (void) memset((char *)&argument, 0, sizeof (argument)); if (!svc_getargs(transp, (xdrproc_t) xdr_argument, (char *) &argument)) { svcerr_decode(transp); if (debugging) (void) fprintf(stderr, "rpcbind: could not decode\n"); return; } if (!check_access(transp, rqstp->rq_proc, &argument, RPCBVERS)) { svcerr_weakauth(transp); goto done; } result = (*local)(&argument, rqstp, transp, RPCBVERS); if (result != NULL && !svc_sendreply(transp, (xdrproc_t)xdr_result, result)) { svcerr_systemerr(transp); if (debugging) { (void) fprintf(stderr, "rpcbind: svc_sendreply\n"); if (doabort) { rpcbind_abort(); } } } done: if (!svc_freeargs(transp, (xdrproc_t)xdr_argument, (char *) &argument)) { if (debugging) { (void) fprintf(stderr, "unable to free arguments\n"); if (doabort) { rpcbind_abort(); } } } }
/* * Called for all the version 2 inquiries. */ void pmap_service(struct svc_req *rqstp, SVCXPRT *xprt) { rpcbs_procinfo(RPCBVERS_2_STAT, rqstp->rq_proc); switch (rqstp->rq_proc) { case PMAPPROC_NULL: /* * Null proc call */ #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "PMAPPROC_NULL\n"); #endif check_access(xprt, rqstp->rq_proc, NULL, PMAPVERS); if ((!svc_sendreply(xprt, (xdrproc_t) xdr_void, NULL)) && debugging) { if (doabort) { rpcbind_abort(); } } break; case PMAPPROC_SET: /* * Set a program, version to port mapping */ pmapproc_change(rqstp, xprt, rqstp->rq_proc); break; case PMAPPROC_UNSET: /* * Remove a program, version to port mapping. */ pmapproc_change(rqstp, xprt, rqstp->rq_proc); break; case PMAPPROC_GETPORT: /* * Lookup the mapping for a program, version and return its * port number. */ pmapproc_getport(rqstp, xprt); break; case PMAPPROC_DUMP: /* * Return the current set of mapped program, version */ #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "PMAPPROC_DUMP\n"); #endif pmapproc_dump(rqstp, xprt); break; case PMAPPROC_CALLIT: /* * Calls a procedure on the local machine. If the requested * procedure is not registered this procedure does not return * error information!! * This procedure is only supported on rpc/udp and calls via * rpc/udp. It passes null authentication parameters. */ rpcbproc_callit_com(rqstp, xprt, PMAPPROC_CALLIT, PMAPVERS); break; default: svcerr_noproc(xprt); break; } }