|
Packit Service |
4f68e0 |
/*
|
|
Packit Service |
4f68e0 |
* Copyright (c) 2009, Sun Microsystems, Inc.
|
|
Packit Service |
4f68e0 |
* All rights reserved.
|
|
Packit Service |
4f68e0 |
*
|
|
Packit Service |
4f68e0 |
* Redistribution and use in source and binary forms, with or without
|
|
Packit Service |
4f68e0 |
* modification, are permitted provided that the following conditions are met:
|
|
Packit Service |
4f68e0 |
* - Redistributions of source code must retain the above copyright notice,
|
|
Packit Service |
4f68e0 |
* this list of conditions and the following disclaimer.
|
|
Packit Service |
4f68e0 |
* - Redistributions in binary form must reproduce the above copyright notice,
|
|
Packit Service |
4f68e0 |
* this list of conditions and the following disclaimer in the documentation
|
|
Packit Service |
4f68e0 |
* and/or other materials provided with the distribution.
|
|
Packit Service |
4f68e0 |
* - Neither the name of Sun Microsystems, Inc. nor the names of its
|
|
Packit Service |
4f68e0 |
* contributors may be used to endorse or promote products derived
|
|
Packit Service |
4f68e0 |
* from this software without specific prior written permission.
|
|
Packit Service |
4f68e0 |
*
|
|
Packit Service |
4f68e0 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit Service |
4f68e0 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit Service |
4f68e0 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit Service |
4f68e0 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
Packit Service |
4f68e0 |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit Service |
4f68e0 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit Service |
4f68e0 |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit Service |
4f68e0 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit Service |
4f68e0 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit Service |
4f68e0 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
Packit Service |
4f68e0 |
* POSSIBILITY OF SUCH DAMAGE.
|
|
Packit Service |
4f68e0 |
*/
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
/*
|
|
Packit Service |
4f68e0 |
#if defined(LIBC_SCCS) && !defined(lint)
|
|
Packit Service |
4f68e0 |
static char *sccsid = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
|
|
Packit Service |
4f68e0 |
static char *sccsid = "@(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC";
|
|
Packit Service |
4f68e0 |
#endif
|
|
Packit Service |
4f68e0 |
__FBSDID("$FreeBSD: src/lib/libc/rpc/auth_none.c,v 1.12 2002/03/22 23:18:35 obrien Exp $");
|
|
Packit Service |
4f68e0 |
*/
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
/*
|
|
Packit Service |
4f68e0 |
* auth_none.c
|
|
Packit Service |
4f68e0 |
* Creates a client authentication handle for passing "null"
|
|
Packit Service |
4f68e0 |
* credentials and verifiers to remote systems.
|
|
Packit Service |
4f68e0 |
*
|
|
Packit Service |
4f68e0 |
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
Packit Service |
4f68e0 |
*/
|
|
Packit Service |
4f68e0 |
#include <pthread.h>
|
|
Packit Service |
4f68e0 |
#include <reentrant.h>
|
|
Packit Service |
4f68e0 |
#include <assert.h>
|
|
Packit Service |
4f68e0 |
#include <stdlib.h>
|
|
Packit Service |
4f68e0 |
#include <rpc/types.h>
|
|
Packit Service |
4f68e0 |
#include <rpc/xdr.h>
|
|
Packit Service |
4f68e0 |
#include <rpc/auth.h>
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
#define MAX_MARSHAL_SIZE 20
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
/*
|
|
Packit Service |
4f68e0 |
* Authenticator operations routines
|
|
Packit Service |
4f68e0 |
*/
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
static bool_t authnone_marshal (AUTH *, XDR *);
|
|
Packit Service |
4f68e0 |
static void authnone_verf (AUTH *);
|
|
Packit Service |
4f68e0 |
static bool_t authnone_validate (AUTH *, struct opaque_auth *);
|
|
Packit Service |
4f68e0 |
static bool_t authnone_refresh (AUTH *, void *);
|
|
Packit Service |
4f68e0 |
static void authnone_destroy (AUTH *);
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
extern bool_t xdr_opaque_auth();
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
static struct auth_ops *authnone_ops();
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
static struct authnone_private {
|
|
Packit Service |
4f68e0 |
AUTH no_client;
|
|
Packit Service |
4f68e0 |
char marshalled_client[MAX_MARSHAL_SIZE];
|
|
Packit Service |
4f68e0 |
u_int mcnt;
|
|
Packit Service |
4f68e0 |
} *authnone_private;
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
AUTH *
|
|
Packit Service |
4f68e0 |
authnone_create()
|
|
Packit Service |
4f68e0 |
{
|
|
Packit Service |
4f68e0 |
struct authnone_private *ap = authnone_private;
|
|
Packit Service |
4f68e0 |
XDR xdr_stream;
|
|
Packit Service |
4f68e0 |
XDR *xdrs;
|
|
Packit Service |
4f68e0 |
extern mutex_t authnone_lock;
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
mutex_lock(&authnone_lock);
|
|
Packit Service |
4f68e0 |
if (ap == 0) {
|
|
Packit Service |
4f68e0 |
ap = (struct authnone_private *)calloc(1, sizeof (*ap));
|
|
Packit Service |
4f68e0 |
if (ap == 0) {
|
|
Packit Service |
4f68e0 |
mutex_unlock(&authnone_lock);
|
|
Packit Service |
4f68e0 |
return (0);
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
authnone_private = ap;
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
if (!ap->mcnt) {
|
|
Packit Service |
4f68e0 |
ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
|
|
Packit Service |
4f68e0 |
ap->no_client.ah_ops = authnone_ops();
|
|
Packit Service |
4f68e0 |
xdrs = &xdr_stream;
|
|
Packit Service |
4f68e0 |
xdrmem_create(xdrs, ap->marshalled_client,
|
|
Packit Service |
4f68e0 |
(u_int)MAX_MARSHAL_SIZE, XDR_ENCODE);
|
|
Packit Service |
4f68e0 |
(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
|
|
Packit Service |
4f68e0 |
(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
|
|
Packit Service |
4f68e0 |
ap->mcnt = XDR_GETPOS(xdrs);
|
|
Packit Service |
4f68e0 |
XDR_DESTROY(xdrs);
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
mutex_unlock(&authnone_lock);
|
|
Packit Service |
4f68e0 |
return (&ap->no_client);
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
/*ARGSUSED*/
|
|
Packit Service |
4f68e0 |
static bool_t
|
|
Packit Service |
4f68e0 |
authnone_marshal(AUTH *client, XDR *xdrs)
|
|
Packit Service |
4f68e0 |
{
|
|
Packit Service |
4f68e0 |
struct authnone_private *ap;
|
|
Packit Service |
4f68e0 |
bool_t rv = FALSE;
|
|
Packit Service |
4f68e0 |
extern mutex_t authnone_lock;
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
assert(xdrs != NULL);
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
mutex_lock(&authnone_lock);
|
|
Packit Service |
4f68e0 |
ap = authnone_private;
|
|
Packit Service |
4f68e0 |
if (ap) {
|
|
Packit Service |
4f68e0 |
rv = (*xdrs->x_ops->x_putbytes)(xdrs, ap->marshalled_client,
|
|
Packit Service |
4f68e0 |
ap->mcnt);
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
mutex_unlock(&authnone_lock);
|
|
Packit Service |
4f68e0 |
return (rv);
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
/* All these unused parameters are required to keep ANSI-C from grumbling */
|
|
Packit Service |
4f68e0 |
/*ARGSUSED*/
|
|
Packit Service |
4f68e0 |
static void
|
|
Packit Service |
4f68e0 |
authnone_verf(AUTH *client)
|
|
Packit Service |
4f68e0 |
{
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
/*ARGSUSED*/
|
|
Packit Service |
4f68e0 |
static bool_t
|
|
Packit Service |
4f68e0 |
authnone_validate(AUTH *client, struct opaque_auth *opaque)
|
|
Packit Service |
4f68e0 |
{
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
return (TRUE);
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
/*ARGSUSED*/
|
|
Packit Service |
4f68e0 |
static bool_t
|
|
Packit Service |
4f68e0 |
authnone_refresh(AUTH *client, void *dummy)
|
|
Packit Service |
4f68e0 |
{
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
return (FALSE);
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
/*ARGSUSED*/
|
|
Packit Service |
4f68e0 |
static void
|
|
Packit Service |
4f68e0 |
authnone_destroy(AUTH *client)
|
|
Packit Service |
4f68e0 |
{
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
static bool_t
|
|
Packit Service |
4f68e0 |
authnone_wrap(AUTH *auth, XDR *xdrs, xdrproc_t xfunc, caddr_t xwhere)
|
|
Packit Service |
4f68e0 |
{
|
|
Packit Service |
4f68e0 |
return ((*xfunc)(xdrs, xwhere));
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
static struct auth_ops *
|
|
Packit Service |
4f68e0 |
authnone_ops()
|
|
Packit Service |
4f68e0 |
{
|
|
Packit Service |
4f68e0 |
static struct auth_ops ops;
|
|
Packit Service |
4f68e0 |
extern mutex_t ops_lock;
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
/* VARIABLES PROTECTED BY ops_lock: ops */
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
mutex_lock(&ops_lock);
|
|
Packit Service |
4f68e0 |
if (ops.ah_nextverf == NULL) {
|
|
Packit Service |
4f68e0 |
ops.ah_nextverf = authnone_verf;
|
|
Packit Service |
4f68e0 |
ops.ah_marshal = authnone_marshal;
|
|
Packit Service |
4f68e0 |
ops.ah_validate = authnone_validate;
|
|
Packit Service |
4f68e0 |
ops.ah_refresh = authnone_refresh;
|
|
Packit Service |
4f68e0 |
ops.ah_destroy = authnone_destroy;
|
|
Packit Service |
4f68e0 |
ops.ah_wrap = authnone_wrap;
|
|
Packit Service |
4f68e0 |
ops.ah_unwrap = authnone_wrap;
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
mutex_unlock(&ops_lock);
|
|
Packit Service |
4f68e0 |
return (&ops;;
|
|
Packit Service |
4f68e0 |
}
|