d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy/*
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * CDDL HEADER START
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy *
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * The contents of this file are subject to the terms of the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * Common Development and Distribution License (the "License").
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * You may not use this file except in compliance with the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy *
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * or http://www.opensolaris.org/os/licensing.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * See the License for the specific language governing permissions
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * and limitations under the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy *
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * When distributing Covered Code, include this CDDL HEADER in each
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * If applicable, add the following below this CDDL HEADER, with the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * fields enclosed by brackets "[]" replaced with your own identifying
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * information: Portions Copyright [yyyy] [name of copyright owner]
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy *
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * CDDL HEADER END
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy/*
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * Use is subject to license terms.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy/*
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * auth_none.c implements routines used to pass "null" credentials
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * and "null" verifiers in kernel RPC.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#include <rpc/auth.h>
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy/*
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * Null authenticator operations vector
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedystatic void authnone_nextverf(AUTH *);
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedystatic bool_t authnone_marshal(AUTH *, XDR *, struct cred *);
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedystatic bool_t authnone_validate(AUTH *, struct opaque_auth *);
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedystatic bool_t authnone_refresh(AUTH *, struct rpc_msg *, cred_t *);
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedystatic void authnone_destroy(AUTH *);
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedystatic struct auth_ops auth_none_ops = {
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy authnone_nextverf,
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy authnone_marshal,
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy authnone_validate,
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy authnone_refresh,
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy authnone_destroy,
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy authany_wrap,
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy authany_unwrap
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy};
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy/*
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * Create a kernel null style authenticator.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * Returns an auth handle.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren KennedyAUTH *
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyauthnone_create(void)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy{
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy /*
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * Allocate and set up auth handle
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy return (kmem_cache_alloc(authnone_cache, KM_SLEEP));
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy}
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy/*
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * The constructor of the authnone_cache.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy/* ARGSUSED */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyint
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyauthnone_init(void *buf, void *cdrarg, int kmflags)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy{
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy AUTH *auth = (AUTH *)buf;
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy auth->ah_ops = &auth_none_ops;
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy /*
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * Flavor of RPC message's credential and verifier should be set to
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * AUTH_NONE. Opaque data associated with AUTH_NONE is undefined.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * The length of the opaque data should be zero.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * oa_flavor = AUTH_NONE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * oa_base = NULL
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy * oa_length = 0
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy */
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy auth->ah_cred = auth->ah_verf = _null_auth;
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy return (0);
}
/*
* authnone operations
*/
/* ARGSUSED */
static void
authnone_nextverf(AUTH *auth)
{
/* no action necessary */
}
/* ARGSUSED */
static bool_t
authnone_marshal(AUTH *auth, XDR *xdrs, struct cred *cr)
{
int32_t *ptr;
/*
* auth_none has no opaque data. Encode auth_none
* value with 0 len data for both cred and verf.
* We first try a fast path to complete this operation.
*/
ptr = XDR_INLINE(xdrs, 4 + 4 + 4 + 4);
if (ptr) {
IXDR_PUT_INT32(ptr, AUTH_NONE);
IXDR_PUT_INT32(ptr, 0);
IXDR_PUT_INT32(ptr, AUTH_NONE);
IXDR_PUT_INT32(ptr, 0);
return (TRUE);
}
/*
* serialize AUTH_NONE credential and AUTH_NONE verifier
*/
if ((xdr_opaque_auth(xdrs, &(auth->ah_cred))) &&
(xdr_opaque_auth(xdrs, &(auth->ah_verf))))
return (TRUE);
else
return (FALSE);
}
/* ARGSUSED */
static bool_t
authnone_validate(AUTH *auth, struct opaque_auth *verf)
{
return (TRUE);
}
/* ARGSUSED */
static bool_t
authnone_refresh(AUTH *auth, struct rpc_msg *msg, cred_t *cr)
{
return (FALSE);
}
static void
authnone_destroy(AUTH *auth)
{
kmem_cache_free(authnone_cache, auth);
}