/* $NetBSD: auth_none.c,v 1.13 2000/01/22 22:19:17 mycroft Exp $ */12/*-3* SPDX-License-Identifier: BSD-3-Clause4*5* Copyright (c) 2009, Sun Microsystems, Inc.6* All rights reserved.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions are met:10* - Redistributions of source code must retain the above copyright notice,11* this list of conditions and the following disclaimer.12* - Redistributions in binary form must reproduce the above copyright notice,13* this list of conditions and the following disclaimer in the documentation14* and/or other materials provided with the distribution.15* - Neither the name of Sun Microsystems, Inc. nor the names of its16* contributors may be used to endorse or promote products derived17* from this software without specific prior written permission.18*19* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"20* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE23* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR24* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF25* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS26* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN27* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29* POSSIBILITY OF SUCH DAMAGE.30*/3132#include <sys/cdefs.h>33/*34* auth_none.c35* Creates a client authentication handle for passing "null"36* credentials and verifiers to remote systems.37*38* Copyright (C) 1984, Sun Microsystems, Inc.39*/4041#include <sys/param.h>42#include <sys/systm.h>43#include <sys/kernel.h>44#include <sys/lock.h>45#include <sys/malloc.h>46#include <sys/mutex.h>4748#include <rpc/types.h>49#include <rpc/xdr.h>50#include <rpc/auth.h>51#include <rpc/clnt.h>5253#define MAX_MARSHAL_SIZE 205455/*56* Authenticator operations routines57*/5859static bool_t authnone_marshal (AUTH *, uint32_t, XDR *, struct mbuf *);60static void authnone_verf (AUTH *);61static bool_t authnone_validate (AUTH *, uint32_t, struct opaque_auth *,62struct mbuf **);63static bool_t authnone_refresh (AUTH *, void *);64static void authnone_destroy (AUTH *);6566static const struct auth_ops authnone_ops = {67.ah_nextverf = authnone_verf,68.ah_marshal = authnone_marshal,69.ah_validate = authnone_validate,70.ah_refresh = authnone_refresh,71.ah_destroy = authnone_destroy,72};7374struct authnone_private {75AUTH no_client;76char mclient[MAX_MARSHAL_SIZE];77u_int mcnt;78};7980static struct authnone_private authnone_private;8182static void83authnone_init(void *dummy)84{85struct authnone_private *ap = &authnone_private;86XDR xdrs;8788ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;89ap->no_client.ah_ops = &authnone_ops;90xdrmem_create(&xdrs, ap->mclient, MAX_MARSHAL_SIZE, XDR_ENCODE);91xdr_opaque_auth(&xdrs, &ap->no_client.ah_cred);92xdr_opaque_auth(&xdrs, &ap->no_client.ah_verf);93ap->mcnt = XDR_GETPOS(&xdrs);94XDR_DESTROY(&xdrs);95}96SYSINIT(authnone_init, SI_SUB_KMEM, SI_ORDER_ANY, authnone_init, NULL);9798AUTH *99authnone_create(void)100{101struct authnone_private *ap = &authnone_private;102103return (&ap->no_client);104}105106/*ARGSUSED*/107static bool_t108authnone_marshal(AUTH *client, uint32_t xid, XDR *xdrs, struct mbuf *args)109{110struct authnone_private *ap = &authnone_private;111112KASSERT(xdrs != NULL, ("authnone_marshal: xdrs is null"));113114if (!XDR_PUTBYTES(xdrs, ap->mclient, ap->mcnt))115return (FALSE);116117return (xdr_putmbuf(xdrs, args));118}119120/* All these unused parameters are required to keep ANSI-C from grumbling */121/*ARGSUSED*/122static void123authnone_verf(AUTH *client)124{125}126127/*ARGSUSED*/128static bool_t129authnone_validate(AUTH *client, uint32_t xid, struct opaque_auth *opaque,130struct mbuf **mrepp)131{132133return (TRUE);134}135136/*ARGSUSED*/137static bool_t138authnone_refresh(AUTH *client, void *dummy)139{140141return (FALSE);142}143144/*ARGSUSED*/145static void146authnone_destroy(AUTH *client)147{148}149150151