1*33f285aeSVallish Vaidyeshwara /*
2*33f285aeSVallish Vaidyeshwara * CDDL HEADER START
3*33f285aeSVallish Vaidyeshwara *
4*33f285aeSVallish Vaidyeshwara * The contents of this file are subject to the terms of the
5*33f285aeSVallish Vaidyeshwara * Common Development and Distribution License (the "License").
6*33f285aeSVallish Vaidyeshwara * You may not use this file except in compliance with the License.
7*33f285aeSVallish Vaidyeshwara *
8*33f285aeSVallish Vaidyeshwara * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*33f285aeSVallish Vaidyeshwara * or http://www.opensolaris.org/os/licensing.
10*33f285aeSVallish Vaidyeshwara * See the License for the specific language governing permissions
11*33f285aeSVallish Vaidyeshwara * and limitations under the License.
12*33f285aeSVallish Vaidyeshwara *
13*33f285aeSVallish Vaidyeshwara * When distributing Covered Code, include this CDDL HEADER in each
14*33f285aeSVallish Vaidyeshwara * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*33f285aeSVallish Vaidyeshwara * If applicable, add the following below this CDDL HEADER, with the
16*33f285aeSVallish Vaidyeshwara * fields enclosed by brackets "[]" replaced with your own identifying
17*33f285aeSVallish Vaidyeshwara * information: Portions Copyright [yyyy] [name of copyright owner]
18*33f285aeSVallish Vaidyeshwara *
19*33f285aeSVallish Vaidyeshwara * CDDL HEADER END
20*33f285aeSVallish Vaidyeshwara */
21*33f285aeSVallish Vaidyeshwara
22*33f285aeSVallish Vaidyeshwara /*
23*33f285aeSVallish Vaidyeshwara * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24*33f285aeSVallish Vaidyeshwara * Use is subject to license terms.
25*33f285aeSVallish Vaidyeshwara */
26*33f285aeSVallish Vaidyeshwara
27*33f285aeSVallish Vaidyeshwara /*
28*33f285aeSVallish Vaidyeshwara * auth_none.c implements routines used to pass "null" credentials
29*33f285aeSVallish Vaidyeshwara * and "null" verifiers in kernel RPC.
30*33f285aeSVallish Vaidyeshwara */
31*33f285aeSVallish Vaidyeshwara
32*33f285aeSVallish Vaidyeshwara #include <rpc/auth.h>
33*33f285aeSVallish Vaidyeshwara
34*33f285aeSVallish Vaidyeshwara /*
35*33f285aeSVallish Vaidyeshwara * Null authenticator operations vector
36*33f285aeSVallish Vaidyeshwara */
37*33f285aeSVallish Vaidyeshwara static void authnone_nextverf(AUTH *);
38*33f285aeSVallish Vaidyeshwara static bool_t authnone_marshal(AUTH *, XDR *, struct cred *);
39*33f285aeSVallish Vaidyeshwara static bool_t authnone_validate(AUTH *, struct opaque_auth *);
40*33f285aeSVallish Vaidyeshwara static bool_t authnone_refresh(AUTH *, struct rpc_msg *, cred_t *);
41*33f285aeSVallish Vaidyeshwara static void authnone_destroy(AUTH *);
42*33f285aeSVallish Vaidyeshwara
43*33f285aeSVallish Vaidyeshwara static struct auth_ops auth_none_ops = {
44*33f285aeSVallish Vaidyeshwara authnone_nextverf,
45*33f285aeSVallish Vaidyeshwara authnone_marshal,
46*33f285aeSVallish Vaidyeshwara authnone_validate,
47*33f285aeSVallish Vaidyeshwara authnone_refresh,
48*33f285aeSVallish Vaidyeshwara authnone_destroy,
49*33f285aeSVallish Vaidyeshwara authany_wrap,
50*33f285aeSVallish Vaidyeshwara authany_unwrap
51*33f285aeSVallish Vaidyeshwara };
52*33f285aeSVallish Vaidyeshwara
53*33f285aeSVallish Vaidyeshwara /*
54*33f285aeSVallish Vaidyeshwara * Create a kernel null style authenticator.
55*33f285aeSVallish Vaidyeshwara * Returns an auth handle.
56*33f285aeSVallish Vaidyeshwara */
57*33f285aeSVallish Vaidyeshwara AUTH *
authnone_create(void)58*33f285aeSVallish Vaidyeshwara authnone_create(void)
59*33f285aeSVallish Vaidyeshwara {
60*33f285aeSVallish Vaidyeshwara /*
61*33f285aeSVallish Vaidyeshwara * Allocate and set up auth handle
62*33f285aeSVallish Vaidyeshwara */
63*33f285aeSVallish Vaidyeshwara return (kmem_cache_alloc(authnone_cache, KM_SLEEP));
64*33f285aeSVallish Vaidyeshwara }
65*33f285aeSVallish Vaidyeshwara
66*33f285aeSVallish Vaidyeshwara /*
67*33f285aeSVallish Vaidyeshwara * The constructor of the authnone_cache.
68*33f285aeSVallish Vaidyeshwara */
69*33f285aeSVallish Vaidyeshwara /* ARGSUSED */
70*33f285aeSVallish Vaidyeshwara int
authnone_init(void * buf,void * cdrarg,int kmflags)71*33f285aeSVallish Vaidyeshwara authnone_init(void *buf, void *cdrarg, int kmflags)
72*33f285aeSVallish Vaidyeshwara {
73*33f285aeSVallish Vaidyeshwara AUTH *auth = (AUTH *)buf;
74*33f285aeSVallish Vaidyeshwara
75*33f285aeSVallish Vaidyeshwara auth->ah_ops = &auth_none_ops;
76*33f285aeSVallish Vaidyeshwara
77*33f285aeSVallish Vaidyeshwara /*
78*33f285aeSVallish Vaidyeshwara * Flavor of RPC message's credential and verifier should be set to
79*33f285aeSVallish Vaidyeshwara * AUTH_NONE. Opaque data associated with AUTH_NONE is undefined.
80*33f285aeSVallish Vaidyeshwara * The length of the opaque data should be zero.
81*33f285aeSVallish Vaidyeshwara * oa_flavor = AUTH_NONE
82*33f285aeSVallish Vaidyeshwara * oa_base = NULL
83*33f285aeSVallish Vaidyeshwara * oa_length = 0
84*33f285aeSVallish Vaidyeshwara */
85*33f285aeSVallish Vaidyeshwara auth->ah_cred = auth->ah_verf = _null_auth;
86*33f285aeSVallish Vaidyeshwara
87*33f285aeSVallish Vaidyeshwara return (0);
88*33f285aeSVallish Vaidyeshwara }
89*33f285aeSVallish Vaidyeshwara
90*33f285aeSVallish Vaidyeshwara /*
91*33f285aeSVallish Vaidyeshwara * authnone operations
92*33f285aeSVallish Vaidyeshwara */
93*33f285aeSVallish Vaidyeshwara /* ARGSUSED */
94*33f285aeSVallish Vaidyeshwara static void
authnone_nextverf(AUTH * auth)95*33f285aeSVallish Vaidyeshwara authnone_nextverf(AUTH *auth)
96*33f285aeSVallish Vaidyeshwara {
97*33f285aeSVallish Vaidyeshwara /* no action necessary */
98*33f285aeSVallish Vaidyeshwara }
99*33f285aeSVallish Vaidyeshwara
100*33f285aeSVallish Vaidyeshwara /* ARGSUSED */
101*33f285aeSVallish Vaidyeshwara static bool_t
authnone_marshal(AUTH * auth,XDR * xdrs,struct cred * cr)102*33f285aeSVallish Vaidyeshwara authnone_marshal(AUTH *auth, XDR *xdrs, struct cred *cr)
103*33f285aeSVallish Vaidyeshwara {
104*33f285aeSVallish Vaidyeshwara int32_t *ptr;
105*33f285aeSVallish Vaidyeshwara
106*33f285aeSVallish Vaidyeshwara /*
107*33f285aeSVallish Vaidyeshwara * auth_none has no opaque data. Encode auth_none
108*33f285aeSVallish Vaidyeshwara * value with 0 len data for both cred and verf.
109*33f285aeSVallish Vaidyeshwara * We first try a fast path to complete this operation.
110*33f285aeSVallish Vaidyeshwara */
111*33f285aeSVallish Vaidyeshwara ptr = XDR_INLINE(xdrs, 4 + 4 + 4 + 4);
112*33f285aeSVallish Vaidyeshwara if (ptr) {
113*33f285aeSVallish Vaidyeshwara IXDR_PUT_INT32(ptr, AUTH_NONE);
114*33f285aeSVallish Vaidyeshwara IXDR_PUT_INT32(ptr, 0);
115*33f285aeSVallish Vaidyeshwara IXDR_PUT_INT32(ptr, AUTH_NONE);
116*33f285aeSVallish Vaidyeshwara IXDR_PUT_INT32(ptr, 0);
117*33f285aeSVallish Vaidyeshwara return (TRUE);
118*33f285aeSVallish Vaidyeshwara }
119*33f285aeSVallish Vaidyeshwara
120*33f285aeSVallish Vaidyeshwara /*
121*33f285aeSVallish Vaidyeshwara * serialize AUTH_NONE credential and AUTH_NONE verifier
122*33f285aeSVallish Vaidyeshwara */
123*33f285aeSVallish Vaidyeshwara if ((xdr_opaque_auth(xdrs, &(auth->ah_cred))) &&
124*33f285aeSVallish Vaidyeshwara (xdr_opaque_auth(xdrs, &(auth->ah_verf))))
125*33f285aeSVallish Vaidyeshwara return (TRUE);
126*33f285aeSVallish Vaidyeshwara else
127*33f285aeSVallish Vaidyeshwara return (FALSE);
128*33f285aeSVallish Vaidyeshwara }
129*33f285aeSVallish Vaidyeshwara
130*33f285aeSVallish Vaidyeshwara /* ARGSUSED */
131*33f285aeSVallish Vaidyeshwara static bool_t
authnone_validate(AUTH * auth,struct opaque_auth * verf)132*33f285aeSVallish Vaidyeshwara authnone_validate(AUTH *auth, struct opaque_auth *verf)
133*33f285aeSVallish Vaidyeshwara {
134*33f285aeSVallish Vaidyeshwara return (TRUE);
135*33f285aeSVallish Vaidyeshwara }
136*33f285aeSVallish Vaidyeshwara
137*33f285aeSVallish Vaidyeshwara /* ARGSUSED */
138*33f285aeSVallish Vaidyeshwara static bool_t
authnone_refresh(AUTH * auth,struct rpc_msg * msg,cred_t * cr)139*33f285aeSVallish Vaidyeshwara authnone_refresh(AUTH *auth, struct rpc_msg *msg, cred_t *cr)
140*33f285aeSVallish Vaidyeshwara {
141*33f285aeSVallish Vaidyeshwara return (FALSE);
142*33f285aeSVallish Vaidyeshwara }
143*33f285aeSVallish Vaidyeshwara
144*33f285aeSVallish Vaidyeshwara static void
authnone_destroy(AUTH * auth)145*33f285aeSVallish Vaidyeshwara authnone_destroy(AUTH *auth)
146*33f285aeSVallish Vaidyeshwara {
147*33f285aeSVallish Vaidyeshwara kmem_cache_free(authnone_cache, auth);
148*33f285aeSVallish Vaidyeshwara }
149