Import TBBT (NFS trace replay).
[bluesky.git] / TBBT / trace_play / rpc / auth_none.c
1 #ifndef lint
2 static char sfs_auth_none_c_id[] = "@(#)auth_none.c     2.1     97/10/23";
3 #endif
4 /* @(#)auth_none.c      2.1 88/07/29 4.0 RPCSRC */
5 /*
6  *   Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
7  *      All rights reserved.
8  *              Standard Performance Evaluation Corporation (SPEC)
9  *              6585 Merchant Place, Suite 100
10  *              Warrenton, VA 20187
11  *
12  *      This product contains benchmarks acquired from several sources who
13  *      understand and agree with SPEC's goal of creating fair and objective
14  *      benchmarks to measure computer performance.
15  *
16  *      This copyright notice is placed here only to protect SPEC in the
17  *      event the source is misused in any manner that is contrary to the
18  *      spirit, the goals and the intent of SPEC.
19  *
20  *      The source code is provided to the user or company under the license
21  *      agreement for the SPEC Benchmark Suite for this product.
22  */
23 /*
24  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
25  * unrestricted use provided that this legend is included on all tape
26  * media and as a part of the software program in whole or part.  Users
27  * may copy or modify Sun RPC without charge, but are not authorized
28  * to license or distribute it to anyone else except as part of a product or
29  * program developed by the user.
30  * 
31  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
32  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
33  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
34  * 
35  * Sun RPC is provided with no support and without any obligation on the
36  * part of Sun Microsystems, Inc. to assist in its use, correction,
37  * modification or enhancement.
38  * 
39  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
40  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
41  * OR ANY PART THEREOF.
42  * 
43  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
44  * or profits or other special, indirect and consequential damages, even if
45  * Sun has been advised of the possibility of such damages.
46  * 
47  * Sun Microsystems, Inc.
48  * 2550 Garcia Avenue
49  * Mountain View, California  94043
50  */
51 #if !defined(lint) && defined(SCCSIDS)
52 static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
53 #endif
54
55 /*
56  * auth_none.c
57  * Creates a client authentication handle for passing "null" 
58  * credentials and verifiers to remote systems. 
59  * 
60  * Copyright (C) 1984, Sun Microsystems, Inc. 
61  */
62
63 #include <stdlib.h>
64 #include "rpc/rpc.h"
65 #define MAX_MARSHEL_SIZE 20
66
67 /*
68  * Authenticator operations routines
69  */
70 static void     authnone_verf(void);
71 static void     authnone_destroy(void);
72 static bool_t   authnone_marshal(AUTH *, XDR *);
73 static bool_t   authnone_validate(void);
74 static bool_t   authnone_refresh(void);
75
76 static struct auth_ops ops = {
77         authnone_verf,
78         authnone_marshal,
79         authnone_validate,
80         authnone_refresh,
81         authnone_destroy
82 };
83
84 static struct authnone_private {
85         AUTH    no_client;
86         char    marshalled_client[MAX_MARSHEL_SIZE];
87         uint_t  mcnt;
88 } *authnone_private;
89
90 AUTH *
91 authnone_create(void)
92 {
93         register struct authnone_private *ap = authnone_private;
94         XDR xdr_stream;
95         register XDR *xdrs;
96
97         if (ap == 0) {
98                 ap = (struct authnone_private *)calloc(1,
99                                         sizeof (struct authnone_private));
100                 if (ap == 0)
101                         return (0);
102                 authnone_private = ap;
103         }
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, (uint_t)MAX_MARSHEL_SIZE,
109                     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);
114         }
115         return (&ap->no_client);
116 }
117
118 /*ARGSUSED*/
119 static bool_t
120 authnone_marshal(
121         AUTH *client,
122         XDR *xdrs)
123 {
124         register struct authnone_private *ap = authnone_private;
125
126         if (ap == 0)
127                 return (0);
128         return ((*xdrs->x_ops->x_putbytes)(xdrs,
129             ap->marshalled_client, ap->mcnt));
130 }
131
132 static void 
133 authnone_verf(void)
134 {
135 }
136
137 static bool_t
138 authnone_validate(void)
139 {
140
141         return (TRUE);
142 }
143
144 static bool_t
145 authnone_refresh(void)
146 {
147
148         return (FALSE);
149 }
150
151 static void
152 authnone_destroy(void)
153 {
154 }