1 /* $NetBSD: auth_none.c,v 1.13 2000/01/22 22:19:17 mycroft Exp $ */
4 * Copyright (c) 2009, Sun Microsystems, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 * - Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * - Neither the name of Sun Microsystems, Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
31 #if defined(LIBC_SCCS) && !defined(lint)
32 static char *sccsid2 = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
33 static char *sccsid = "@(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC";
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
40 * Creates a client authentication handle for passing "null"
41 * credentials and verifiers to remote systems.
43 * Copyright (C) 1984, Sun Microsystems, Inc.
46 #include "namespace.h"
47 #include "reentrant.h"
50 #include <rpc/types.h>
53 #include "un-namespace.h"
56 #define MAX_MARSHAL_SIZE 20
59 * Authenticator operations routines
62 static bool_t authnone_marshal (AUTH *, XDR *);
63 static void authnone_verf (AUTH *);
64 static bool_t authnone_validate (AUTH *, struct opaque_auth *);
65 static bool_t authnone_refresh (AUTH *, void *);
66 static void authnone_destroy (AUTH *);
68 extern bool_t xdr_opaque_auth();
70 static struct auth_ops *authnone_ops();
72 static struct authnone_private {
74 char marshalled_client[MAX_MARSHAL_SIZE];
81 struct authnone_private *ap = authnone_private;
85 mutex_lock(&authnone_lock);
87 ap = (struct authnone_private *)calloc(1, sizeof (*ap));
89 mutex_unlock(&authnone_lock);
92 authnone_private = ap;
95 ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
96 ap->no_client.ah_ops = authnone_ops();
98 xdrmem_create(xdrs, ap->marshalled_client,
99 (u_int)MAX_MARSHAL_SIZE, XDR_ENCODE);
100 (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
101 (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
102 ap->mcnt = XDR_GETPOS(xdrs);
105 mutex_unlock(&authnone_lock);
106 return (&ap->no_client);
111 authnone_marshal(AUTH *client, XDR *xdrs)
113 struct authnone_private *ap;
116 assert(xdrs != NULL);
118 ap = authnone_private;
120 mutex_unlock(&authnone_lock);
123 dummy = (*xdrs->x_ops->x_putbytes)(xdrs,
124 ap->marshalled_client, ap->mcnt);
125 mutex_unlock(&authnone_lock);
129 /* All these unused parameters are required to keep ANSI-C from grumbling */
132 authnone_verf(AUTH *client)
138 authnone_validate(AUTH *client, struct opaque_auth *opaque)
146 authnone_refresh(AUTH *client, void *dummy)
154 authnone_destroy(AUTH *client)
158 static struct auth_ops *
161 static struct auth_ops ops;
163 /* VARIABLES PROTECTED BY ops_lock: ops */
165 mutex_lock(&ops_lock);
166 if (ops.ah_nextverf == NULL) {
167 ops.ah_nextverf = authnone_verf;
168 ops.ah_marshal = authnone_marshal;
169 ops.ah_validate = authnone_validate;
170 ops.ah_refresh = authnone_refresh;
171 ops.ah_destroy = authnone_destroy;
173 mutex_unlock(&ops_lock);