xref: /illumos-gate/usr/src/uts/common/rpc/svc_auth.h (revision 7a6d80f1660abd4755c68cbd094d4a914681d26e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
28 /*
29  * Portions of this source code were derived from Berkeley
30  * 4.3 BSD under license from the Regents of the University of
31  * California.
32  */
33 
34 #ifndef _RPC_SVC_AUTH_H
35 #define	_RPC_SVC_AUTH_H
36 
37 /*
38  * svc_auth.h, Service side of rpc authentication.
39  */
40 #include <rpc/rpcsec_gss.h>
41 #include <rpc/rpc_msg.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /*
48  * Server side authenticator
49  */
50 #ifdef _KERNEL
51 /*
52  * Copy of GSS parameters, needed for MT operation
53  */
54 typedef struct {
55 	bool_t			established;
56 	rpc_gss_service_t	service;
57 	uint_t			qop_rcvd;
58 	void			*context;
59 	uint_t			seq_num;
60 } svc_rpc_gss_parms_t;
61 
62 /*
63  * sec_svc_control() commands
64  */
65 #define	RPC_SVC_SET_GSS_CALLBACK	1  /* set rpcsec_gss callback routine */
66 extern bool_t sec_svc_control();
67 
68 /*
69  * Interface to server-side authentication flavors, may change on
70  * each request.
71  */
72 typedef struct {
73 	struct svc_auth_ops {
74 		int		(*svc_ah_wrap)();
75 		int		(*svc_ah_unwrap)();
76 	} svc_ah_ops;
77 	caddr_t			svc_ah_private;
78 	svc_rpc_gss_parms_t	svc_gss_parms;
79 	rpc_gss_rawcred_t	raw_cred;
80 } SVCAUTH;
81 
82 #define	SVCAUTH_GSSPARMS(auth)  ((svc_rpc_gss_parms_t *)&(auth)->svc_gss_parms)
83 
84 /*
85  * Auth flavors can now apply a transformation in addition to simple XDR
86  * on the body of a call/response in ways that depend on the flavor being
87  * used.  These interfaces provide a generic interface between the
88  * internal RPC frame and the auth flavor specific code to allow the
89  * auth flavor to encode (WRAP) or decode (UNWRAP) the body.
90  */
91 #define	SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere) \
92 	((*((auth)->svc_ah_ops.svc_ah_wrap))(auth, xdrs, xfunc, xwhere))
93 #define	SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \
94 	((*((auth)->svc_ah_ops.svc_ah_unwrap))(auth, xdrs, xfunc, xwhere))
95 
96 /*
97  * Server side authenticator
98  */
99 #ifdef __STDC__
100 extern enum auth_stat sec_svc_msg(struct svc_req *, struct rpc_msg *,
101 				bool_t *);
102 #else
103 extern enum auth_stat sec_svc_msg();
104 #endif /* __STDC__ */
105 
106 #else
107 
108 #ifdef __STDC__
109 extern enum auth_stat __gss_authenticate(struct svc_req *, struct rpc_msg *,
110 				bool_t *);
111 extern enum auth_stat __authenticate(struct svc_req *, struct rpc_msg *);
112 #else
113 extern enum auth_stat __gss_authenticate();
114 extern enum auth_stat __authenticate();
115 #endif /* __STDC__ */
116 
117 #endif /* _KERNEL */
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif	/* _RPC_SVC_AUTH_H */
124