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