Blame sunrpc/auth_none.c

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