xref: /csrg-svn/lib/librpc/rpc/auth_none.c (revision 45072)
1*45072Smckusick /* @(#)auth_none.c	2.1 88/07/29 4.0 RPCSRC */
2*45072Smckusick /*
3*45072Smckusick  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
4*45072Smckusick  * unrestricted use provided that this legend is included on all tape
5*45072Smckusick  * media and as a part of the software program in whole or part.  Users
6*45072Smckusick  * may copy or modify Sun RPC without charge, but are not authorized
7*45072Smckusick  * to license or distribute it to anyone else except as part of a product or
8*45072Smckusick  * program developed by the user.
9*45072Smckusick  *
10*45072Smckusick  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
11*45072Smckusick  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
12*45072Smckusick  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
13*45072Smckusick  *
14*45072Smckusick  * Sun RPC is provided with no support and without any obligation on the
15*45072Smckusick  * part of Sun Microsystems, Inc. to assist in its use, correction,
16*45072Smckusick  * modification or enhancement.
17*45072Smckusick  *
18*45072Smckusick  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
19*45072Smckusick  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
20*45072Smckusick  * OR ANY PART THEREOF.
21*45072Smckusick  *
22*45072Smckusick  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
23*45072Smckusick  * or profits or other special, indirect and consequential damages, even if
24*45072Smckusick  * Sun has been advised of the possibility of such damages.
25*45072Smckusick  *
26*45072Smckusick  * Sun Microsystems, Inc.
27*45072Smckusick  * 2550 Garcia Avenue
28*45072Smckusick  * Mountain View, California  94043
29*45072Smckusick  */
30*45072Smckusick #if !defined(lint) && defined(SCCSIDS)
31*45072Smckusick static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
32*45072Smckusick #endif
33*45072Smckusick 
34*45072Smckusick /*
35*45072Smckusick  * auth_none.c
36*45072Smckusick  * Creates a client authentication handle for passing "null"
37*45072Smckusick  * credentials and verifiers to remote systems.
38*45072Smckusick  *
39*45072Smckusick  * Copyright (C) 1984, Sun Microsystems, Inc.
40*45072Smckusick  */
41*45072Smckusick 
42*45072Smckusick #include <rpc/types.h>
43*45072Smckusick #include <rpc/xdr.h>
44*45072Smckusick #include <rpc/auth.h>
45*45072Smckusick #define MAX_MARSHEL_SIZE 20
46*45072Smckusick 
47*45072Smckusick /*
48*45072Smckusick  * Authenticator operations routines
49*45072Smckusick  */
50*45072Smckusick static void	authnone_verf();
51*45072Smckusick static void	authnone_destroy();
52*45072Smckusick static bool_t	authnone_marshal();
53*45072Smckusick static bool_t	authnone_validate();
54*45072Smckusick static bool_t	authnone_refresh();
55*45072Smckusick 
56*45072Smckusick static struct auth_ops ops = {
57*45072Smckusick 	authnone_verf,
58*45072Smckusick 	authnone_marshal,
59*45072Smckusick 	authnone_validate,
60*45072Smckusick 	authnone_refresh,
61*45072Smckusick 	authnone_destroy
62*45072Smckusick };
63*45072Smckusick 
64*45072Smckusick static struct authnone_private {
65*45072Smckusick 	AUTH	no_client;
66*45072Smckusick 	char	marshalled_client[MAX_MARSHEL_SIZE];
67*45072Smckusick 	u_int	mcnt;
68*45072Smckusick } *authnone_private;
69*45072Smckusick 
70*45072Smckusick AUTH *
authnone_create()71*45072Smckusick authnone_create()
72*45072Smckusick {
73*45072Smckusick 	register struct authnone_private *ap = authnone_private;
74*45072Smckusick 	XDR xdr_stream;
75*45072Smckusick 	register XDR *xdrs;
76*45072Smckusick 
77*45072Smckusick 	if (ap == 0) {
78*45072Smckusick 		ap = (struct authnone_private *)calloc(1, sizeof (*ap));
79*45072Smckusick 		if (ap == 0)
80*45072Smckusick 			return (0);
81*45072Smckusick 		authnone_private = ap;
82*45072Smckusick 	}
83*45072Smckusick 	if (!ap->mcnt) {
84*45072Smckusick 		ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
85*45072Smckusick 		ap->no_client.ah_ops = &ops;
86*45072Smckusick 		xdrs = &xdr_stream;
87*45072Smckusick 		xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE,
88*45072Smckusick 		    XDR_ENCODE);
89*45072Smckusick 		(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
90*45072Smckusick 		(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
91*45072Smckusick 		ap->mcnt = XDR_GETPOS(xdrs);
92*45072Smckusick 		XDR_DESTROY(xdrs);
93*45072Smckusick 	}
94*45072Smckusick 	return (&ap->no_client);
95*45072Smckusick }
96*45072Smckusick 
97*45072Smckusick /*ARGSUSED*/
98*45072Smckusick static bool_t
authnone_marshal(client,xdrs)99*45072Smckusick authnone_marshal(client, xdrs)
100*45072Smckusick 	AUTH *client;
101*45072Smckusick 	XDR *xdrs;
102*45072Smckusick {
103*45072Smckusick 	register struct authnone_private *ap = authnone_private;
104*45072Smckusick 
105*45072Smckusick 	if (ap == 0)
106*45072Smckusick 		return (0);
107*45072Smckusick 	return ((*xdrs->x_ops->x_putbytes)(xdrs,
108*45072Smckusick 	    ap->marshalled_client, ap->mcnt));
109*45072Smckusick }
110*45072Smckusick 
111*45072Smckusick static void
authnone_verf()112*45072Smckusick authnone_verf()
113*45072Smckusick {
114*45072Smckusick }
115*45072Smckusick 
116*45072Smckusick static bool_t
authnone_validate()117*45072Smckusick authnone_validate()
118*45072Smckusick {
119*45072Smckusick 
120*45072Smckusick 	return (TRUE);
121*45072Smckusick }
122*45072Smckusick 
123*45072Smckusick static bool_t
authnone_refresh()124*45072Smckusick authnone_refresh()
125*45072Smckusick {
126*45072Smckusick 
127*45072Smckusick 	return (FALSE);
128*45072Smckusick }
129*45072Smckusick 
130*45072Smckusick static void
authnone_destroy()131*45072Smckusick authnone_destroy()
132*45072Smckusick {
133*45072Smckusick }
134