Path: blob/main/crypto/krb5/src/lib/rpc/auth_none.c
39536 views
/* @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC */1/*2* Copyright (c) 2010, Oracle America, Inc.3*4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions are met:8*9* * Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11*12* * Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in14* the documentation and/or other materials provided with the15* distribution.16*17* * Neither the name of the "Oracle America, Inc." nor the names of18* its contributors may be used to endorse or promote products19* derived from this software without specific prior written permission.20*21* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS22* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED23* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A24* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT25* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,26* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED27* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR28* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF29* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING30* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS31* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.32*/33#if !defined(lint) && defined(SCCSIDS)34static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";35#endif3637/*38* auth_none.c39* Creates a client authentication handle for passing "null"40* credentials and verifiers to remote systems.41*/4243#include <gssrpc/types.h>44#include <gssrpc/xdr.h>45#include <gssrpc/auth.h>46#include <stdlib.h>47#define MAX_MARSHEL_SIZE 204849/*50* Authenticator operations routines51*/52static void authnone_verf(AUTH *);53static void authnone_destroy(AUTH *);54static bool_t authnone_marshal(AUTH *, XDR *);55static bool_t authnone_validate(AUTH *, struct opaque_auth *);56static bool_t authnone_refresh(AUTH *, struct rpc_msg *);57static bool_t authnone_wrap(AUTH *, XDR *, xdrproc_t, caddr_t);5859static struct auth_ops ops = {60authnone_verf,61authnone_marshal,62authnone_validate,63authnone_refresh,64authnone_destroy,65authnone_wrap,66authnone_wrap67};6869static struct authnone_private {70AUTH no_client;71char marshalled_client[MAX_MARSHEL_SIZE];72u_int mcnt;73} *authnone_private;7475AUTH *76authnone_create(void)77{78struct authnone_private *ap = authnone_private;79XDR xdr_stream;80XDR *xdrs;8182if (ap == 0) {83ap = (struct authnone_private *)calloc(1, sizeof (*ap));84if (ap == 0)85return (0);86authnone_private = ap;87}88if (!ap->mcnt) {89ap->no_client.ah_cred = ap->no_client.ah_verf = gssrpc__null_auth;90ap->no_client.ah_ops = &ops;91xdrs = &xdr_stream;92xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE,93XDR_ENCODE);94(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);95(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);96ap->mcnt = XDR_GETPOS(xdrs);97XDR_DESTROY(xdrs);98}99return (&ap->no_client);100}101102/*ARGSUSED*/103static bool_t104authnone_marshal(AUTH *client, XDR *xdrs)105{106struct authnone_private *ap = authnone_private;107108if (ap == 0)109return (0);110return ((*xdrs->x_ops->x_putbytes)(xdrs,111ap->marshalled_client, ap->mcnt));112}113114/*ARGSUSED*/115static void116authnone_verf(AUTH *auth)117{118}119120/*ARGSUSED*/121static bool_t122authnone_validate(AUTH *auth, struct opaque_auth *verf)123{124125return (TRUE);126}127128/*ARGSUSED*/129static bool_t130authnone_refresh(AUTH *auth, struct rpc_msg *msg)131{132133return (FALSE);134}135136/*ARGSUSED*/137static void138authnone_destroy(AUTH *auth)139{140}141142static bool_t143authnone_wrap(AUTH *auth, XDR *xdrs, xdrproc_t xfunc, caddr_t xwhere)144{145return ((*xfunc)(xdrs, xwhere));146}147148149