ReactOS 0.4.15-dev-7924-g5949c20
auth_none.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009, Sun Microsystems, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * - Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * - Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * - Neither the name of Sun Microsystems, Inc. nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/*
30#if defined(LIBC_SCCS) && !defined(lint)
31static char *sccsid = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
32static char *sccsid = "@(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC";
33#endif
34//#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: src/lib/libc/rpc/auth_none.c,v 1.12 2002/03/22 23:18:35 obrien Exp $");
36*/
37
38
39/*
40 * auth_none.c
41 * Creates a client authentication handle for passing "null"
42 * credentials and verifiers to remote systems.
43 *
44 * Copyright (C) 1984, Sun Microsystems, Inc.
45 */
46
47/* NFSv4.1 client for Windows
48 * Copyright © 2012 The Regents of the University of Michigan
49 *
50 * Olga Kornievskaia <aglo@umich.edu>
51 * Casey Bodley <cbodley@umich.edu>
52 *
53 * This library is free software; you can redistribute it and/or modify it
54 * under the terms of the GNU Lesser General Public License as published by
55 * the Free Software Foundation; either version 2.1 of the License, or (at
56 * your option) any later version.
57 *
58 * This library is distributed in the hope that it will be useful, but
59 * without any warranty; without even the implied warranty of merchantability
60 * or fitness for a particular purpose. See the GNU Lesser General Public
61 * License for more details.
62 *
63 * You should have received a copy of the GNU Lesser General Public License
64 * along with this library; if not, write to the Free Software Foundation,
65 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
66 */
67
68#include <wintirpc.h>
69//#include <pthread.h>
70#include <reentrant.h>
71#include <assert.h>
72#include <stdlib.h>
73#include <rpc/types.h>
74#include <rpc/xdr.h>
75#include <rpc/auth.h>
76
77#define MAX_MARSHAL_SIZE 20
78
79/*
80 * Authenticator operations routines
81 */
82
83static bool_t authnone_marshal (AUTH *, XDR *, u_int *);
84static void authnone_verf (AUTH *);
85static bool_t authnone_validate (AUTH *, struct opaque_auth *, u_int);
86static bool_t authnone_refresh (AUTH *, void *);
87static void authnone_destroy (AUTH *);
88
90
91static struct auth_ops *authnone_ops();
92
93static struct authnone_private {
98
99AUTH *
101{
103 XDR xdr_stream;
104 XDR *xdrs;
105 extern mutex_t authnone_lock;
106
108 if (ap == 0) {
109 ap = (struct authnone_private *)calloc(1, sizeof (*ap));
110 if (ap == 0) {
112 return (0);
113 }
115 }
116 if (!ap->mcnt) {
117 ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
118 ap->no_client.ah_ops = authnone_ops();
119 xdrs = &xdr_stream;
120 xdrmem_create(xdrs, ap->marshalled_client,
122 (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
123 (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
124 ap->mcnt = XDR_GETPOS(xdrs);
125 XDR_DESTROY(xdrs);
126 }
128 return (&ap->no_client);
129}
130
131/*ARGSUSED*/
132static bool_t
134{
135 struct authnone_private *ap;
137 extern mutex_t authnone_lock;
138
139 assert(xdrs != NULL);
140
142 if (ap == NULL) {
144 return (FALSE);
145 }
146 dummy = (*xdrs->x_ops->x_putbytes)(xdrs,
147 ap->marshalled_client, ap->mcnt);
149 return (dummy);
150}
151
152/* All these unused parameters are required to keep ANSI-C from grumbling */
153/*ARGSUSED*/
154static void
156{
157}
158
159/*ARGSUSED*/
160static bool_t
162{
163
164 return (TRUE);
165}
166
167/*ARGSUSED*/
168static bool_t
170{
171
172 return (FALSE);
173}
174
175/*ARGSUSED*/
176static void
178{
179}
180
181static int
183{
184 return ((*func)(xdrs, args));
185}
186
187static int
189{
190 return ((*func)(xdrs, args));
191}
192
193static struct auth_ops *
195{
196 static struct auth_ops ops;
197 extern mutex_t ops_lock;
198
199/* VARIABLES PROTECTED BY ops_lock: ops */
200
202 if (ops.ah_nextverf == NULL) {
203 ops.ah_nextverf = authnone_verf;
204 ops.ah_marshal = authnone_marshal;
205 ops.ah_validate = authnone_validate;
206 ops.ah_refresh = authnone_refresh;
207 ops.ah_destroy = authnone_destroy;
208 ops.ah_wrap = authnone_wrap;
209 ops.ah_unwrap = authnone_unwrap;
210 }
212 return (&ops);
213}
static bool_t authnone_validate(AUTH *, struct opaque_auth *, u_int)
Definition: auth_none.c:161
bool_t xdr_opaque_auth()
static bool_t authnone_refresh(AUTH *, void *)
Definition: auth_none.c:169
static void authnone_destroy(AUTH *)
Definition: auth_none.c:177
static struct auth_ops * authnone_ops()
Definition: auth_none.c:194
static void authnone_verf(AUTH *)
Definition: auth_none.c:155
static int authnone_wrap(AUTH *auth, XDR *xdrs, xdrproc_t func, caddr_t args)
Definition: auth_none.c:182
#define MAX_MARSHAL_SIZE
Definition: auth_none.c:77
static int authnone_unwrap(AUTH *auth, XDR *xdrs, xdrproc_t func, caddr_t args, u_int seq)
Definition: auth_none.c:188
static bool_t authnone_marshal(AUTH *, XDR *, u_int *)
Definition: auth_none.c:133
AUTH * authnone_create()
Definition: auth_none.c:100
UINT32 u_int
Definition: types.h:82
#define NULL
Definition: types.h:112
int32_t bool_t
Definition: types.h:101
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define assert(x)
Definition: debug.h:53
GLenum func
Definition: glext.h:6028
mutex_t authnone_lock
Definition: mt_misc.c:44
mutex_t ops_lock
Definition: mt_misc.c:71
#define mutex_lock(m)
Definition: reentrant.h:128
#define mutex_unlock(m)
Definition: reentrant.h:129
char * caddr_t
Definition: rosdhcp.h:36
#define calloc
Definition: rosglue.h:14
struct opaque_auth _null_auth
static FILE * client
Definition: client.c:41
Definition: auth.h:205
Definition: xdr.h:103
const struct __rpc_xdr::xdr_ops * x_ops
Definition: match.c:390
char marshalled_client[MAX_MARSHAL_SIZE]
Definition: auth_none.c:95
Definition: module.h:456
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
@ XDR_ENCODE
Definition: xdr.h:85
#define XDR_DESTROY(xdrs)
Definition: xdr.h:214
bool_t(* xdrproc_t)(XDR *,...)
Definition: xdr.h:144
#define XDR_GETPOS(xdrs)
Definition: xdr.h:199
void xdrmem_create(XDR *xdrs, char *addr, u_int size, enum xdr_op op)
Definition: xdr_mem.c:94