1 /* $OpenBSD: auth_none.c,v 1.10 2006/03/31 18:28:55 deraadt Exp $ */ 2 /* 3 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 4 * unrestricted use provided that this legend is included on all tape 5 * media and as a part of the software program in whole or part. Users 6 * may copy or modify Sun RPC without charge, but are not authorized 7 * to license or distribute it to anyone else except as part of a product or 8 * program developed by the user. 9 * 10 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 11 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 12 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 13 * 14 * Sun RPC is provided with no support and without any obligation on the 15 * part of Sun Microsystems, Inc. to assist in its use, correction, 16 * modification or enhancement. 17 * 18 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 19 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 20 * OR ANY PART THEREOF. 21 * 22 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 23 * or profits or other special, indirect and consequential damages, even if 24 * Sun has been advised of the possibility of such damages. 25 * 26 * Sun Microsystems, Inc. 27 * 2550 Garcia Avenue 28 * Mountain View, California 94043 29 */ 30 31 /* 32 * auth_none.c 33 * Creates a client authentication handle for passing "null" 34 * credentials and verifiers to remote systems. 35 * 36 * Copyright (C) 1984, Sun Microsystems, Inc. 37 */ 38 39 #include <stdlib.h> 40 #include <rpc/types.h> 41 #include <rpc/rpc.h> 42 #include <rpc/xdr.h> 43 #include <rpc/auth.h> 44 #define MAX_MARSHEL_SIZE 20 45 46 /* 47 * Authenticator operations routines 48 */ 49 static void authnone_destroy(struct __rpc_auth *); 50 static void authnone_verf(struct __rpc_auth *); 51 static bool_t authnone_validate(struct __rpc_auth *, struct opaque_auth *); 52 static bool_t authnone_marshal(struct __rpc_auth *, XDR *); 53 static bool_t authnone_refresh(struct __rpc_auth *); 54 55 static struct auth_ops ops = { 56 authnone_verf, 57 authnone_marshal, 58 authnone_validate, 59 authnone_refresh, 60 authnone_destroy 61 }; 62 63 static struct authnone_private { 64 AUTH no_client; 65 char marshalled_client[MAX_MARSHEL_SIZE]; 66 u_int mcnt; 67 } *authnone_private; 68 69 AUTH * 70 authnone_create(void) 71 { 72 struct authnone_private *ap = authnone_private; 73 XDR xdr_stream; 74 XDR *xdrs; 75 76 if (ap == NULL) { 77 ap = (struct authnone_private *)calloc(1, sizeof (*ap)); 78 if (ap == NULL) 79 return (NULL); 80 authnone_private = ap; 81 } 82 if (!ap->mcnt) { 83 ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; 84 ap->no_client.ah_ops = &ops; 85 xdrs = &xdr_stream; 86 xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE, 87 XDR_ENCODE); 88 (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred); 89 (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf); 90 ap->mcnt = XDR_GETPOS(xdrs); 91 XDR_DESTROY(xdrs); 92 } 93 return (&ap->no_client); 94 } 95 96 /*ARGSUSED*/ 97 static bool_t 98 authnone_marshal(AUTH *client, XDR *xdrs) 99 { 100 struct authnone_private *ap = authnone_private; 101 102 if (ap == NULL) 103 return (0); 104 return ((*xdrs->x_ops->x_putbytes)(xdrs, 105 ap->marshalled_client, ap->mcnt)); 106 } 107 108 /*ARGSUSED*/ 109 static void 110 authnone_verf(struct __rpc_auth *none) 111 { 112 } 113 114 /*ARGSUSED*/ 115 static bool_t 116 authnone_validate(struct __rpc_auth *none, struct opaque_auth *noauth) 117 { 118 119 return (TRUE); 120 } 121 122 /*ARGSUSED*/ 123 static bool_t 124 authnone_refresh(struct __rpc_auth *none) 125 { 126 127 return (FALSE); 128 } 129 130 /*ARGSUSED*/ 131 static void 132 authnone_destroy(struct __rpc_auth *none) 133 { 134 } 135