4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
30 * Portions of this source code were derived from Berkeley
31 * 4.3 BSD under license from the Regents of the University of
35 #pragma ident "%Z%%M% %I% %E% SMI"
39 * Creates a client authentication handle for passing "null"
40 * credentials and verifiers to remote systems.
46 #include <rpc/types.h>
49 #define MAX_MARSHEL_SIZE 20
52 extern bool_t
xdr_opaque_auth(XDR
*, struct opaque_auth
*);
54 static struct auth_ops
*authnone_ops(void);
56 static struct authnone_private
{
58 char marshalled_client
[MAX_MARSHEL_SIZE
];
66 struct authnone_private
*ap
;
69 extern mutex_t authnone_lock
;
71 /* VARIABLES PROTECTED BY authnone_lock: ap */
73 (void) mutex_lock(&authnone_lock
);
74 ap
= authnone_private
;
76 ap
= calloc(1, sizeof (*ap
));
78 (void) mutex_unlock(&authnone_lock
);
81 authnone_private
= ap
;
84 ap
->no_client
.ah_cred
= ap
->no_client
.ah_verf
= _null_auth
;
85 ap
->no_client
.ah_ops
= authnone_ops();
87 xdrmem_create(xdrs
, ap
->marshalled_client
,
88 (uint_t
)MAX_MARSHEL_SIZE
, XDR_ENCODE
);
89 (void) xdr_opaque_auth(xdrs
, &ap
->no_client
.ah_cred
);
90 (void) xdr_opaque_auth(xdrs
, &ap
->no_client
.ah_verf
);
91 ap
->mcnt
= XDR_GETPOS(xdrs
);
94 (void) mutex_unlock(&authnone_lock
);
95 return (&ap
->no_client
);
100 authnone_marshal(AUTH
*client
, XDR
*xdrs
)
102 struct authnone_private
*ap
;
104 extern mutex_t authnone_lock
;
106 (void) mutex_lock(&authnone_lock
);
107 ap
= authnone_private
;
109 (void) mutex_unlock(&authnone_lock
);
112 res
= (*xdrs
->x_ops
->x_putbytes
)(xdrs
,
113 ap
->marshalled_client
, ap
->mcnt
);
114 (void) mutex_unlock(&authnone_lock
);
118 /* All these unused parameters are required to keep ANSI-C from grumbling */
121 authnone_verf(AUTH
*client
)
127 authnone_validate(AUTH
*client
, struct opaque_auth
*opaque
)
134 authnone_refresh(AUTH
*client
, void *dummy
)
141 authnone_destroy(AUTH
*client
)
145 static struct auth_ops
*
148 static struct auth_ops ops
;
149 extern mutex_t ops_lock
;
151 /* VARIABLES PROTECTED BY ops_lock: ops */
153 (void) mutex_lock(&ops_lock
);
154 if (ops
.ah_nextverf
== NULL
) {
155 ops
.ah_nextverf
= authnone_verf
;
156 ops
.ah_marshal
= authnone_marshal
;
157 ops
.ah_validate
= authnone_validate
;
158 ops
.ah_refresh
= authnone_refresh
;
159 ops
.ah_destroy
= authnone_destroy
;
161 (void) mutex_unlock(&ops_lock
);