Back to index

glibc  2.9
auth_none.c
Go to the documentation of this file.
00001 /*
00002  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
00003  * unrestricted use provided that this legend is included on all tape
00004  * media and as a part of the software program in whole or part.  Users
00005  * may copy or modify Sun RPC without charge, but are not authorized
00006  * to license or distribute it to anyone else except as part of a product or
00007  * program developed by the user.
00008  *
00009  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
00010  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
00011  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
00012  *
00013  * Sun RPC is provided with no support and without any obligation on the
00014  * part of Sun Microsystems, Inc. to assist in its use, correction,
00015  * modification or enhancement.
00016  *
00017  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
00018  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
00019  * OR ANY PART THEREOF.
00020  *
00021  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
00022  * or profits or other special, indirect and consequential damages, even if
00023  * Sun has been advised of the possibility of such damages.
00024  *
00025  * Sun Microsystems, Inc.
00026  * 2550 Garcia Avenue
00027  * Mountain View, California  94043
00028  */
00029 /*
00030  * Copyright (C) 1984, Sun Microsystems, Inc.
00031  */
00032 /*
00033  * auth_none.c
00034  * Creates a client authentication handle for passing "null"
00035  * credentials and verifiers to remote systems.
00036  */
00037 
00038 #include <rpc/rpc.h>
00039 #include <bits/libc-lock.h>
00040 
00041 #define MAX_MARSHAL_SIZE 20
00042 
00043 /*
00044  * Authenticator operations routines
00045  */
00046 static void authnone_verf (AUTH *);
00047 static void authnone_destroy (AUTH *);
00048 static bool_t authnone_marshal (AUTH *, XDR *);
00049 static bool_t authnone_validate (AUTH *, struct opaque_auth *);
00050 static bool_t authnone_refresh (AUTH *);
00051 
00052 static const struct auth_ops ops = {
00053   authnone_verf,
00054   authnone_marshal,
00055   authnone_validate,
00056   authnone_refresh,
00057   authnone_destroy
00058 };
00059 
00060 /* Internal data and routines */
00061 
00062 struct authnone_private_s {
00063   AUTH no_client;
00064   char marshalled_client[MAX_MARSHAL_SIZE];
00065   u_int mcnt;
00066 };
00067 
00068 static struct authnone_private_s authnone_private;
00069 __libc_once_define(static, authnone_private_guard);
00070 
00071 static void authnone_create_once (void);
00072 
00073 static void
00074 authnone_create_once (void)
00075 {
00076   struct authnone_private_s *ap;
00077   XDR xdr_stream;
00078   XDR *xdrs;
00079 
00080   ap = &authnone_private;
00081 
00082   ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
00083   ap->no_client.ah_ops = (struct auth_ops *) &ops;
00084   xdrs = &xdr_stream;
00085   INTUSE(xdrmem_create) (xdrs, ap->marshalled_client,
00086                       (u_int) MAX_MARSHAL_SIZE, XDR_ENCODE);
00087   (void) INTUSE(xdr_opaque_auth) (xdrs, &ap->no_client.ah_cred);
00088   (void) INTUSE(xdr_opaque_auth) (xdrs, &ap->no_client.ah_verf);
00089   ap->mcnt = XDR_GETPOS (xdrs);
00090   XDR_DESTROY (xdrs);
00091 }
00092 
00093 AUTH *
00094 authnone_create (void)
00095 {
00096   __libc_once (authnone_private_guard, authnone_create_once);
00097   return &authnone_private.no_client;
00098 }
00099 INTDEF (authnone_create)
00100 
00101 static bool_t
00102 authnone_marshal (AUTH *client, XDR *xdrs)
00103 {
00104   struct authnone_private_s *ap;
00105 
00106   /* authnone_create returned authnone_private->no_client, which is
00107      the first field of struct authnone_private_s.  */
00108   ap = (struct authnone_private_s *) client;
00109   if (ap == NULL)
00110     return FALSE;
00111   return (*xdrs->x_ops->x_putbytes) (xdrs, ap->marshalled_client, ap->mcnt);
00112 }
00113 
00114 static void
00115 authnone_verf (AUTH *auth)
00116 {
00117 }
00118 
00119 static bool_t
00120 authnone_validate (AUTH *auth, struct opaque_auth *oa)
00121 {
00122   return TRUE;
00123 }
00124 
00125 static bool_t
00126 authnone_refresh (AUTH *auth)
00127 {
00128   return FALSE;
00129 }
00130 
00131 static void
00132 authnone_destroy (AUTH *auth)
00133 {
00134 }