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