1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate /* from SunOS 4.1 */
28*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gate /*
31*0Sstevel@tonic-gate * modified for use by the boot program.
32*0Sstevel@tonic-gate *
33*0Sstevel@tonic-gate * auth_none.c
34*0Sstevel@tonic-gate * Creates a client authentication handle for passing "null"
35*0Sstevel@tonic-gate * credentials and verifiers to remote systems.
36*0Sstevel@tonic-gate */
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate #include <rpc/types.h>
39*0Sstevel@tonic-gate #include <rpc/xdr.h>
40*0Sstevel@tonic-gate #include <rpc/auth.h>
41*0Sstevel@tonic-gate #include "clnt.h"
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gate #define MAX_MARSHEL_SIZE 20
44*0Sstevel@tonic-gate
45*0Sstevel@tonic-gate static struct auth_ops *authnone_ops();
46*0Sstevel@tonic-gate
47*0Sstevel@tonic-gate static struct authnone_private {
48*0Sstevel@tonic-gate AUTH no_client;
49*0Sstevel@tonic-gate char marshalled_client[MAX_MARSHEL_SIZE];
50*0Sstevel@tonic-gate uint_t mcnt;
51*0Sstevel@tonic-gate } *authnone_private;
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gate static struct authnone_private authnone_local;
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gate AUTH *
authnone_create(void)56*0Sstevel@tonic-gate authnone_create(void)
57*0Sstevel@tonic-gate {
58*0Sstevel@tonic-gate struct authnone_private *ap = authnone_private;
59*0Sstevel@tonic-gate XDR xdr_stream;
60*0Sstevel@tonic-gate XDR *xdrs;
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gate if (ap == 0) {
63*0Sstevel@tonic-gate ap = &authnone_local;
64*0Sstevel@tonic-gate authnone_private = ap;
65*0Sstevel@tonic-gate }
66*0Sstevel@tonic-gate if (!ap->mcnt) {
67*0Sstevel@tonic-gate ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
68*0Sstevel@tonic-gate ap->no_client.ah_ops = authnone_ops();
69*0Sstevel@tonic-gate xdrs = &xdr_stream;
70*0Sstevel@tonic-gate xdrmem_create(xdrs, ap->marshalled_client,
71*0Sstevel@tonic-gate (uint_t)MAX_MARSHEL_SIZE, XDR_ENCODE);
72*0Sstevel@tonic-gate (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
73*0Sstevel@tonic-gate (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
74*0Sstevel@tonic-gate ap->mcnt = XDR_GETPOS(xdrs);
75*0Sstevel@tonic-gate XDR_DESTROY(xdrs);
76*0Sstevel@tonic-gate }
77*0Sstevel@tonic-gate return (&ap->no_client);
78*0Sstevel@tonic-gate }
79*0Sstevel@tonic-gate
80*0Sstevel@tonic-gate /*ARGSUSED*/
81*0Sstevel@tonic-gate static bool_t
authnone_marshal(AUTH * client,XDR * xdrs,struct cred * cr)82*0Sstevel@tonic-gate authnone_marshal(AUTH *client, XDR *xdrs, struct cred *cr)
83*0Sstevel@tonic-gate {
84*0Sstevel@tonic-gate struct authnone_private *ap = authnone_private;
85*0Sstevel@tonic-gate
86*0Sstevel@tonic-gate if (ap == 0)
87*0Sstevel@tonic-gate return (0);
88*0Sstevel@tonic-gate return ((*xdrs->x_ops->x_putbytes)(xdrs,
89*0Sstevel@tonic-gate ap->marshalled_client, ap->mcnt));
90*0Sstevel@tonic-gate }
91*0Sstevel@tonic-gate
92*0Sstevel@tonic-gate /* ARGSUSED */
93*0Sstevel@tonic-gate static void
authnone_verf(AUTH * foo)94*0Sstevel@tonic-gate authnone_verf(AUTH *foo)
95*0Sstevel@tonic-gate {
96*0Sstevel@tonic-gate }
97*0Sstevel@tonic-gate
98*0Sstevel@tonic-gate /* ARGSUSED */
99*0Sstevel@tonic-gate static bool_t
authnone_validate(AUTH * foo,struct opaque_auth * bar)100*0Sstevel@tonic-gate authnone_validate(AUTH *foo, struct opaque_auth *bar)
101*0Sstevel@tonic-gate {
102*0Sstevel@tonic-gate return (TRUE);
103*0Sstevel@tonic-gate }
104*0Sstevel@tonic-gate
105*0Sstevel@tonic-gate /* ARGSUSED */
106*0Sstevel@tonic-gate static bool_t
authnone_refresh(AUTH * foo,struct rpc_msg * bar,cred_t * cr)107*0Sstevel@tonic-gate authnone_refresh(AUTH *foo, struct rpc_msg *bar, cred_t *cr)
108*0Sstevel@tonic-gate {
109*0Sstevel@tonic-gate return (FALSE);
110*0Sstevel@tonic-gate }
111*0Sstevel@tonic-gate
112*0Sstevel@tonic-gate /* ARGSUSED */
113*0Sstevel@tonic-gate static void
authnone_destroy(AUTH * foo)114*0Sstevel@tonic-gate authnone_destroy(AUTH *foo)
115*0Sstevel@tonic-gate {
116*0Sstevel@tonic-gate }
117*0Sstevel@tonic-gate
118*0Sstevel@tonic-gate static struct auth_ops *
authnone_ops(void)119*0Sstevel@tonic-gate authnone_ops(void)
120*0Sstevel@tonic-gate {
121*0Sstevel@tonic-gate static struct auth_ops ops;
122*0Sstevel@tonic-gate
123*0Sstevel@tonic-gate if (ops.ah_nextverf == NULL) {
124*0Sstevel@tonic-gate ops.ah_nextverf = authnone_verf;
125*0Sstevel@tonic-gate ops.ah_marshal = authnone_marshal;
126*0Sstevel@tonic-gate ops.ah_validate = authnone_validate;
127*0Sstevel@tonic-gate ops.ah_refresh = authnone_refresh;
128*0Sstevel@tonic-gate ops.ah_destroy = authnone_destroy;
129*0Sstevel@tonic-gate }
130*0Sstevel@tonic-gate return (&ops);
131*0Sstevel@tonic-gate }
132