2 * Copyright (c) 2010, Oracle America, Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 * * Neither the name of the "Oracle America, Inc." nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * Creates a client authentication handle for passing "null"
34 * credentials and verifiers to remote systems.
38 #include <libc-lock.h>
40 #define MAX_MARSHAL_SIZE 20
43 * Authenticator operations routines
45 static void authnone_verf (AUTH
*);
46 static void authnone_destroy (AUTH
*);
47 static bool_t
authnone_marshal (AUTH
*, XDR
*);
48 static bool_t
authnone_validate (AUTH
*, struct opaque_auth
*);
49 static bool_t
authnone_refresh (AUTH
*);
51 static const struct auth_ops ops
= {
59 /* Internal data and routines */
61 struct authnone_private_s
{
63 char marshalled_client
[MAX_MARSHAL_SIZE
];
67 static struct authnone_private_s authnone_private
;
68 __libc_once_define(static, authnone_private_guard
);
70 static void authnone_create_once (void);
73 authnone_create_once (void)
75 struct authnone_private_s
*ap
;
79 ap
= &authnone_private
;
81 ap
->no_client
.ah_cred
= ap
->no_client
.ah_verf
= _null_auth
;
82 ap
->no_client
.ah_ops
= (struct auth_ops
*) &ops
;
84 xdrmem_create (xdrs
, ap
->marshalled_client
,
85 (u_int
) MAX_MARSHAL_SIZE
, XDR_ENCODE
);
86 (void) xdr_opaque_auth (xdrs
, &ap
->no_client
.ah_cred
);
87 (void) xdr_opaque_auth (xdrs
, &ap
->no_client
.ah_verf
);
88 ap
->mcnt
= XDR_GETPOS (xdrs
);
93 authnone_create (void)
95 __libc_once (authnone_private_guard
, authnone_create_once
);
96 return &authnone_private
.no_client
;
98 libc_hidden_nolink_sunrpc (authnone_create
, GLIBC_2_0
)
101 authnone_marshal (AUTH
*client
, XDR
*xdrs
)
103 struct authnone_private_s
*ap
;
105 /* authnone_create returned authnone_private->no_client, which is
106 the first field of struct authnone_private_s. */
107 ap
= (struct authnone_private_s
*) client
;
110 return (*xdrs
->x_ops
->x_putbytes
) (xdrs
, ap
->marshalled_client
, ap
->mcnt
);
114 authnone_verf (AUTH
*auth
)
119 authnone_validate (AUTH
*auth
, struct opaque_auth
*oa
)
125 authnone_refresh (AUTH
*auth
)
131 authnone_destroy (AUTH
*auth
)