xref: /titanic_50/usr/src/uts/common/rpc/auth.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */
28*7c478bd9Sstevel@tonic-gate /*
29*7c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
30*7c478bd9Sstevel@tonic-gate  * 4.3 BSD under license from the Regents of the University of
31*7c478bd9Sstevel@tonic-gate  * California.
32*7c478bd9Sstevel@tonic-gate  */
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate /*
35*7c478bd9Sstevel@tonic-gate  * auth.h, Authentication interface.
36*7c478bd9Sstevel@tonic-gate  *
37*7c478bd9Sstevel@tonic-gate  * The data structures are completely opaque to the client. The client
38*7c478bd9Sstevel@tonic-gate  * is required to pass a AUTH * to routines that create rpc
39*7c478bd9Sstevel@tonic-gate  * "sessions".
40*7c478bd9Sstevel@tonic-gate  */
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate #ifndef	_RPC_AUTH_H
43*7c478bd9Sstevel@tonic-gate #define	_RPC_AUTH_H
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate #include <rpc/xdr.h>
48*7c478bd9Sstevel@tonic-gate #include <rpc/clnt_stat.h>
49*7c478bd9Sstevel@tonic-gate #include <sys/cred.h>
50*7c478bd9Sstevel@tonic-gate #include <sys/tiuser.h>
51*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
52*7c478bd9Sstevel@tonic-gate #include <sys/zone.h>
53*7c478bd9Sstevel@tonic-gate #endif
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
56*7c478bd9Sstevel@tonic-gate extern "C" {
57*7c478bd9Sstevel@tonic-gate #endif
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate #define	MAX_AUTH_BYTES	400
60*7c478bd9Sstevel@tonic-gate #define	MAXNETNAMELEN	255	/* maximum length of network user's name */
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate /*
63*7c478bd9Sstevel@tonic-gate  *  Client side authentication/security data
64*7c478bd9Sstevel@tonic-gate  */
65*7c478bd9Sstevel@tonic-gate typedef struct sec_data {
66*7c478bd9Sstevel@tonic-gate 	uint_t	secmod;		/* security mode number e.g. in nfssec.conf */
67*7c478bd9Sstevel@tonic-gate 	uint_t	rpcflavor;	/* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */
68*7c478bd9Sstevel@tonic-gate 	int	flags;		/* AUTH_F_xxx flags */
69*7c478bd9Sstevel@tonic-gate 	uid_t	uid;		/* uid of caller for all sec flavors (NFSv4)  */
70*7c478bd9Sstevel@tonic-gate 	caddr_t	data;		/* opaque data per flavor */
71*7c478bd9Sstevel@tonic-gate } sec_data_t;
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
74*7c478bd9Sstevel@tonic-gate struct sec_data32 {
75*7c478bd9Sstevel@tonic-gate 	uint32_t	secmod;	/* security mode number e.g. in nfssec.conf */
76*7c478bd9Sstevel@tonic-gate 	uint32_t	rpcflavor; /* AUTH_UNIX,AUTH_DES,RPCSEC_GSS */
77*7c478bd9Sstevel@tonic-gate 	int32_t		flags;	/* AUTH_F_xxx flags */
78*7c478bd9Sstevel@tonic-gate 	uid_t		uid;	/* uid of caller for all sec flavors (NFSv4) */
79*7c478bd9Sstevel@tonic-gate 	caddr32_t	data;	/* opaque data per flavor */
80*7c478bd9Sstevel@tonic-gate };
81*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32_IMPL */
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate /*
84*7c478bd9Sstevel@tonic-gate  * AUTH_DES flavor specific data from sec_data opaque data field.
85*7c478bd9Sstevel@tonic-gate  * AUTH_KERB has the same structure.
86*7c478bd9Sstevel@tonic-gate  */
87*7c478bd9Sstevel@tonic-gate typedef struct des_clnt_data {
88*7c478bd9Sstevel@tonic-gate 	struct netbuf	syncaddr;	/* time sync addr */
89*7c478bd9Sstevel@tonic-gate 	struct knetconfig *knconf;	/* knetconfig info that associated */
90*7c478bd9Sstevel@tonic-gate 					/* with the syncaddr. */
91*7c478bd9Sstevel@tonic-gate 	char		*netname;	/* server's netname */
92*7c478bd9Sstevel@tonic-gate 	int		netnamelen;	/* server's netname len */
93*7c478bd9Sstevel@tonic-gate } dh_k4_clntdata_t;
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
96*7c478bd9Sstevel@tonic-gate struct des_clnt_data32 {
97*7c478bd9Sstevel@tonic-gate 	struct netbuf32 syncaddr;	/* time sync addr */
98*7c478bd9Sstevel@tonic-gate 	caddr32_t knconf;		/* knetconfig info that associated */
99*7c478bd9Sstevel@tonic-gate 					/* with the syncaddr. */
100*7c478bd9Sstevel@tonic-gate 	caddr32_t netname;		/* server's netname */
101*7c478bd9Sstevel@tonic-gate 	int32_t	netnamelen;		/* server's netname len */
102*7c478bd9Sstevel@tonic-gate };
103*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32_IMPL */
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate /*
106*7c478bd9Sstevel@tonic-gate  * flavor specific data to hold the data for AUTH_DES/AUTH_KERB(v4)
107*7c478bd9Sstevel@tonic-gate  * in sec_data->data opaque field.
108*7c478bd9Sstevel@tonic-gate  */
109*7c478bd9Sstevel@tonic-gate typedef struct krb4_svc_data {
110*7c478bd9Sstevel@tonic-gate 	int		window;		/* window option value */
111*7c478bd9Sstevel@tonic-gate } krb4_svcdata_t;
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate typedef struct krb4_svc_data	des_svcdata_t;
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate /*
116*7c478bd9Sstevel@tonic-gate  * authentication/security specific flags
117*7c478bd9Sstevel@tonic-gate  */
118*7c478bd9Sstevel@tonic-gate #define	AUTH_F_RPCTIMESYNC	0x001	/* use RPC to do time sync */
119*7c478bd9Sstevel@tonic-gate #define	AUTH_F_TRYNONE		0x002	/* allow fall back to AUTH_NONE */
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate /*
123*7c478bd9Sstevel@tonic-gate  * Status returned from authentication check
124*7c478bd9Sstevel@tonic-gate  */
125*7c478bd9Sstevel@tonic-gate enum auth_stat {
126*7c478bd9Sstevel@tonic-gate 	AUTH_OK = 0,
127*7c478bd9Sstevel@tonic-gate 	/*
128*7c478bd9Sstevel@tonic-gate 	 * failed at remote end
129*7c478bd9Sstevel@tonic-gate 	 */
130*7c478bd9Sstevel@tonic-gate 	AUTH_BADCRED = 1,		/* bogus credentials (seal broken) */
131*7c478bd9Sstevel@tonic-gate 	AUTH_REJECTEDCRED = 2,		/* client should begin new session */
132*7c478bd9Sstevel@tonic-gate 	AUTH_BADVERF = 3,		/* bogus verifier (seal broken) */
133*7c478bd9Sstevel@tonic-gate 	AUTH_REJECTEDVERF = 4,		/* verifier expired or was replayed */
134*7c478bd9Sstevel@tonic-gate 	AUTH_TOOWEAK = 5,		/* rejected due to security reasons */
135*7c478bd9Sstevel@tonic-gate 	/*
136*7c478bd9Sstevel@tonic-gate 	 * failed locally
137*7c478bd9Sstevel@tonic-gate 	 */
138*7c478bd9Sstevel@tonic-gate 	AUTH_INVALIDRESP = 6,		/* bogus response verifier */
139*7c478bd9Sstevel@tonic-gate 	AUTH_FAILED = 7,			/* some unknown reason */
140*7c478bd9Sstevel@tonic-gate 	/*
141*7c478bd9Sstevel@tonic-gate 	 * kerberos errors
142*7c478bd9Sstevel@tonic-gate 	 */
143*7c478bd9Sstevel@tonic-gate 	AUTH_KERB_GENERIC = 8,		/* kerberos generic error */
144*7c478bd9Sstevel@tonic-gate 	AUTH_TIMEEXPIRE = 9,		/* time of credential expired */
145*7c478bd9Sstevel@tonic-gate 	AUTH_TKT_FILE = 10,		/* something wrong with ticket file */
146*7c478bd9Sstevel@tonic-gate 	AUTH_DECODE = 11,		/* can't decode authenticator */
147*7c478bd9Sstevel@tonic-gate 	AUTH_NET_ADDR = 12,		/* wrong net address in ticket */
148*7c478bd9Sstevel@tonic-gate 	/*
149*7c478bd9Sstevel@tonic-gate 	 * GSS related errors
150*7c478bd9Sstevel@tonic-gate 	 */
151*7c478bd9Sstevel@tonic-gate 	RPCSEC_GSS_NOCRED = 13,		/* no credentials for user */
152*7c478bd9Sstevel@tonic-gate 	RPCSEC_GSS_FAILED = 14		/* GSS failure, credentials deleted */
153*7c478bd9Sstevel@tonic-gate };
154*7c478bd9Sstevel@tonic-gate typedef enum auth_stat AUTH_STAT;
155*7c478bd9Sstevel@tonic-gate 
156*7c478bd9Sstevel@tonic-gate union des_block {
157*7c478bd9Sstevel@tonic-gate 	struct	{
158*7c478bd9Sstevel@tonic-gate 		uint32_t high;
159*7c478bd9Sstevel@tonic-gate 		uint32_t low;
160*7c478bd9Sstevel@tonic-gate 	} key;
161*7c478bd9Sstevel@tonic-gate 	char c[8];
162*7c478bd9Sstevel@tonic-gate };
163*7c478bd9Sstevel@tonic-gate typedef union des_block des_block;
164*7c478bd9Sstevel@tonic-gate 
165*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
166*7c478bd9Sstevel@tonic-gate extern bool_t xdr_des_block(XDR *, des_block *);
167*7c478bd9Sstevel@tonic-gate #else
168*7c478bd9Sstevel@tonic-gate extern bool_t xdr_des_block();
169*7c478bd9Sstevel@tonic-gate #endif
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate /*
173*7c478bd9Sstevel@tonic-gate  * Authentication info. Opaque to client.
174*7c478bd9Sstevel@tonic-gate  */
175*7c478bd9Sstevel@tonic-gate struct opaque_auth {
176*7c478bd9Sstevel@tonic-gate 	enum_t	oa_flavor;		/* flavor of auth */
177*7c478bd9Sstevel@tonic-gate 	caddr_t	oa_base;		/* address of more auth stuff */
178*7c478bd9Sstevel@tonic-gate 	uint_t	oa_length;		/* not to exceed MAX_AUTH_BYTES */
179*7c478bd9Sstevel@tonic-gate };
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate /*
183*7c478bd9Sstevel@tonic-gate  * Auth handle, interface to client side authenticators.
184*7c478bd9Sstevel@tonic-gate  */
185*7c478bd9Sstevel@tonic-gate typedef struct __auth {
186*7c478bd9Sstevel@tonic-gate 	struct	opaque_auth	ah_cred;
187*7c478bd9Sstevel@tonic-gate 	struct	opaque_auth	ah_verf;
188*7c478bd9Sstevel@tonic-gate 	union	des_block	ah_key;
189*7c478bd9Sstevel@tonic-gate 	struct auth_ops {
190*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
191*7c478bd9Sstevel@tonic-gate 		void	(*ah_nextverf)(struct __auth *);
192*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
193*7c478bd9Sstevel@tonic-gate 		int	(*ah_marshal)(struct __auth *, XDR *, struct cred *);
194*7c478bd9Sstevel@tonic-gate #else
195*7c478bd9Sstevel@tonic-gate 		int	(*ah_marshal)(struct __auth *, XDR *);
196*7c478bd9Sstevel@tonic-gate #endif
197*7c478bd9Sstevel@tonic-gate 		/* nextverf & serialize */
198*7c478bd9Sstevel@tonic-gate 		int	(*ah_validate)(struct __auth *,
199*7c478bd9Sstevel@tonic-gate 		    struct opaque_auth *);
200*7c478bd9Sstevel@tonic-gate 		/* validate varifier */
201*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
202*7c478bd9Sstevel@tonic-gate 		int	(*ah_refresh)(struct __auth *, struct rpc_msg *,
203*7c478bd9Sstevel@tonic-gate 		    cred_t *);
204*7c478bd9Sstevel@tonic-gate #else
205*7c478bd9Sstevel@tonic-gate 		int	(*ah_refresh)(struct __auth *, void *);
206*7c478bd9Sstevel@tonic-gate 		/* refresh credentials */
207*7c478bd9Sstevel@tonic-gate #endif
208*7c478bd9Sstevel@tonic-gate 		void	(*ah_destroy)(struct __auth *);
209*7c478bd9Sstevel@tonic-gate 		/* destroy this structure */
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
212*7c478bd9Sstevel@tonic-gate 		int	(*ah_wrap)(struct __auth *, caddr_t, uint_t,
213*7c478bd9Sstevel@tonic-gate 		    XDR *, xdrproc_t, caddr_t);
214*7c478bd9Sstevel@tonic-gate 		int	(*ah_unwrap)(struct __auth *, XDR *, xdrproc_t,
215*7c478bd9Sstevel@tonic-gate 		    caddr_t);
216*7c478bd9Sstevel@tonic-gate #endif
217*7c478bd9Sstevel@tonic-gate #else
218*7c478bd9Sstevel@tonic-gate 		void	(*ah_nextverf)();
219*7c478bd9Sstevel@tonic-gate 		int	(*ah_marshal)();	/* nextverf & serialize */
220*7c478bd9Sstevel@tonic-gate 		int	(*ah_validate)();	/* validate verifier */
221*7c478bd9Sstevel@tonic-gate 		int	(*ah_refresh)();	/* refresh credentials */
222*7c478bd9Sstevel@tonic-gate 		void	(*ah_destroy)();	/* destroy this structure */
223*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
224*7c478bd9Sstevel@tonic-gate 		int	(*ah_wrap)();		/* encode XDR data */
225*7c478bd9Sstevel@tonic-gate 		int	(*ah_unwrap)();		/* decode XDR data */
226*7c478bd9Sstevel@tonic-gate #endif
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate #endif
229*7c478bd9Sstevel@tonic-gate 	} *ah_ops;
230*7c478bd9Sstevel@tonic-gate 	caddr_t ah_private;
231*7c478bd9Sstevel@tonic-gate } AUTH;
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate 
234*7c478bd9Sstevel@tonic-gate /*
235*7c478bd9Sstevel@tonic-gate  * Authentication ops.
236*7c478bd9Sstevel@tonic-gate  * The ops and the auth handle provide the interface to the authenticators.
237*7c478bd9Sstevel@tonic-gate  *
238*7c478bd9Sstevel@tonic-gate  * AUTH	*auth;
239*7c478bd9Sstevel@tonic-gate  * XDR	*xdrs;
240*7c478bd9Sstevel@tonic-gate  * struct opaque_auth verf;
241*7c478bd9Sstevel@tonic-gate  */
242*7c478bd9Sstevel@tonic-gate #define	AUTH_NEXTVERF(auth)		\
243*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_nextverf))(auth))
244*7c478bd9Sstevel@tonic-gate #define	auth_nextverf(auth)		\
245*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_nextverf))(auth))
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate 
248*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
249*7c478bd9Sstevel@tonic-gate #define	AUTH_MARSHALL(auth, xdrs, cred)	\
250*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_marshal))(auth, xdrs, cred))
251*7c478bd9Sstevel@tonic-gate #define	auth_marshall(auth, xdrs, cred)	\
252*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_marshal))(auth, xdrs, cred))
253*7c478bd9Sstevel@tonic-gate #else
254*7c478bd9Sstevel@tonic-gate #define	AUTH_MARSHALL(auth, xdrs)	\
255*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
256*7c478bd9Sstevel@tonic-gate #define	auth_marshall(auth, xdrs)	\
257*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
258*7c478bd9Sstevel@tonic-gate #endif
259*7c478bd9Sstevel@tonic-gate 
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate #define	AUTH_VALIDATE(auth, verfp)	\
262*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_validate))((auth), verfp))
263*7c478bd9Sstevel@tonic-gate #define	auth_validate(auth, verfp)	\
264*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_validate))((auth), verfp))
265*7c478bd9Sstevel@tonic-gate 
266*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
267*7c478bd9Sstevel@tonic-gate #define	AUTH_REFRESH(auth, msg, cr)		\
268*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_refresh))(auth, msg, cr))
269*7c478bd9Sstevel@tonic-gate #define	auth_refresh(auth, msg, cr)		\
270*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_refresh))(auth, msg, cr))
271*7c478bd9Sstevel@tonic-gate #else
272*7c478bd9Sstevel@tonic-gate #define	AUTH_REFRESH(auth, msg)		\
273*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_refresh))(auth, msg))
274*7c478bd9Sstevel@tonic-gate #define	auth_refresh(auth, msg)		\
275*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_refresh))(auth, msg))
276*7c478bd9Sstevel@tonic-gate #endif
277*7c478bd9Sstevel@tonic-gate 
278*7c478bd9Sstevel@tonic-gate #define	AUTH_DESTROY(auth)		\
279*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_destroy))(auth))
280*7c478bd9Sstevel@tonic-gate #define	auth_destroy(auth)		\
281*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_destroy))(auth))
282*7c478bd9Sstevel@tonic-gate 
283*7c478bd9Sstevel@tonic-gate /*
284*7c478bd9Sstevel@tonic-gate  * Auth flavors can now apply a transformation in addition to simple XDR
285*7c478bd9Sstevel@tonic-gate  * on the body of a call/response in ways that depend on the flavor being
286*7c478bd9Sstevel@tonic-gate  * used.  These interfaces provide a generic interface between the
287*7c478bd9Sstevel@tonic-gate  * internal RPC frame and the auth flavor specific code to allow the
288*7c478bd9Sstevel@tonic-gate  * auth flavor to encode (WRAP) or decode (UNWRAP) the body.
289*7c478bd9Sstevel@tonic-gate  */
290*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
291*7c478bd9Sstevel@tonic-gate #define	AUTH_WRAP(auth, buf, buflen, xdrs, xfunc, xwhere)	\
292*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_wrap))(auth, buf, buflen, \
293*7c478bd9Sstevel@tonic-gate 				xdrs, xfunc, xwhere))
294*7c478bd9Sstevel@tonic-gate #define	auth_wrap(auth, buf, buflen, xdrs, xfunc, xwhere)	\
295*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_wrap))(auth, buf, buflen, \
296*7c478bd9Sstevel@tonic-gate 				xdrs, xfunc, xwhere))
297*7c478bd9Sstevel@tonic-gate 
298*7c478bd9Sstevel@tonic-gate #define	AUTH_UNWRAP(auth, xdrs, xfunc, xwhere)	\
299*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, xfunc, xwhere))
300*7c478bd9Sstevel@tonic-gate #define	auth_unwrap(auth, xdrs)	\
301*7c478bd9Sstevel@tonic-gate 		((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, xfunc, xwhere))
302*7c478bd9Sstevel@tonic-gate #endif
303*7c478bd9Sstevel@tonic-gate 
304*7c478bd9Sstevel@tonic-gate extern struct opaque_auth _null_auth;
305*7c478bd9Sstevel@tonic-gate 
306*7c478bd9Sstevel@tonic-gate /*
307*7c478bd9Sstevel@tonic-gate  * These are the various implementations of client side authenticators.
308*7c478bd9Sstevel@tonic-gate  */
309*7c478bd9Sstevel@tonic-gate 
310*7c478bd9Sstevel@tonic-gate /*
311*7c478bd9Sstevel@tonic-gate  * System style authentication
312*7c478bd9Sstevel@tonic-gate  * AUTH *authsys_create(machname, uid, gid, len, aup_gids)
313*7c478bd9Sstevel@tonic-gate  *	const char *machname;
314*7c478bd9Sstevel@tonic-gate  *	const uid_t uid;
315*7c478bd9Sstevel@tonic-gate  *	const gid_t gid;
316*7c478bd9Sstevel@tonic-gate  *	const int len;
317*7c478bd9Sstevel@tonic-gate  *	const gid_t *aup_gids;
318*7c478bd9Sstevel@tonic-gate  */
319*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
320*7c478bd9Sstevel@tonic-gate extern AUTH *authkern_create(void);		/* takes no parameters */
321*7c478bd9Sstevel@tonic-gate extern int authkern_init(void *, void *, int);
322*7c478bd9Sstevel@tonic-gate extern struct kmem_cache *authkern_cache;
323*7c478bd9Sstevel@tonic-gate extern AUTH *authloopback_create(void);		/* takes no parameters */
324*7c478bd9Sstevel@tonic-gate extern int authloopback_init(void *, void *, int);
325*7c478bd9Sstevel@tonic-gate extern struct kmem_cache *authloopback_cache;
326*7c478bd9Sstevel@tonic-gate #else /* _KERNEL */
327*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
328*7c478bd9Sstevel@tonic-gate extern AUTH *authsys_create(const char *, const uid_t, const gid_t, const int,
329*7c478bd9Sstevel@tonic-gate     const gid_t *);
330*7c478bd9Sstevel@tonic-gate extern AUTH *authsys_create_default(void);	/* takes no parameters */
331*7c478bd9Sstevel@tonic-gate extern AUTH *authnone_create(void);		/* takes no parameters */
332*7c478bd9Sstevel@tonic-gate #else /* __STDC__ */
333*7c478bd9Sstevel@tonic-gate extern AUTH *authsys_create();
334*7c478bd9Sstevel@tonic-gate extern AUTH *authsys_create_default();	/* takes no parameters */
335*7c478bd9Sstevel@tonic-gate extern AUTH *authnone_create();	/* takes no parameters */
336*7c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
337*7c478bd9Sstevel@tonic-gate /* Will get obsolete in near future */
338*7c478bd9Sstevel@tonic-gate #define	authunix_create		authsys_create
339*7c478bd9Sstevel@tonic-gate #define	authunix_create_default authsys_create_default
340*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
341*7c478bd9Sstevel@tonic-gate 
342*7c478bd9Sstevel@tonic-gate /*
343*7c478bd9Sstevel@tonic-gate  * DES style authentication
344*7c478bd9Sstevel@tonic-gate  * AUTH *authdes_seccreate(servername, window, timehost, ckey)
345*7c478bd9Sstevel@tonic-gate  *	const char *servername;		- network name of server
346*7c478bd9Sstevel@tonic-gate  *	const uint_t window;			- time to live
347*7c478bd9Sstevel@tonic-gate  *	const char *timehost;			- optional hostname to sync with
348*7c478bd9Sstevel@tonic-gate  *	const des_block *ckey;		- optional conversation key to use
349*7c478bd9Sstevel@tonic-gate  */
350*7c478bd9Sstevel@tonic-gate /* Will get obsolete in near future */
351*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
352*7c478bd9Sstevel@tonic-gate extern int authdes_create(char *, uint_t, struct netbuf *, struct knetconfig *,
353*7c478bd9Sstevel@tonic-gate     des_block *, int, AUTH **retauth);
354*7c478bd9Sstevel@tonic-gate #else /* _KERNEL */
355*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
356*7c478bd9Sstevel@tonic-gate extern AUTH *authdes_seccreate(const char *, const uint_t, const  char *,
357*7c478bd9Sstevel@tonic-gate     const des_block *);
358*7c478bd9Sstevel@tonic-gate #else
359*7c478bd9Sstevel@tonic-gate extern AUTH *authdes_seccreate();
360*7c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
361*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
362*7c478bd9Sstevel@tonic-gate 
363*7c478bd9Sstevel@tonic-gate /*
364*7c478bd9Sstevel@tonic-gate  *  Netname manipulating functions
365*7c478bd9Sstevel@tonic-gate  */
366*7c478bd9Sstevel@tonic-gate 
367*7c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
368*7c478bd9Sstevel@tonic-gate extern enum clnt_stat netname2user(char *, uid_t *, gid_t *, int *, int *);
369*7c478bd9Sstevel@tonic-gate #endif
370*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
371*7c478bd9Sstevel@tonic-gate extern int getnetname(char *);
372*7c478bd9Sstevel@tonic-gate extern int host2netname(char *, const char *, const char *);
373*7c478bd9Sstevel@tonic-gate extern int user2netname(char *, const uid_t, const char *);
374*7c478bd9Sstevel@tonic-gate #ifndef	_KERNEL
375*7c478bd9Sstevel@tonic-gate extern int netname2user(const char *, uid_t *, gid_t *, int *, gid_t *);
376*7c478bd9Sstevel@tonic-gate #endif
377*7c478bd9Sstevel@tonic-gate extern int netname2host(const char *, char *, const int);
378*7c478bd9Sstevel@tonic-gate #else
379*7c478bd9Sstevel@tonic-gate extern int getnetname();
380*7c478bd9Sstevel@tonic-gate extern int host2netname();
381*7c478bd9Sstevel@tonic-gate extern int user2netname();
382*7c478bd9Sstevel@tonic-gate extern int netname2host();
383*7c478bd9Sstevel@tonic-gate #endif
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate /*
386*7c478bd9Sstevel@tonic-gate  * These routines interface to the keyserv daemon
387*7c478bd9Sstevel@tonic-gate  */
388*7c478bd9Sstevel@tonic-gate 
389*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
390*7c478bd9Sstevel@tonic-gate extern enum clnt_stat key_decryptsession();
391*7c478bd9Sstevel@tonic-gate extern enum clnt_stat key_encryptsession();
392*7c478bd9Sstevel@tonic-gate extern enum clnt_stat key_gendes();
393*7c478bd9Sstevel@tonic-gate extern enum clnt_stat key_getnetname();
394*7c478bd9Sstevel@tonic-gate #endif
395*7c478bd9Sstevel@tonic-gate 
396*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL
397*7c478bd9Sstevel@tonic-gate #ifdef	__STDC__
398*7c478bd9Sstevel@tonic-gate extern int key_decryptsession(const char *, des_block *);
399*7c478bd9Sstevel@tonic-gate extern int key_encryptsession(const char *, des_block *);
400*7c478bd9Sstevel@tonic-gate extern int key_gendes(des_block *);
401*7c478bd9Sstevel@tonic-gate extern int key_setsecret(const char *);
402*7c478bd9Sstevel@tonic-gate extern int key_secretkey_is_set(void);
403*7c478bd9Sstevel@tonic-gate /*
404*7c478bd9Sstevel@tonic-gate  * The following routines are private.
405*7c478bd9Sstevel@tonic-gate  */
406*7c478bd9Sstevel@tonic-gate extern int key_setnet_ruid();
407*7c478bd9Sstevel@tonic-gate extern int key_setnet_g_ruid();
408*7c478bd9Sstevel@tonic-gate extern int key_removesecret_g_ruid();
409*7c478bd9Sstevel@tonic-gate extern int key_secretkey_is_set_g_ruid();
410*7c478bd9Sstevel@tonic-gate extern AUTH *authsys_create_ruid();
411*7c478bd9Sstevel@tonic-gate #else
412*7c478bd9Sstevel@tonic-gate extern int key_decryptsession();
413*7c478bd9Sstevel@tonic-gate extern int key_encryptsession();
414*7c478bd9Sstevel@tonic-gate extern int key_gendes();
415*7c478bd9Sstevel@tonic-gate extern int key_setsecret();
416*7c478bd9Sstevel@tonic-gate extern int key_secretkey_is_set();
417*7c478bd9Sstevel@tonic-gate #endif
418*7c478bd9Sstevel@tonic-gate #endif
419*7c478bd9Sstevel@tonic-gate 
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate /*
422*7c478bd9Sstevel@tonic-gate  * Kerberos style authentication
423*7c478bd9Sstevel@tonic-gate  * AUTH *authkerb_seccreate(service, srv_inst, realm, window, timehost, status)
424*7c478bd9Sstevel@tonic-gate  *	const char *service;			- service name
425*7c478bd9Sstevel@tonic-gate  *	const char *srv_inst;			- server instance
426*7c478bd9Sstevel@tonic-gate  *	const char *realm;			- server realm
427*7c478bd9Sstevel@tonic-gate  *	const uint_t window;			- time to live
428*7c478bd9Sstevel@tonic-gate  *	const char *timehost;			- optional hostname to sync with
429*7c478bd9Sstevel@tonic-gate  *	int *status;			- kerberos status returned
430*7c478bd9Sstevel@tonic-gate  */
431*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
432*7c478bd9Sstevel@tonic-gate extern int    authkerb_create(char *, char *, char *, uint_t,
433*7c478bd9Sstevel@tonic-gate     struct netbuf *, int *, struct knetconfig *, int, AUTH **);
434*7c478bd9Sstevel@tonic-gate #else
435*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
436*7c478bd9Sstevel@tonic-gate extern AUTH *authkerb_seccreate(const char *, const char *, const  char *,
437*7c478bd9Sstevel@tonic-gate     const uint_t, const char *, int *);
438*7c478bd9Sstevel@tonic-gate #else
439*7c478bd9Sstevel@tonic-gate extern AUTH *authkerb_seccreate();
440*7c478bd9Sstevel@tonic-gate #endif
441*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
442*7c478bd9Sstevel@tonic-gate 
443*7c478bd9Sstevel@tonic-gate /*
444*7c478bd9Sstevel@tonic-gate  * Map a kerberos credential into a unix cred.
445*7c478bd9Sstevel@tonic-gate  *
446*7c478bd9Sstevel@tonic-gate  *  authkerb_getucred(rqst, uid, gid, grouplen, groups)
447*7c478bd9Sstevel@tonic-gate  *	const struct svc_req *rqst;		- request pointer
448*7c478bd9Sstevel@tonic-gate  *	uid_t *uid;
449*7c478bd9Sstevel@tonic-gate  *	gid_t *gid;
450*7c478bd9Sstevel@tonic-gate  *	short *grouplen;
451*7c478bd9Sstevel@tonic-gate  *	int   *groups;
452*7c478bd9Sstevel@tonic-gate  *
453*7c478bd9Sstevel@tonic-gate  */
454*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
455*7c478bd9Sstevel@tonic-gate struct svc_req;
456*7c478bd9Sstevel@tonic-gate extern int authkerb_getucred(struct svc_req *, uid_t *, gid_t *,
457*7c478bd9Sstevel@tonic-gate     short *, int *);
458*7c478bd9Sstevel@tonic-gate #else
459*7c478bd9Sstevel@tonic-gate extern int authkerb_getucred();
460*7c478bd9Sstevel@tonic-gate #endif
461*7c478bd9Sstevel@tonic-gate 
462*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
463*7c478bd9Sstevel@tonic-gate /*
464*7c478bd9Sstevel@tonic-gate  * XDR an opaque authentication struct.  See auth.h.
465*7c478bd9Sstevel@tonic-gate  */
466*7c478bd9Sstevel@tonic-gate extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *);
467*7c478bd9Sstevel@tonic-gate #endif
468*7c478bd9Sstevel@tonic-gate 
469*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
470*7c478bd9Sstevel@tonic-gate extern int authany_wrap(AUTH *, caddr_t, uint_t, XDR *, xdrproc_t, caddr_t);
471*7c478bd9Sstevel@tonic-gate extern int authany_unwrap(AUTH *, XDR *, xdrproc_t, caddr_t);
472*7c478bd9Sstevel@tonic-gate #endif
473*7c478bd9Sstevel@tonic-gate 
474*7c478bd9Sstevel@tonic-gate #define	AUTH_NONE	0		/* no authentication */
475*7c478bd9Sstevel@tonic-gate #define	AUTH_NULL	0		/* backward compatibility */
476*7c478bd9Sstevel@tonic-gate #define	AUTH_SYS	1		/* unix style (uid, gids) */
477*7c478bd9Sstevel@tonic-gate #define	AUTH_UNIX	AUTH_SYS
478*7c478bd9Sstevel@tonic-gate #define	AUTH_SHORT	2		/* short hand unix style */
479*7c478bd9Sstevel@tonic-gate #define	AUTH_DH		3		/* for Diffie-Hellman mechanism */
480*7c478bd9Sstevel@tonic-gate #define	AUTH_DES	AUTH_DH		/* for backward compatibility */
481*7c478bd9Sstevel@tonic-gate #define	AUTH_KERB	4		/* kerberos style */
482*7c478bd9Sstevel@tonic-gate #define	RPCSEC_GSS	6		/* GSS-API style */
483*7c478bd9Sstevel@tonic-gate 
484*7c478bd9Sstevel@tonic-gate #define	AUTH_LOOPBACK	21982		/* unix style w/ expanded groups */
485*7c478bd9Sstevel@tonic-gate 					/* for use over the local transport */
486*7c478bd9Sstevel@tonic-gate 
487*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
488*7c478bd9Sstevel@tonic-gate extern char	loopback_name[];
489*7c478bd9Sstevel@tonic-gate 
490*7c478bd9Sstevel@tonic-gate extern zone_key_t	auth_zone_key;
491*7c478bd9Sstevel@tonic-gate extern void *		auth_zone_init(zoneid_t);
492*7c478bd9Sstevel@tonic-gate extern void		auth_zone_fini(zoneid_t, void *);
493*7c478bd9Sstevel@tonic-gate #endif
494*7c478bd9Sstevel@tonic-gate 
495*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
496*7c478bd9Sstevel@tonic-gate }
497*7c478bd9Sstevel@tonic-gate #endif
498*7c478bd9Sstevel@tonic-gate 
499*7c478bd9Sstevel@tonic-gate #endif	/* !_RPC_AUTH_H */
500