Blame sunrpc/auth_none.c

Packit 6c4009
/*
Packit 6c4009
 * Copyright (c) 2010, Oracle America, Inc.
Packit 6c4009
 *
Packit 6c4009
 * Redistribution and use in source and binary forms, with or without
Packit 6c4009
 * modification, are permitted provided that the following conditions are
Packit 6c4009
 * met:
Packit 6c4009
 *
Packit 6c4009
 *     * Redistributions of source code must retain the above copyright
Packit 6c4009
 *       notice, this list of conditions and the following disclaimer.
Packit 6c4009
 *     * Redistributions in binary form must reproduce the above
Packit 6c4009
 *       copyright notice, this list of conditions and the following
Packit 6c4009
 *       disclaimer in the documentation and/or other materials
Packit 6c4009
 *       provided with the distribution.
Packit 6c4009
 *     * Neither the name of the "Oracle America, Inc." nor the names of its
Packit 6c4009
 *       contributors may be used to endorse or promote products derived
Packit 6c4009
 *       from this software without specific prior written permission.
Packit 6c4009
 *
Packit 6c4009
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 6c4009
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 6c4009
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
Packit 6c4009
 *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
Packit 6c4009
 *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
Packit 6c4009
 *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 6c4009
 *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
Packit 6c4009
 *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit 6c4009
 *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
Packit 6c4009
 *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Packit 6c4009
 *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 6c4009
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 6c4009
 */
Packit 6c4009
/*
Packit 6c4009
 * auth_none.c
Packit 6c4009
 * Creates a client authentication handle for passing "null"
Packit 6c4009
 * credentials and verifiers to remote systems.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#include <rpc/rpc.h>
Packit 6c4009
#include <libc-lock.h>
Packit 6c4009
#include <shlib-compat.h>
Packit 6c4009
Packit 6c4009
#define MAX_MARSHAL_SIZE 20
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Authenticator operations routines
Packit 6c4009
 */
Packit 6c4009
static void authnone_verf (AUTH *);
Packit 6c4009
static void authnone_destroy (AUTH *);
Packit 6c4009
static bool_t authnone_marshal (AUTH *, XDR *);
Packit 6c4009
static bool_t authnone_validate (AUTH *, struct opaque_auth *);
Packit 6c4009
static bool_t authnone_refresh (AUTH *);
Packit 6c4009
Packit 6c4009
static const struct auth_ops ops = {
Packit 6c4009
  authnone_verf,
Packit 6c4009
  authnone_marshal,
Packit 6c4009
  authnone_validate,
Packit 6c4009
  authnone_refresh,
Packit 6c4009
  authnone_destroy
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* Internal data and routines */
Packit 6c4009
Packit 6c4009
struct authnone_private_s {
Packit 6c4009
  AUTH no_client;
Packit 6c4009
  char marshalled_client[MAX_MARSHAL_SIZE];
Packit 6c4009
  u_int mcnt;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
static struct authnone_private_s authnone_private;
Packit 6c4009
__libc_once_define(static, authnone_private_guard);
Packit 6c4009
Packit 6c4009
static void authnone_create_once (void);
Packit 6c4009
Packit 6c4009
static void
Packit 6c4009
authnone_create_once (void)
Packit 6c4009
{
Packit 6c4009
  struct authnone_private_s *ap;
Packit 6c4009
  XDR xdr_stream;
Packit 6c4009
  XDR *xdrs;
Packit 6c4009
Packit 6c4009
  ap = &authnone_private;
Packit 6c4009
Packit 6c4009
  ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
Packit 6c4009
  ap->no_client.ah_ops = (struct auth_ops *) &ops;
Packit 6c4009
  xdrs = &xdr_stream;
Packit 6c4009
  xdrmem_create (xdrs, ap->marshalled_client,
Packit 6c4009
		 (u_int) MAX_MARSHAL_SIZE, XDR_ENCODE);
Packit 6c4009
  (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_cred);
Packit 6c4009
  (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_verf);
Packit 6c4009
  ap->mcnt = XDR_GETPOS (xdrs);
Packit 6c4009
  XDR_DESTROY (xdrs);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
AUTH *
Packit 6c4009
authnone_create (void)
Packit 6c4009
{
Packit 6c4009
  __libc_once (authnone_private_guard, authnone_create_once);
Packit 6c4009
  return &authnone_private.no_client;
Packit 6c4009
}
Packit 6c4009
libc_hidden_nolink_sunrpc (authnone_create, GLIBC_2_0)
Packit 6c4009
Packit 6c4009
static bool_t
Packit 6c4009
authnone_marshal (AUTH *client, XDR *xdrs)
Packit 6c4009
{
Packit 6c4009
  struct authnone_private_s *ap;
Packit 6c4009
Packit 6c4009
  /* authnone_create returned authnone_private->no_client, which is
Packit 6c4009
     the first field of struct authnone_private_s.  */
Packit 6c4009
  ap = (struct authnone_private_s *) client;
Packit 6c4009
  if (ap == NULL)
Packit 6c4009
    return FALSE;
Packit 6c4009
  return (*xdrs->x_ops->x_putbytes) (xdrs, ap->marshalled_client, ap->mcnt);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
static void
Packit 6c4009
authnone_verf (AUTH *auth)
Packit 6c4009
{
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
static bool_t
Packit 6c4009
authnone_validate (AUTH *auth, struct opaque_auth *oa)
Packit 6c4009
{
Packit 6c4009
  return TRUE;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
static bool_t
Packit 6c4009
authnone_refresh (AUTH *auth)
Packit 6c4009
{
Packit 6c4009
  return FALSE;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
static void
Packit 6c4009
authnone_destroy (AUTH *auth)
Packit 6c4009
{
Packit 6c4009
}