207 |
mateuszvis |
1 |
/*!\file rpc/auth.h
|
|
|
2 |
* RPC authentication interface.
|
|
|
3 |
*/
|
|
|
4 |
|
|
|
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, MERCHANTABILITY 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 |
* from: @(#)auth.h 1.17 88/02/08 SMI
|
|
|
34 |
* from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC
|
|
|
35 |
* $Id: auth.h,v 1.5 1996/01/31 08:02:11 hsu Exp $
|
|
|
36 |
*/
|
|
|
37 |
|
|
|
38 |
/*
|
|
|
39 |
* auth.h, Authentication interface.
|
|
|
40 |
*
|
|
|
41 |
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
|
42 |
*
|
|
|
43 |
* The data structures are completely opaque to the client. The client
|
|
|
44 |
* is required to pass a AUTH * to routines that create rpc
|
|
|
45 |
* "sessions".
|
|
|
46 |
*/
|
|
|
47 |
|
|
|
48 |
#ifndef __RPC_AUTH_H
|
|
|
49 |
#define __RPC_AUTH_H
|
|
|
50 |
|
|
|
51 |
#ifndef __SYS_CDEFS_H
|
|
|
52 |
#include <sys/cdefs.h>
|
|
|
53 |
#endif
|
|
|
54 |
|
|
|
55 |
#ifndef __SYS_SOCKET_H
|
|
|
56 |
#include <sys/socket.h>
|
|
|
57 |
#endif
|
|
|
58 |
|
|
|
59 |
#define MAX_AUTH_BYTES 400
|
|
|
60 |
#define MAXNETNAMELEN 255 /* maximum length of network user's name */
|
|
|
61 |
|
|
|
62 |
/*
|
|
|
63 |
* Status returned from authentication check
|
|
|
64 |
*/
|
|
|
65 |
enum auth_stat {
|
|
|
66 |
AUTH_OK=0,
|
|
|
67 |
/*
|
|
|
68 |
* failed at remote end
|
|
|
69 |
*/
|
|
|
70 |
AUTH_BADCRED=1, /* bogus credentials (seal broken) */
|
|
|
71 |
AUTH_REJECTEDCRED=2, /* client should begin new session */
|
|
|
72 |
AUTH_BADVERF=3, /* bogus verifier (seal broken) */
|
|
|
73 |
AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */
|
|
|
74 |
AUTH_TOOWEAK=5, /* rejected due to security reasons */
|
|
|
75 |
/*
|
|
|
76 |
* failed locally
|
|
|
77 |
*/
|
|
|
78 |
AUTH_INVALIDRESP=6, /* bogus response verifier */
|
|
|
79 |
AUTH_FAILED=7 /* some unknown reason */
|
|
|
80 |
};
|
|
|
81 |
|
|
|
82 |
union des_block {
|
|
|
83 |
struct {
|
|
|
84 |
u_long high;
|
|
|
85 |
u_long low;
|
|
|
86 |
} key;
|
|
|
87 |
char c[8];
|
|
|
88 |
};
|
|
|
89 |
|
|
|
90 |
typedef union des_block des_block;
|
|
|
91 |
|
|
|
92 |
__BEGIN_DECLS
|
|
|
93 |
|
|
|
94 |
extern bool_t xdr_des_block (XDR *, des_block *);
|
|
|
95 |
|
|
|
96 |
__END_DECLS
|
|
|
97 |
|
|
|
98 |
/*
|
|
|
99 |
* Authentication info. Opaque to client.
|
|
|
100 |
*/
|
|
|
101 |
struct opaque_auth {
|
|
|
102 |
enum_t oa_flavor; /* flavor of auth */
|
|
|
103 |
caddr_t oa_base; /* address of more auth stuff */
|
|
|
104 |
u_int oa_length; /* not to exceed MAX_AUTH_BYTES */
|
|
|
105 |
};
|
|
|
106 |
|
|
|
107 |
/*
|
|
|
108 |
* Auth handle, interface to client side authenticators.
|
|
|
109 |
*/
|
|
|
110 |
typedef struct {
|
|
|
111 |
struct opaque_auth ah_cred;
|
|
|
112 |
struct opaque_auth ah_verf;
|
|
|
113 |
union des_block ah_key;
|
|
|
114 |
struct auth_ops {
|
|
|
115 |
void (*ah_nextverf)();
|
|
|
116 |
int (*ah_marshal)(); /* nextverf & serialize */
|
|
|
117 |
int (*ah_validate)(); /* validate verifier */
|
|
|
118 |
int (*ah_refresh)(); /* refresh credentials */
|
|
|
119 |
void (*ah_destroy)(); /* destroy this structure */
|
|
|
120 |
} *ah_ops;
|
|
|
121 |
caddr_t ah_private;
|
|
|
122 |
} AUTH;
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
/*
|
|
|
126 |
* Authentication ops.
|
|
|
127 |
* The ops and the auth handle provide the interface to the authenticators.
|
|
|
128 |
*
|
|
|
129 |
* AUTH *auth;
|
|
|
130 |
* XDR *xdrs;
|
|
|
131 |
* struct opaque_auth verf;
|
|
|
132 |
*/
|
|
|
133 |
#define AUTH_NEXTVERF(auth) ((*((auth)->ah_ops->ah_nextverf))(auth))
|
|
|
134 |
#define auth_nextverf(auth) ((*((auth)->ah_ops->ah_nextverf))(auth))
|
|
|
135 |
|
|
|
136 |
#define AUTH_MARSHALL(auth,xdrs) ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
|
|
|
137 |
#define auth_marshall(auth,xdrs) ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
|
|
|
138 |
|
|
|
139 |
#define AUTH_VALIDATE(auth,verfp) ((*((auth)->ah_ops->ah_validate))((auth), verfp))
|
|
|
140 |
#define auth_validate(auth,verfp) ((*((auth)->ah_ops->ah_validate))((auth), verfp))
|
|
|
141 |
|
|
|
142 |
#define AUTH_REFRESH(auth) ((*((auth)->ah_ops->ah_refresh))(auth))
|
|
|
143 |
#define auth_refresh(auth) ((*((auth)->ah_ops->ah_refresh))(auth))
|
|
|
144 |
|
|
|
145 |
#define AUTH_DESTROY(auth) ((*((auth)->ah_ops->ah_destroy))(auth))
|
|
|
146 |
#define auth_destroy(auth) ((*((auth)->ah_ops->ah_destroy))(auth))
|
|
|
147 |
|
|
|
148 |
extern struct opaque_auth _null_auth;
|
|
|
149 |
|
|
|
150 |
|
|
|
151 |
/*
|
|
|
152 |
* These are the various implementations of client side authenticators.
|
|
|
153 |
*/
|
|
|
154 |
|
|
|
155 |
/*
|
|
|
156 |
* Unix style authentication
|
|
|
157 |
* AUTH *authunix_create(machname, uid, gid, len, aup_gids)
|
|
|
158 |
* char *machname;
|
|
|
159 |
* int uid;
|
|
|
160 |
* int gid;
|
|
|
161 |
* int len;
|
|
|
162 |
* int *aup_gids;
|
|
|
163 |
*/
|
|
|
164 |
|
|
|
165 |
__BEGIN_DECLS
|
|
|
166 |
|
|
|
167 |
extern AUTH *authunix_create (char *, int, int, int, int *);
|
|
|
168 |
extern AUTH *authunix_create_default(void);
|
|
|
169 |
extern AUTH *authnone_create (void);
|
|
|
170 |
extern AUTH *authdes_create (char*, u_int, struct sockaddr*, des_block*);
|
|
|
171 |
|
|
|
172 |
__END_DECLS
|
|
|
173 |
|
|
|
174 |
#define AUTH_NONE 0 /* no authentication */
|
|
|
175 |
#define AUTH_NULL 0 /* backward compatibility */
|
|
|
176 |
#define AUTH_UNIX 1 /* unix style (uid, gids) */
|
|
|
177 |
#define AUTH_SHORT 2 /* short hand unix style */
|
|
|
178 |
#define AUTH_DES 3 /* des style (encrypted timestamps) */
|
|
|
179 |
|
|
|
180 |
#endif
|