4/* 5 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 6 * unrestricted use provided that this legend is included on all tape 7 * media and as a part of the software program in whole or part. Users 8 * may copy or modify Sun RPC without charge, but are not authorized 9 * to license or distribute it to anyone else except as part of a product or 10 * program developed by the user. 11 * 12 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 13 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 14 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 15 * 16 * Sun RPC is provided with no support and without any obligation on the 17 * part of Sun Microsystems, Inc. to assist in its use, correction, 18 * modification or enhancement. 19 * 20 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 21 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 22 * OR ANY PART THEREOF. 23 * 24 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 25 * or profits or other special, indirect and consequential damages, even if 26 * Sun has been advised of the possibility of such damages. 27 * 28 * Sun Microsystems, Inc. 29 * 2550 Garcia Avenue 30 * Mountain View, California 94043
| 4/*- 5 * Copyright (c) 2009, Sun Microsystems, Inc. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * - Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * - Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * - Neither the name of Sun Microsystems, Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived 17 * from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE.
|
31 */ 32/* 33 * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. 34 */ 35 36/* #ident "@(#)rpcb_svc.c 1.16 93/07/05 SMI" */ 37 38/* 39 * rpcb_svc.c 40 * The server procedure for the version 3 rpcbind (TLI). 41 * 42 * It maintains a separate list of all the registered services with the 43 * version 3 of rpcbind. 44 */ 45#include <sys/types.h> 46#include <rpc/rpc.h> 47#include <rpc/rpcb_prot.h> 48#include <netconfig.h> 49#include <syslog.h> 50#include <stdlib.h> 51#include <stdio.h> 52#include <string.h> 53 54#include "rpcbind.h" 55 56static void *rpcbproc_getaddr_3_local(void *, struct svc_req *, SVCXPRT *, 57 rpcvers_t); 58static void *rpcbproc_dump_3_local(void *, struct svc_req *, SVCXPRT *, 59 rpcvers_t); 60 61/* 62 * Called by svc_getreqset. There is a separate server handle for 63 * every transport that it waits on. 64 */ 65void 66rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp) 67{ 68 union { 69 RPCB rpcbproc_set_3_arg; 70 RPCB rpcbproc_unset_3_arg; 71 RPCB rpcbproc_getaddr_3_local_arg; 72 struct rpcb_rmtcallargs rpcbproc_callit_3_arg; 73 char *rpcbproc_uaddr2taddr_3_arg; 74 struct netbuf rpcbproc_taddr2uaddr_3_arg; 75 } argument; 76 char *result; 77 xdrproc_t xdr_argument, xdr_result; 78 void *(*local)(void *, struct svc_req *, SVCXPRT *, rpcvers_t); 79 80 rpcbs_procinfo(RPCBVERS_3_STAT, rqstp->rq_proc); 81 82 switch (rqstp->rq_proc) { 83 case NULLPROC: 84 /* 85 * Null proc call 86 */ 87#ifdef RPCBIND_DEBUG 88 if (debugging) 89 fprintf(stderr, "RPCBPROC_NULL\n"); 90#endif 91 /* This call just logs, no actual checks */ 92 check_access(transp, rqstp->rq_proc, NULL, RPCBVERS); 93 (void) svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL); 94 return; 95 96 case RPCBPROC_SET: 97 xdr_argument = (xdrproc_t )xdr_rpcb; 98 xdr_result = (xdrproc_t )xdr_bool; 99 local = rpcbproc_set_com; 100 break; 101 102 case RPCBPROC_UNSET: 103 xdr_argument = (xdrproc_t)xdr_rpcb; 104 xdr_result = (xdrproc_t)xdr_bool; 105 local = rpcbproc_unset_com; 106 break; 107 108 case RPCBPROC_GETADDR: 109 xdr_argument = (xdrproc_t)xdr_rpcb; 110 xdr_result = (xdrproc_t)xdr_wrapstring; 111 local = rpcbproc_getaddr_3_local; 112 break; 113 114 case RPCBPROC_DUMP: 115#ifdef RPCBIND_DEBUG 116 if (debugging) 117 fprintf(stderr, "RPCBPROC_DUMP\n"); 118#endif 119 xdr_argument = (xdrproc_t)xdr_void; 120 xdr_result = (xdrproc_t)xdr_rpcblist_ptr; 121 local = rpcbproc_dump_3_local; 122 break; 123 124 case RPCBPROC_CALLIT: 125 rpcbproc_callit_com(rqstp, transp, rqstp->rq_proc, RPCBVERS); 126 return; 127 128 case RPCBPROC_GETTIME: 129#ifdef RPCBIND_DEBUG 130 if (debugging) 131 fprintf(stderr, "RPCBPROC_GETTIME\n"); 132#endif 133 xdr_argument = (xdrproc_t)xdr_void; 134 xdr_result = (xdrproc_t)xdr_u_long; 135 local = rpcbproc_gettime_com; 136 break; 137 138 case RPCBPROC_UADDR2TADDR: 139#ifdef RPCBIND_DEBUG 140 if (debugging) 141 fprintf(stderr, "RPCBPROC_UADDR2TADDR\n"); 142#endif 143 xdr_argument = (xdrproc_t)xdr_wrapstring; 144 xdr_result = (xdrproc_t)xdr_netbuf; 145 local = rpcbproc_uaddr2taddr_com; 146 break; 147 148 case RPCBPROC_TADDR2UADDR: 149#ifdef RPCBIND_DEBUG 150 if (debugging) 151 fprintf(stderr, "RPCBPROC_TADDR2UADDR\n"); 152#endif 153 xdr_argument = (xdrproc_t)xdr_netbuf; 154 xdr_result = (xdrproc_t)xdr_wrapstring; 155 local = rpcbproc_taddr2uaddr_com; 156 break; 157 158 default: 159 svcerr_noproc(transp); 160 return; 161 } 162 (void) memset((char *)&argument, 0, sizeof (argument)); 163 if (!svc_getargs(transp, (xdrproc_t) xdr_argument, 164 (char *) &argument)) { 165 svcerr_decode(transp); 166 if (debugging) 167 (void) fprintf(stderr, "rpcbind: could not decode\n"); 168 return; 169 } 170 if (!check_access(transp, rqstp->rq_proc, &argument, RPCBVERS)) { 171 svcerr_weakauth(transp); 172 goto done; 173 } 174 result = (*local)(&argument, rqstp, transp, RPCBVERS); 175 if (result != NULL && !svc_sendreply(transp, (xdrproc_t)xdr_result, 176 result)) { 177 svcerr_systemerr(transp); 178 if (debugging) { 179 (void) fprintf(stderr, "rpcbind: svc_sendreply\n"); 180 if (doabort) { 181 rpcbind_abort(); 182 } 183 } 184 } 185done: 186 if (!svc_freeargs(transp, (xdrproc_t)xdr_argument, (char *) 187 &argument)) { 188 if (debugging) { 189 (void) fprintf(stderr, "unable to free arguments\n"); 190 if (doabort) { 191 rpcbind_abort(); 192 } 193 } 194 } 195} 196 197/* 198 * Lookup the mapping for a program, version and return its 199 * address. Assuming that the caller wants the address of the 200 * server running on the transport on which the request came. 201 * 202 * We also try to resolve the universal address in terms of 203 * address of the caller. 204 */ 205/* ARGSUSED */ 206static void * 207rpcbproc_getaddr_3_local(void *arg, struct svc_req *rqstp __unused, 208 SVCXPRT *transp __unused, rpcvers_t versnum __unused) 209{ 210 RPCB *regp = (RPCB *)arg; 211#ifdef RPCBIND_DEBUG 212 if (debugging) { 213 char *uaddr; 214 215 uaddr = taddr2uaddr(rpcbind_get_conf(transp->xp_netid), 216 svc_getrpccaller(transp)); 217 fprintf(stderr, "RPCB_GETADDR req for (%lu, %lu, %s) from %s: ", 218 (unsigned long)regp->r_prog, (unsigned long)regp->r_vers, 219 regp->r_netid, uaddr); 220 free(uaddr); 221 } 222#endif 223 return (rpcbproc_getaddr_com(regp, rqstp, transp, RPCBVERS, 224 RPCB_ALLVERS)); 225} 226 227/* ARGSUSED */ 228static void * 229rpcbproc_dump_3_local(void *arg __unused, struct svc_req *rqstp __unused, 230 SVCXPRT *transp __unused, rpcvers_t versnum __unused) 231{ 232 return ((void *)&list_rbl); 233}
| 30 */ 31/* 32 * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. 33 */ 34 35/* #ident "@(#)rpcb_svc.c 1.16 93/07/05 SMI" */ 36 37/* 38 * rpcb_svc.c 39 * The server procedure for the version 3 rpcbind (TLI). 40 * 41 * It maintains a separate list of all the registered services with the 42 * version 3 of rpcbind. 43 */ 44#include <sys/types.h> 45#include <rpc/rpc.h> 46#include <rpc/rpcb_prot.h> 47#include <netconfig.h> 48#include <syslog.h> 49#include <stdlib.h> 50#include <stdio.h> 51#include <string.h> 52 53#include "rpcbind.h" 54 55static void *rpcbproc_getaddr_3_local(void *, struct svc_req *, SVCXPRT *, 56 rpcvers_t); 57static void *rpcbproc_dump_3_local(void *, struct svc_req *, SVCXPRT *, 58 rpcvers_t); 59 60/* 61 * Called by svc_getreqset. There is a separate server handle for 62 * every transport that it waits on. 63 */ 64void 65rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp) 66{ 67 union { 68 RPCB rpcbproc_set_3_arg; 69 RPCB rpcbproc_unset_3_arg; 70 RPCB rpcbproc_getaddr_3_local_arg; 71 struct rpcb_rmtcallargs rpcbproc_callit_3_arg; 72 char *rpcbproc_uaddr2taddr_3_arg; 73 struct netbuf rpcbproc_taddr2uaddr_3_arg; 74 } argument; 75 char *result; 76 xdrproc_t xdr_argument, xdr_result; 77 void *(*local)(void *, struct svc_req *, SVCXPRT *, rpcvers_t); 78 79 rpcbs_procinfo(RPCBVERS_3_STAT, rqstp->rq_proc); 80 81 switch (rqstp->rq_proc) { 82 case NULLPROC: 83 /* 84 * Null proc call 85 */ 86#ifdef RPCBIND_DEBUG 87 if (debugging) 88 fprintf(stderr, "RPCBPROC_NULL\n"); 89#endif 90 /* This call just logs, no actual checks */ 91 check_access(transp, rqstp->rq_proc, NULL, RPCBVERS); 92 (void) svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL); 93 return; 94 95 case RPCBPROC_SET: 96 xdr_argument = (xdrproc_t )xdr_rpcb; 97 xdr_result = (xdrproc_t )xdr_bool; 98 local = rpcbproc_set_com; 99 break; 100 101 case RPCBPROC_UNSET: 102 xdr_argument = (xdrproc_t)xdr_rpcb; 103 xdr_result = (xdrproc_t)xdr_bool; 104 local = rpcbproc_unset_com; 105 break; 106 107 case RPCBPROC_GETADDR: 108 xdr_argument = (xdrproc_t)xdr_rpcb; 109 xdr_result = (xdrproc_t)xdr_wrapstring; 110 local = rpcbproc_getaddr_3_local; 111 break; 112 113 case RPCBPROC_DUMP: 114#ifdef RPCBIND_DEBUG 115 if (debugging) 116 fprintf(stderr, "RPCBPROC_DUMP\n"); 117#endif 118 xdr_argument = (xdrproc_t)xdr_void; 119 xdr_result = (xdrproc_t)xdr_rpcblist_ptr; 120 local = rpcbproc_dump_3_local; 121 break; 122 123 case RPCBPROC_CALLIT: 124 rpcbproc_callit_com(rqstp, transp, rqstp->rq_proc, RPCBVERS); 125 return; 126 127 case RPCBPROC_GETTIME: 128#ifdef RPCBIND_DEBUG 129 if (debugging) 130 fprintf(stderr, "RPCBPROC_GETTIME\n"); 131#endif 132 xdr_argument = (xdrproc_t)xdr_void; 133 xdr_result = (xdrproc_t)xdr_u_long; 134 local = rpcbproc_gettime_com; 135 break; 136 137 case RPCBPROC_UADDR2TADDR: 138#ifdef RPCBIND_DEBUG 139 if (debugging) 140 fprintf(stderr, "RPCBPROC_UADDR2TADDR\n"); 141#endif 142 xdr_argument = (xdrproc_t)xdr_wrapstring; 143 xdr_result = (xdrproc_t)xdr_netbuf; 144 local = rpcbproc_uaddr2taddr_com; 145 break; 146 147 case RPCBPROC_TADDR2UADDR: 148#ifdef RPCBIND_DEBUG 149 if (debugging) 150 fprintf(stderr, "RPCBPROC_TADDR2UADDR\n"); 151#endif 152 xdr_argument = (xdrproc_t)xdr_netbuf; 153 xdr_result = (xdrproc_t)xdr_wrapstring; 154 local = rpcbproc_taddr2uaddr_com; 155 break; 156 157 default: 158 svcerr_noproc(transp); 159 return; 160 } 161 (void) memset((char *)&argument, 0, sizeof (argument)); 162 if (!svc_getargs(transp, (xdrproc_t) xdr_argument, 163 (char *) &argument)) { 164 svcerr_decode(transp); 165 if (debugging) 166 (void) fprintf(stderr, "rpcbind: could not decode\n"); 167 return; 168 } 169 if (!check_access(transp, rqstp->rq_proc, &argument, RPCBVERS)) { 170 svcerr_weakauth(transp); 171 goto done; 172 } 173 result = (*local)(&argument, rqstp, transp, RPCBVERS); 174 if (result != NULL && !svc_sendreply(transp, (xdrproc_t)xdr_result, 175 result)) { 176 svcerr_systemerr(transp); 177 if (debugging) { 178 (void) fprintf(stderr, "rpcbind: svc_sendreply\n"); 179 if (doabort) { 180 rpcbind_abort(); 181 } 182 } 183 } 184done: 185 if (!svc_freeargs(transp, (xdrproc_t)xdr_argument, (char *) 186 &argument)) { 187 if (debugging) { 188 (void) fprintf(stderr, "unable to free arguments\n"); 189 if (doabort) { 190 rpcbind_abort(); 191 } 192 } 193 } 194} 195 196/* 197 * Lookup the mapping for a program, version and return its 198 * address. Assuming that the caller wants the address of the 199 * server running on the transport on which the request came. 200 * 201 * We also try to resolve the universal address in terms of 202 * address of the caller. 203 */ 204/* ARGSUSED */ 205static void * 206rpcbproc_getaddr_3_local(void *arg, struct svc_req *rqstp __unused, 207 SVCXPRT *transp __unused, rpcvers_t versnum __unused) 208{ 209 RPCB *regp = (RPCB *)arg; 210#ifdef RPCBIND_DEBUG 211 if (debugging) { 212 char *uaddr; 213 214 uaddr = taddr2uaddr(rpcbind_get_conf(transp->xp_netid), 215 svc_getrpccaller(transp)); 216 fprintf(stderr, "RPCB_GETADDR req for (%lu, %lu, %s) from %s: ", 217 (unsigned long)regp->r_prog, (unsigned long)regp->r_vers, 218 regp->r_netid, uaddr); 219 free(uaddr); 220 } 221#endif 222 return (rpcbproc_getaddr_com(regp, rqstp, transp, RPCBVERS, 223 RPCB_ALLVERS)); 224} 225 226/* ARGSUSED */ 227static void * 228rpcbproc_dump_3_local(void *arg __unused, struct svc_req *rqstp __unused, 229 SVCXPRT *transp __unused, rpcvers_t versnum __unused) 230{ 231 return ((void *)&list_rbl); 232}
|