Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / uts / common / rpc / sec / auth_none.c
blob584a1a050e70bc2bd6510e01c07c69e84c7a4208
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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.
32 #include <rpc/auth.h>
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 = {
44 authnone_nextverf,
45 authnone_marshal,
46 authnone_validate,
47 authnone_refresh,
48 authnone_destroy,
49 authany_wrap,
50 authany_unwrap
54 * Create a kernel null style authenticator.
55 * Returns an auth handle.
57 AUTH *
58 authnone_create(void)
61 * Allocate and set up auth handle
63 return (kmem_cache_alloc(authnone_cache, KM_SLEEP));
67 * The constructor of the authnone_cache.
69 /* ARGSUSED */
70 int
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
82 * oa_base = NULL
83 * oa_length = 0
85 auth->ah_cred = auth->ah_verf = _null_auth;
87 return (0);
91 * authnone operations
93 /* ARGSUSED */
94 static void
95 authnone_nextverf(AUTH *auth)
97 /* no action necessary */
100 /* ARGSUSED */
101 static bool_t
102 authnone_marshal(AUTH *auth, XDR *xdrs, struct cred *cr)
104 int32_t *ptr;
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);
112 if (ptr) {
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);
117 return (TRUE);
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))))
125 return (TRUE);
126 else
127 return (FALSE);
130 /* ARGSUSED */
131 static bool_t
132 authnone_validate(AUTH *auth, struct opaque_auth *verf)
134 return (TRUE);
137 /* ARGSUSED */
138 static bool_t
139 authnone_refresh(AUTH *auth, struct rpc_msg *msg, cred_t *cr)
141 return (FALSE);
144 static void
145 authnone_destroy(AUTH *auth)
147 kmem_cache_free(authnone_cache, auth);