Subversion Repositories SvarDOS

Rev

Rev 616 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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