GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libc/rpc/auth_none.c Lines: 0 23 0.0 %
Date: 2017-11-07 Branches: 0 10 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: auth_none.c,v 1.14 2015/11/01 03:45:29 guenther Exp $ */
2
3
/*
4
 * Copyright (c) 2010, Oracle America, Inc.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are
8
 * met:
9
 *
10
 *     * Redistributions of source code must retain the above copyright
11
 *       notice, this list of conditions and the following disclaimer.
12
 *     * Redistributions in binary form must reproduce the above
13
 *       copyright notice, this list of conditions and the following
14
 *       disclaimer in the documentation and/or other materials
15
 *       provided with the distribution.
16
 *     * Neither the name of the "Oracle America, Inc." nor the names of its
17
 *       contributors may be used to endorse or promote products derived
18
 *       from this software without specific prior written permission.
19
 *
20
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23
 *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
 *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25
 *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
 *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27
 *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
 *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29
 *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30
 *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
 */
33
34
/*
35
 * auth_none.c
36
 * Creates a client authentication handle for passing "null"
37
 * credentials and verifiers to remote systems.
38
 */
39
40
#include <stdlib.h>
41
#include <rpc/types.h>
42
#include <rpc/rpc.h>
43
#include <rpc/xdr.h>
44
#include <rpc/auth.h>
45
#define MAX_MARSHEL_SIZE 20
46
47
/*
48
 * Authenticator operations routines
49
 */
50
static void	authnone_destroy(struct __rpc_auth *);
51
static void	authnone_verf(struct __rpc_auth *);
52
static bool_t	authnone_validate(struct __rpc_auth *, struct opaque_auth *);
53
static bool_t	authnone_marshal(struct __rpc_auth *, XDR *);
54
static bool_t	authnone_refresh(struct __rpc_auth *);
55
56
static struct auth_ops ops = {
57
	authnone_verf,
58
	authnone_marshal,
59
	authnone_validate,
60
	authnone_refresh,
61
	authnone_destroy
62
};
63
64
static struct authnone_private {
65
	AUTH	no_client;
66
	char	marshalled_client[MAX_MARSHEL_SIZE];
67
	u_int	mcnt;
68
} *authnone_private;
69
70
AUTH *
71
authnone_create(void)
72
{
73
	struct authnone_private *ap = authnone_private;
74
	XDR xdr_stream;
75
	XDR *xdrs;
76
77
	if (ap == NULL) {
78
		ap = calloc(1, sizeof (*ap));
79
		if (ap == NULL)
80
			return (NULL);
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 = &ops;
86
		xdrs = &xdr_stream;
87
		xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE,
88
		    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
	}
94
	return (&ap->no_client);
95
}
96
DEF_WEAK(authnone_create);
97
98
static bool_t
99
authnone_marshal(AUTH *client, XDR *xdrs)
100
{
101
	struct authnone_private *ap = authnone_private;
102
103
	if (ap == NULL)
104
		return (0);
105
	return ((*xdrs->x_ops->x_putbytes)(xdrs,
106
	    ap->marshalled_client, ap->mcnt));
107
}
108
109
static void
110
authnone_verf(struct __rpc_auth *none)
111
{
112
}
113
114
static bool_t
115
authnone_validate(struct __rpc_auth *none, struct opaque_auth *noauth)
116
{
117
118
	return (TRUE);
119
}
120
121
static bool_t
122
authnone_refresh(struct __rpc_auth *none)
123
{
124
125
	return (FALSE);
126
}
127
128
static void
129
authnone_destroy(struct __rpc_auth *none)
130
{
131
}