auth_none.c (7c478bd9) auth_none.c (61961e0f)
1/*
2 * CDDL HEADER START
3 *
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
7 * with the License.
8 *

--- 4 unchanged lines hidden (view full) ---

13 *
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]
19 *
20 * CDDL HEADER END
1/*
2 * CDDL HEADER START
3 *
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
7 * with the License.
8 *

--- 4 unchanged lines hidden (view full) ---

13 *
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]
19 *
20 * CDDL HEADER END
21 *
22 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
21 */
22
23/*
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
26/* All Rights Reserved */
27/*
28 * Portions of this source code were derived from Berkeley
29 * 4.3 BSD under license from the Regents of the University of
30 * California.

--- 4 unchanged lines hidden (view full) ---

35/*
36 * auth_none.c
37 * Creates a client authentication handle for passing "null"
38 * credentials and verifiers to remote systems.
39 */
40
41#include "mt.h"
42#include "rpc_mt.h"
25 * Use is subject to license terms.
26 */
27/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28/* All Rights Reserved */
29/*
30 * Portions of this source code were derived from Berkeley
31 * 4.3 BSD under license from the Regents of the University of
32 * California.

--- 4 unchanged lines hidden (view full) ---

37/*
38 * auth_none.c
39 * Creates a client authentication handle for passing "null"
40 * credentials and verifiers to remote systems.
41 */
42
43#include "mt.h"
44#include "rpc_mt.h"
45#include <stdlib.h>
43#include <rpc/types.h>
46#include <rpc/types.h>
44#include <rpc/trace.h>
45#include <rpc/xdr.h>
46#include <rpc/auth.h>
47#define MAX_MARSHEL_SIZE 20
48
49
47#include <rpc/xdr.h>
48#include <rpc/auth.h>
49#define MAX_MARSHEL_SIZE 20
50
51
50extern bool_t xdr_opaque_auth();
52extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *);
51
53
52static struct auth_ops *authnone_ops();
54static struct auth_ops *authnone_ops(void);
53
54static struct authnone_private {
55 AUTH no_client;
56 char marshalled_client[MAX_MARSHEL_SIZE];
57 uint_t mcnt;
58} *authnone_private;
59
55
56static struct authnone_private {
57 AUTH no_client;
58 char marshalled_client[MAX_MARSHEL_SIZE];
59 uint_t mcnt;
60} *authnone_private;
61
60char *calloc();
61
62AUTH *
62
63AUTH *
63authnone_create()
64authnone_create(void)
64{
65 struct authnone_private *ap;
66 XDR xdr_stream;
67 XDR *xdrs;
68 extern mutex_t authnone_lock;
69
70 /* VARIABLES PROTECTED BY authnone_lock: ap */
71
65{
66 struct authnone_private *ap;
67 XDR xdr_stream;
68 XDR *xdrs;
69 extern mutex_t authnone_lock;
70
71 /* VARIABLES PROTECTED BY authnone_lock: ap */
72
72 trace1(TR_authnone_create, 0);
73 mutex_lock(&authnone_lock);
73 (void) mutex_lock(&authnone_lock);
74 ap = authnone_private;
75 if (ap == NULL) {
74 ap = authnone_private;
75 if (ap == NULL) {
76/* LINTED pointer alignment */
77 ap = (struct authnone_private *)calloc(1, sizeof (*ap));
76 ap = calloc(1, sizeof (*ap));
78 if (ap == NULL) {
77 if (ap == NULL) {
79 mutex_unlock(&authnone_lock);
80 trace1(TR_authnone_create, 1);
81 return ((AUTH *)NULL);
78 (void) mutex_unlock(&authnone_lock);
79 return (NULL);
82 }
83 authnone_private = ap;
84 }
85 if (!ap->mcnt) {
86 ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
87 ap->no_client.ah_ops = authnone_ops();
88 xdrs = &xdr_stream;
89 xdrmem_create(xdrs, ap->marshalled_client,
90 (uint_t)MAX_MARSHEL_SIZE, XDR_ENCODE);
91 (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
92 (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
93 ap->mcnt = XDR_GETPOS(xdrs);
94 XDR_DESTROY(xdrs);
95 }
80 }
81 authnone_private = ap;
82 }
83 if (!ap->mcnt) {
84 ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
85 ap->no_client.ah_ops = authnone_ops();
86 xdrs = &xdr_stream;
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);
92 XDR_DESTROY(xdrs);
93 }
96 mutex_unlock(&authnone_lock);
97 trace1(TR_authnone_create, 1);
94 (void) mutex_unlock(&authnone_lock);
98 return (&ap->no_client);
99}
100
101/*ARGSUSED*/
102static bool_t
103authnone_marshal(AUTH *client, XDR *xdrs)
104{
105 struct authnone_private *ap;
95 return (&ap->no_client);
96}
97
98/*ARGSUSED*/
99static bool_t
100authnone_marshal(AUTH *client, XDR *xdrs)
101{
102 struct authnone_private *ap;
106 bool_t dummy;
103 bool_t res;
107 extern mutex_t authnone_lock;
108
104 extern mutex_t authnone_lock;
105
109 trace1(TR_authnone_marshal, 0);
110 mutex_lock(&authnone_lock);
106 (void) mutex_lock(&authnone_lock);
111 ap = authnone_private;
112 if (ap == NULL) {
107 ap = authnone_private;
108 if (ap == NULL) {
113 mutex_unlock(&authnone_lock);
114 trace1(TR_authnone_marshal, 1);
109 (void) mutex_unlock(&authnone_lock);
115 return (FALSE);
116 }
110 return (FALSE);
111 }
117 dummy = (*xdrs->x_ops->x_putbytes)(xdrs,
112 res = (*xdrs->x_ops->x_putbytes)(xdrs,
118 ap->marshalled_client, ap->mcnt);
113 ap->marshalled_client, ap->mcnt);
119 mutex_unlock(&authnone_lock);
120 trace1(TR_authnone_marshal, 1);
121 return (dummy);
114 (void) mutex_unlock(&authnone_lock);
115 return (res);
122}
123
124/* All these unused parameters are required to keep ANSI-C from grumbling */
125/*ARGSUSED*/
126static void
127authnone_verf(AUTH *client)
128{
116}
117
118/* All these unused parameters are required to keep ANSI-C from grumbling */
119/*ARGSUSED*/
120static void
121authnone_verf(AUTH *client)
122{
129 trace1(TR_authnone_verf, 0);
130 trace1(TR_authnone_verf, 1);
131}
132
133/*ARGSUSED*/
134static bool_t
135authnone_validate(AUTH *client, struct opaque_auth *opaque)
136{
123}
124
125/*ARGSUSED*/
126static bool_t
127authnone_validate(AUTH *client, struct opaque_auth *opaque)
128{
137 trace1(TR_authnone_validate, 0);
138 trace1(TR_authnone_validate, 1);
139 return (TRUE);
140}
141
142/*ARGSUSED*/
143static bool_t
144authnone_refresh(AUTH *client, void *dummy)
145{
129 return (TRUE);
130}
131
132/*ARGSUSED*/
133static bool_t
134authnone_refresh(AUTH *client, void *dummy)
135{
146 trace1(TR_authnone_refresh, 0);
147 trace1(TR_authnone_refresh, 1);
148 return (FALSE);
149}
150
151/*ARGSUSED*/
152static void
153authnone_destroy(AUTH *client)
154{
136 return (FALSE);
137}
138
139/*ARGSUSED*/
140static void
141authnone_destroy(AUTH *client)
142{
155 trace1(TR_authnone_destroy, 0);
156 trace1(TR_authnone_destroy, 1);
157}
158
159static struct auth_ops *
143}
144
145static struct auth_ops *
160authnone_ops()
146authnone_ops(void)
161{
162 static struct auth_ops ops;
163 extern mutex_t ops_lock;
164
165/* VARIABLES PROTECTED BY ops_lock: ops */
166
147{
148 static struct auth_ops ops;
149 extern mutex_t ops_lock;
150
151/* VARIABLES PROTECTED BY ops_lock: ops */
152
167 trace1(TR_authnone_ops, 0);
168 mutex_lock(&ops_lock);
153 (void) mutex_lock(&ops_lock);
169 if (ops.ah_nextverf == NULL) {
170 ops.ah_nextverf = authnone_verf;
171 ops.ah_marshal = authnone_marshal;
172 ops.ah_validate = authnone_validate;
173 ops.ah_refresh = authnone_refresh;
174 ops.ah_destroy = authnone_destroy;
175 }
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;
160 }
176 mutex_unlock(&ops_lock);
177 trace1(TR_authnone_ops, 1);
161 (void) mutex_unlock(&ops_lock);
178 return (&ops);
179}
162 return (&ops);
163}