1 /* $NetBSD: auth.h,v 1.16 2005/02/03 04:39:32 perry Exp $ */
4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5 * unrestricted use provided that this legend is included on all tape
6 * media and as a part of the software program in whole or part. Users
7 * may copy or modify Sun RPC without charge, but are not authorized
8 * to license or distribute it to anyone else except as part of a product or
9 * program developed by the user.
11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
15 * Sun RPC is provided with no support and without any obligation on the
16 * part of Sun Microsystems, Inc. to assist in its use, correction,
17 * modification or enhancement.
19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21 * OR ANY PART THEREOF.
23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24 * or profits or other special, indirect and consequential damages, even if
25 * Sun has been advised of the possibility of such damages.
27 * Sun Microsystems, Inc.
29 * Mountain View, California 94043
31 * from: @(#)auth.h 1.17 88/02/08 SMI
32 * @(#)auth.h 2.3 88/08/07 4.0 RPCSRC
36 * auth.h, Authentication interface.
38 * Copyright (C) 1984, Sun Microsystems, Inc.
40 * The data structures are completely opaque to the client. The client
41 * is required to pass a AUTH * to routines that create rpc
47 #include <sys/cdefs.h>
49 #define MAX_AUTH_BYTES 400
50 #define MAXNETNAMELEN 255 /* maximum length of network user's name */
53 * Status returned from authentication check
58 * failed at remote end
60 AUTH_BADCRED
=1, /* bogus credentials (seal broken) */
61 AUTH_REJECTEDCRED
=2, /* client should begin new session */
62 AUTH_BADVERF
=3, /* bogus verifier (seal broken) */
63 AUTH_REJECTEDVERF
=4, /* verifier expired or was replayed */
64 AUTH_TOOWEAK
=5, /* rejected due to security reasons */
68 AUTH_INVALIDRESP
=6, /* bogus response verifier */
69 AUTH_FAILED
=7 /* some unknown reason */
79 typedef union des_block des_block
;
81 extern bool_t
xdr_des_block(XDR
*, des_block
*);
85 * Authentication info. Opaque to client.
88 enum_t oa_flavor
; /* flavor of auth */
89 caddr_t oa_base
; /* address of more auth stuff */
90 u_int oa_length
; /* not to exceed MAX_AUTH_BYTES */
95 * Auth handle, interface to client side authenticators.
97 typedef struct __rpc_auth
{
98 struct opaque_auth ah_cred
;
99 struct opaque_auth ah_verf
;
100 union des_block ah_key
;
101 const struct auth_ops
{
102 void (*ah_nextverf
)(struct __rpc_auth
*);
103 /* nextverf & serialize */
104 int (*ah_marshal
)(struct __rpc_auth
*, XDR
*);
105 /* validate varifier */
106 int (*ah_validate
)(struct __rpc_auth
*,
107 struct opaque_auth
*);
108 /* refresh credentials */
109 int (*ah_refresh
)(struct __rpc_auth
*);
110 /* destroy this structure */
111 void (*ah_destroy
)(struct __rpc_auth
*);
118 * Authentication ops.
119 * The ops and the auth handle provide the interface to the authenticators.
123 * struct opaque_auth verf;
125 #define AUTH_NEXTVERF(auth) \
126 ((*((auth)->ah_ops->ah_nextverf))(auth))
127 #define auth_nextverf(auth) \
128 ((*((auth)->ah_ops->ah_nextverf))(auth))
130 #define AUTH_MARSHALL(auth, xdrs) \
131 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
132 #define auth_marshall(auth, xdrs) \
133 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
135 #define AUTH_VALIDATE(auth, verfp) \
136 ((*((auth)->ah_ops->ah_validate))((auth), verfp))
137 #define auth_validate(auth, verfp) \
138 ((*((auth)->ah_ops->ah_validate))((auth), verfp))
140 #define AUTH_REFRESH(auth) \
141 ((*((auth)->ah_ops->ah_refresh))(auth))
142 #define auth_refresh(auth) \
143 ((*((auth)->ah_ops->ah_refresh))(auth))
145 #define AUTH_DESTROY(auth) \
146 ((*((auth)->ah_ops->ah_destroy))(auth))
147 #define auth_destroy(auth) \
148 ((*((auth)->ah_ops->ah_destroy))(auth))
151 extern struct opaque_auth _null_auth
;
155 * These are the various implementations of client side authenticators.
159 * Unix style authentication
160 * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
169 extern AUTH
*authunix_create (char *, int, int, int, int *);
170 extern AUTH
*authunix_create_default (void);
171 extern AUTH
*authnone_create (void);
172 extern AUTH
*authdes_create (char *, u_int
,
173 struct sockaddr_in
*, des_block
*);
174 extern bool_t
xdr_opaque_auth (XDR
*, struct opaque_auth
*);
176 #define authsys_create(c,i1,i2,i3,ip) authunix_create((c),(i1),(i2),(i3),(ip))
177 #define authsys_create_default() authunix_create_default()
181 enum auth_stat
_svcauth_null(struct svc_req
*, struct rpc_msg
*);
182 enum auth_stat
_svcauth_short(struct svc_req
*, struct rpc_msg
*);
183 enum auth_stat
_svcauth_unix(struct svc_req
*, struct rpc_msg
*);
186 #define AUTH_NONE 0 /* no authentication */
187 #define AUTH_NULL 0 /* backward compatibility */
188 #define AUTH_SYS 1 /* unix style (uid, gids) */
189 #define AUTH_UNIX AUTH_SYS /* backward compatibility */
190 #define AUTH_SHORT 2 /* short hand unix style */
191 #define AUTH_DES 3 /* des style (encrypted timestamps) */
193 #endif /* !_RPC_AUTH_H_ */