]> git.ipfire.org Git - thirdparty/glibc.git/blame - sunrpc/auth_none.c
Add glibc.malloc.mxfast tunable
[thirdparty/glibc.git] / sunrpc / auth_none.c
CommitLineData
28f540f4 1/*
a7ab6ec8 2 * Copyright (c) 2010, Oracle America, Inc.
cb636bb2 3 *
a7ab6ec8
UD
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
cb636bb2 7 *
a7ab6ec8
UD
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 * * Neither the name of the "Oracle America, 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.
e7fd8a39 17 *
a7ab6ec8
UD
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
f8afba91 30 */
28f540f4
RM
31/*
32 * auth_none.c
e7fd8a39
UD
33 * Creates a client authentication handle for passing "null"
34 * credentials and verifiers to remote systems.
28f540f4
RM
35 */
36
f1e4a4a4 37#include <rpc/rpc.h>
ec999b8e 38#include <libc-lock.h>
82f43dd2 39#include <shlib-compat.h>
e7fd8a39 40
cbba1b88 41#define MAX_MARSHAL_SIZE 20
28f540f4
RM
42
43/*
44 * Authenticator operations routines
45 */
e7fd8a39
UD
46static void authnone_verf (AUTH *);
47static void authnone_destroy (AUTH *);
48static bool_t authnone_marshal (AUTH *, XDR *);
49static bool_t authnone_validate (AUTH *, struct opaque_auth *);
50static bool_t authnone_refresh (AUTH *);
28f540f4 51
3d50529d 52static const struct auth_ops ops = {
e7fd8a39
UD
53 authnone_verf,
54 authnone_marshal,
55 authnone_validate,
56 authnone_refresh,
57 authnone_destroy
28f540f4
RM
58};
59
cbba1b88
UD
60/* Internal data and routines */
61
f1e4a4a4 62struct authnone_private_s {
f8afba91 63 AUTH no_client;
cbba1b88 64 char marshalled_client[MAX_MARSHAL_SIZE];
f8afba91 65 u_int mcnt;
f1e4a4a4 66};
28f540f4 67
cbba1b88
UD
68static struct authnone_private_s authnone_private;
69__libc_once_define(static, authnone_private_guard);
70
71static void authnone_create_once (void);
72
73static void
74authnone_create_once (void)
28f540f4 75{
f1e4a4a4 76 struct authnone_private_s *ap;
e7fd8a39
UD
77 XDR xdr_stream;
78 XDR *xdrs;
28f540f4 79
cbba1b88
UD
80 ap = &authnone_private;
81
82 ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
3d50529d 83 ap->no_client.ah_ops = (struct auth_ops *) &ops;
cbba1b88 84 xdrs = &xdr_stream;
7b57bfe5
UD
85 xdrmem_create (xdrs, ap->marshalled_client,
86 (u_int) MAX_MARSHAL_SIZE, XDR_ENCODE);
87 (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_cred);
88 (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_verf);
cbba1b88
UD
89 ap->mcnt = XDR_GETPOS (xdrs);
90 XDR_DESTROY (xdrs);
3d50529d 91}
cbba1b88
UD
92
93AUTH *
94authnone_create (void)
95{
96 __libc_once (authnone_private_guard, authnone_create_once);
97 return &authnone_private.no_client;
28f540f4 98}
021db4be 99libc_hidden_nolink_sunrpc (authnone_create, GLIBC_2_0)
28f540f4 100
28f540f4 101static bool_t
e7fd8a39 102authnone_marshal (AUTH *client, XDR *xdrs)
28f540f4 103{
f1e4a4a4 104 struct authnone_private_s *ap;
28f540f4 105
cbba1b88
UD
106 /* authnone_create returned authnone_private->no_client, which is
107 the first field of struct authnone_private_s. */
108 ap = (struct authnone_private_s *) client;
f1e4a4a4
UD
109 if (ap == NULL)
110 return FALSE;
f8afba91 111 return (*xdrs->x_ops->x_putbytes) (xdrs, ap->marshalled_client, ap->mcnt);
28f540f4
RM
112}
113
e7fd8a39
UD
114static void
115authnone_verf (AUTH *auth)
28f540f4
RM
116{
117}
118
119static bool_t
e7fd8a39 120authnone_validate (AUTH *auth, struct opaque_auth *oa)
28f540f4 121{
e7fd8a39 122 return TRUE;
28f540f4
RM
123}
124
125static bool_t
e7fd8a39 126authnone_refresh (AUTH *auth)
28f540f4 127{
e7fd8a39 128 return FALSE;
28f540f4
RM
129}
130
131static void
e7fd8a39 132authnone_destroy (AUTH *auth)
28f540f4
RM
133{
134}