1 /* 2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 * unrestricted use provided that this legend is included on all tape 4 * media and as a part of the software program in whole or part. Users 5 * may copy or modify Sun RPC without charge, but are not authorized 6 * to license or distribute it to anyone else except as part of a product or 7 * program developed by the user. 8 * 9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 12 * 13 * Sun RPC is provided with no support and without any obligation on the 14 * part of Sun Microsystems, Inc. to assist in its use, correction, 15 * modification or enhancement. 16 * 17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 * OR ANY PART THEREOF. 20 * 21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 * or profits or other special, indirect and consequential damages, even if 23 * Sun has been advised of the possibility of such damages. 24 * 25 * Sun Microsystems, Inc. 26 * 2550 Garcia Avenue 27 * Mountain View, California 94043 28 * 29 * from: @(#)auth.h 1.17 88/02/08 SMI 30 * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC 31 * $Id$ 32 */ 33 34 /* 35 * auth.h, Authentication interface. 36 * 37 * Copyright (C) 1984, Sun Microsystems, Inc. 38 * 39 * The data structures are completely opaque to the client. The client 40 * is required to pass a AUTH * to routines that create rpc 41 * "sessions". 42 */ 43 44 #ifndef _RPC_AUTH_H 45 #define _RPC_AUTH_H 46 #include <sys/cdefs.h> 47 48 #define MAX_AUTH_BYTES 400 49 #define MAXNETNAMELEN 255 /* maximum length of network user's name */ 50 51 /* 52 * Status returned from authentication check 53 */ 54 enum auth_stat { 55 AUTH_OK=0, 56 /* 57 * failed at remote end 58 */ 59 AUTH_BADCRED=1, /* bogus credentials (seal broken) */ 60 AUTH_REJECTEDCRED=2, /* client should begin new session */ 61 AUTH_BADVERF=3, /* bogus verifier (seal broken) */ 62 AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ 63 AUTH_TOOWEAK=5, /* rejected due to security reasons */ 64 /* 65 * failed locally 66 */ 67 AUTH_INVALIDRESP=6, /* bogus response verifier */ 68 AUTH_FAILED=7 /* some unknown reason */ 69 }; 70 71 union des_block { 72 struct { 73 u_int32_t high; 74 u_int32_t low; 75 } key; 76 char c[8]; 77 }; 78 typedef union des_block des_block; 79 __BEGIN_DECLS 80 extern bool_t xdr_des_block __P((XDR *, des_block *)); 81 __END_DECLS 82 83 /* 84 * Authentication info. Opaque to client. 85 */ 86 struct opaque_auth { 87 enum_t oa_flavor; /* flavor of auth */ 88 caddr_t oa_base; /* address of more auth stuff */ 89 u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ 90 }; 91 __BEGIN_DECLS 92 bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap); 93 __END_DECLS 94 95 96 /* 97 * Auth handle, interface to client side authenticators. 98 */ 99 typedef struct __rpc_auth { 100 struct opaque_auth ah_cred; 101 struct opaque_auth ah_verf; 102 union des_block ah_key; 103 struct auth_ops { 104 void (*ah_nextverf) __P((struct __rpc_auth *)); 105 /* nextverf & serialize */ 106 int (*ah_marshal) __P((struct __rpc_auth *, XDR *)); 107 /* validate verifier */ 108 int (*ah_validate) __P((struct __rpc_auth *, 109 struct opaque_auth *)); 110 /* refresh credentials */ 111 int (*ah_refresh) __P((struct __rpc_auth *)); 112 /* destroy this structure */ 113 void (*ah_destroy) __P((struct __rpc_auth *)); 114 } *ah_ops; 115 caddr_t ah_private; 116 } AUTH; 117 118 119 /* 120 * Authentication ops. 121 * The ops and the auth handle provide the interface to the authenticators. 122 * 123 * AUTH *auth; 124 * XDR *xdrs; 125 * struct opaque_auth verf; 126 */ 127 #define AUTH_NEXTVERF(auth) \ 128 ((*((auth)->ah_ops->ah_nextverf))(auth)) 129 #define auth_nextverf(auth) \ 130 ((*((auth)->ah_ops->ah_nextverf))(auth)) 131 132 #define AUTH_MARSHALL(auth, xdrs) \ 133 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) 134 #define auth_marshall(auth, xdrs) \ 135 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) 136 137 #define AUTH_VALIDATE(auth, verfp) \ 138 ((*((auth)->ah_ops->ah_validate))((auth), verfp)) 139 #define auth_validate(auth, verfp) \ 140 ((*((auth)->ah_ops->ah_validate))((auth), verfp)) 141 142 #define AUTH_REFRESH(auth) \ 143 ((*((auth)->ah_ops->ah_refresh))(auth)) 144 #define auth_refresh(auth) \ 145 ((*((auth)->ah_ops->ah_refresh))(auth)) 146 147 #define AUTH_DESTROY(auth) \ 148 ((*((auth)->ah_ops->ah_destroy))(auth)) 149 #define auth_destroy(auth) \ 150 ((*((auth)->ah_ops->ah_destroy))(auth)) 151 152 153 extern struct opaque_auth _null_auth; 154 155 /* 156 * These are the various implementations of client side authenticators. 157 */ 158 159 /* 160 * Unix style authentication 161 * AUTH *authunix_create(machname, uid, gid, len, aup_gids) 162 * char *machname; 163 * int uid; 164 * int gid; 165 * int len; 166 * int *aup_gids; 167 */ 168 __BEGIN_DECLS 169 struct sockaddr_in; 170 extern AUTH *authunix_create __P((char *, int, int, int, int *)); 171 extern AUTH *authunix_create_default __P((void)); 172 extern AUTH *authnone_create __P((void)); 173 extern AUTH *authdes_create __P((char *, u_int, 174 struct sockaddr_in *, des_block *)); 175 __END_DECLS 176 177 #define AUTH_NONE 0 /* no authentication */ 178 #define AUTH_NULL 0 /* backward compatibility */ 179 #define AUTH_UNIX 1 /* unix style (uid, gids) */ 180 #define AUTH_SHORT 2 /* short hand unix style */ 181 #define AUTH_DES 3 /* des style (encrypted timestamps) */ 182 183 #endif /* !_RPC_AUTH_H */ 184