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