Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/krb5/src/lib/rpc/auth_none.c
39536 views
1
/* @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC */
2
/*
3
* Copyright (c) 2010, Oracle America, Inc.
4
*
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
*
10
* * Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
*
13
* * Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in
15
* the documentation and/or other materials provided with the
16
* distribution.
17
*
18
* * Neither the name of the "Oracle America, Inc." nor the names of
19
* its contributors may be used to endorse or promote products
20
* derived from this software without specific prior written permission.
21
*
22
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
23
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
28
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
*/
34
#if !defined(lint) && defined(SCCSIDS)
35
static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
36
#endif
37
38
/*
39
* auth_none.c
40
* Creates a client authentication handle for passing "null"
41
* credentials and verifiers to remote systems.
42
*/
43
44
#include <gssrpc/types.h>
45
#include <gssrpc/xdr.h>
46
#include <gssrpc/auth.h>
47
#include <stdlib.h>
48
#define MAX_MARSHEL_SIZE 20
49
50
/*
51
* Authenticator operations routines
52
*/
53
static void authnone_verf(AUTH *);
54
static void authnone_destroy(AUTH *);
55
static bool_t authnone_marshal(AUTH *, XDR *);
56
static bool_t authnone_validate(AUTH *, struct opaque_auth *);
57
static bool_t authnone_refresh(AUTH *, struct rpc_msg *);
58
static bool_t authnone_wrap(AUTH *, XDR *, xdrproc_t, caddr_t);
59
60
static struct auth_ops ops = {
61
authnone_verf,
62
authnone_marshal,
63
authnone_validate,
64
authnone_refresh,
65
authnone_destroy,
66
authnone_wrap,
67
authnone_wrap
68
};
69
70
static struct authnone_private {
71
AUTH no_client;
72
char marshalled_client[MAX_MARSHEL_SIZE];
73
u_int mcnt;
74
} *authnone_private;
75
76
AUTH *
77
authnone_create(void)
78
{
79
struct authnone_private *ap = authnone_private;
80
XDR xdr_stream;
81
XDR *xdrs;
82
83
if (ap == 0) {
84
ap = (struct authnone_private *)calloc(1, sizeof (*ap));
85
if (ap == 0)
86
return (0);
87
authnone_private = ap;
88
}
89
if (!ap->mcnt) {
90
ap->no_client.ah_cred = ap->no_client.ah_verf = gssrpc__null_auth;
91
ap->no_client.ah_ops = &ops;
92
xdrs = &xdr_stream;
93
xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE,
94
XDR_ENCODE);
95
(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
96
(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
97
ap->mcnt = XDR_GETPOS(xdrs);
98
XDR_DESTROY(xdrs);
99
}
100
return (&ap->no_client);
101
}
102
103
/*ARGSUSED*/
104
static bool_t
105
authnone_marshal(AUTH *client, XDR *xdrs)
106
{
107
struct authnone_private *ap = authnone_private;
108
109
if (ap == 0)
110
return (0);
111
return ((*xdrs->x_ops->x_putbytes)(xdrs,
112
ap->marshalled_client, ap->mcnt));
113
}
114
115
/*ARGSUSED*/
116
static void
117
authnone_verf(AUTH *auth)
118
{
119
}
120
121
/*ARGSUSED*/
122
static bool_t
123
authnone_validate(AUTH *auth, struct opaque_auth *verf)
124
{
125
126
return (TRUE);
127
}
128
129
/*ARGSUSED*/
130
static bool_t
131
authnone_refresh(AUTH *auth, struct rpc_msg *msg)
132
{
133
134
return (FALSE);
135
}
136
137
/*ARGSUSED*/
138
static void
139
authnone_destroy(AUTH *auth)
140
{
141
}
142
143
static bool_t
144
authnone_wrap(AUTH *auth, XDR *xdrs, xdrproc_t xfunc, caddr_t xwhere)
145
{
146
return ((*xfunc)(xdrs, xwhere));
147
}
148
149