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