tools/llvm: Do not build with symbols
[minix3.git] / lib / libc / rpc / auth_none.c
blob5f47a4e75ba125d1e0acc6e5c6d64dcc1bfec9b5
1 /* $NetBSD: auth_none.c,v 1.16 2013/03/11 20:19:28 tron Exp $ */
3 /*
4 * Copyright (c) 2010, Oracle America, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials
15 * provided with the distribution.
16 * * Neither the name of the "Oracle America, Inc." nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/cdefs.h>
35 #if defined(LIBC_SCCS) && !defined(lint)
36 #if 0
37 static char *sccsid = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
38 static char *sccsid = "@(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC";
39 #else
40 __RCSID("$NetBSD: auth_none.c,v 1.16 2013/03/11 20:19:28 tron Exp $");
41 #endif
42 #endif
45 * auth_none.c
46 * Creates a client authentication handle for passing "null"
47 * credentials and verifiers to remote systems.
49 * Copyright (C) 1984, Sun Microsystems, Inc.
52 #include "namespace.h"
54 #include <assert.h>
55 #include <stdlib.h>
57 #include <rpc/types.h>
58 #include <rpc/xdr.h>
59 #include <rpc/auth.h>
61 #ifdef __weak_alias
62 __weak_alias(authnone_create,_authnone_create)
63 #endif
65 #define MAX_MARSHAL_SIZE 20
68 * Authenticator operations routines
71 static bool_t authnone_marshal(AUTH *, XDR *);
72 static void authnone_verf(AUTH *);
73 static bool_t authnone_validate(AUTH *, struct opaque_auth *);
74 static bool_t authnone_refresh(AUTH *);
75 static void authnone_destroy(AUTH *);
77 static const struct auth_ops ops = {
78 authnone_verf,
79 authnone_marshal,
80 authnone_validate,
81 authnone_refresh,
82 authnone_destroy
85 static struct authnone_private {
86 AUTH no_client;
87 char marshalled_client[MAX_MARSHAL_SIZE];
88 u_int mcnt;
89 } *authnone_private;
91 AUTH *
92 authnone_create(void)
94 struct authnone_private *ap = authnone_private;
95 XDR xdr_stream;
96 XDR *xdrs;
98 if (ap == 0) {
99 ap = (struct authnone_private *)calloc(1, sizeof (*ap));
100 if (ap == 0)
101 return (0);
102 authnone_private = ap;
104 if (!ap->mcnt) {
105 ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
106 ap->no_client.ah_ops = &ops;
107 xdrs = &xdr_stream;
108 xdrmem_create(xdrs, ap->marshalled_client,
109 (u_int)MAX_MARSHAL_SIZE, XDR_ENCODE);
110 (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
111 (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
112 ap->mcnt = XDR_GETPOS(xdrs);
113 XDR_DESTROY(xdrs);
115 return (&ap->no_client);
118 /*ARGSUSED*/
119 static bool_t
120 authnone_marshal(AUTH *client, XDR *xdrs)
122 struct authnone_private *ap = authnone_private;
124 _DIAGASSERT(xdrs != NULL);
126 if (ap == 0)
127 return (0);
128 return ((*xdrs->x_ops->x_putbytes)(xdrs,
129 ap->marshalled_client, ap->mcnt));
132 /*ARGSUSED*/
133 static void
134 authnone_verf(AUTH *client)
138 /*ARGSUSED*/
139 static bool_t
140 authnone_validate(AUTH *client, struct opaque_auth *auth)
143 return (TRUE);
146 /*ARGSUSED*/
147 static bool_t
148 authnone_refresh(AUTH *client)
151 return (FALSE);
154 /*ARGSUSED*/
155 static void
156 authnone_destroy(AUTH *client)