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