4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * auth_none.c implements routines used to pass "null" credentials
29 * and "null" verifiers in kernel RPC.
35 * Null authenticator operations vector
37 static void authnone_nextverf(AUTH
*);
38 static bool_t
authnone_marshal(AUTH
*, XDR
*, struct cred
*);
39 static bool_t
authnone_validate(AUTH
*, struct opaque_auth
*);
40 static bool_t
authnone_refresh(AUTH
*, struct rpc_msg
*, cred_t
*);
41 static void authnone_destroy(AUTH
*);
43 static struct auth_ops auth_none_ops
= {
54 * Create a kernel null style authenticator.
55 * Returns an auth handle.
61 * Allocate and set up auth handle
63 return (kmem_cache_alloc(authnone_cache
, KM_SLEEP
));
67 * The constructor of the authnone_cache.
71 authnone_init(void *buf
, void *cdrarg
, int kmflags
)
73 AUTH
*auth
= (AUTH
*)buf
;
75 auth
->ah_ops
= &auth_none_ops
;
78 * Flavor of RPC message's credential and verifier should be set to
79 * AUTH_NONE. Opaque data associated with AUTH_NONE is undefined.
80 * The length of the opaque data should be zero.
81 * oa_flavor = AUTH_NONE
85 auth
->ah_cred
= auth
->ah_verf
= _null_auth
;
95 authnone_nextverf(AUTH
*auth
)
97 /* no action necessary */
102 authnone_marshal(AUTH
*auth
, XDR
*xdrs
, struct cred
*cr
)
107 * auth_none has no opaque data. Encode auth_none
108 * value with 0 len data for both cred and verf.
109 * We first try a fast path to complete this operation.
111 ptr
= XDR_INLINE(xdrs
, 4 + 4 + 4 + 4);
113 IXDR_PUT_INT32(ptr
, AUTH_NONE
);
114 IXDR_PUT_INT32(ptr
, 0);
115 IXDR_PUT_INT32(ptr
, AUTH_NONE
);
116 IXDR_PUT_INT32(ptr
, 0);
121 * serialize AUTH_NONE credential and AUTH_NONE verifier
123 if ((xdr_opaque_auth(xdrs
, &(auth
->ah_cred
))) &&
124 (xdr_opaque_auth(xdrs
, &(auth
->ah_verf
))))
132 authnone_validate(AUTH
*auth
, struct opaque_auth
*verf
)
139 authnone_refresh(AUTH
*auth
, struct rpc_msg
*msg
, cred_t
*cr
)
145 authnone_destroy(AUTH
*auth
)
147 kmem_cache_free(authnone_cache
, auth
);