home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / armlinux / alpha / PARTITIONS / USR_GZ / usr / include / rpc / auth.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-14  |  5.1 KB  |  185 lines

  1. /* @(#)auth.h    2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */
  2. /*
  3.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  4.  * unrestricted use provided that this legend is included on all tape
  5.  * media and as a part of the software program in whole or part.  Users
  6.  * may copy or modify Sun RPC without charge, but are not authorized
  7.  * to license or distribute it to anyone else except as part of a product or
  8.  * program developed by the user.
  9.  * 
  10.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  11.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  12.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  13.  * 
  14.  * Sun RPC is provided with no support and without any obligation on the
  15.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  16.  * modification or enhancement.
  17.  * 
  18.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  19.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  20.  * OR ANY PART THEREOF.
  21.  * 
  22.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  23.  * or profits or other special, indirect and consequential damages, even if
  24.  * Sun has been advised of the possibility of such damages.
  25.  * 
  26.  * Sun Microsystems, Inc.
  27.  * 2550 Garcia Avenue
  28.  * Mountain View, California  94043
  29.  */
  30.  
  31. /*
  32.  * auth.h, Authentication interface.
  33.  *
  34.  * Copyright (C) 1984, Sun Microsystems, Inc.
  35.  *
  36.  * The data structures are completely opaque to the client.  The client
  37.  * is required to pass a AUTH * to routines that create rpc
  38.  * "sessions".
  39.  */
  40.  
  41. #ifndef _RPC_AUTH_H
  42. #define _RPC_AUTH_H
  43.  
  44. #include <features.h>
  45.  
  46. #define MAX_AUTH_BYTES    400
  47. #define MAXNETNAMELEN    255    /* maximum length of network user's name */
  48.  
  49. __BEGIN_DECLS
  50.  
  51. /*
  52.  * Status returned from authentication check
  53.  */
  54. enum auth_stat {
  55.     AUTH_OK=0,
  56.     /*
  57.      * failed at remote end
  58.      */
  59.     AUTH_BADCRED=1,            /* bogus credentials (seal broken) */
  60.     AUTH_REJECTEDCRED=2,        /* client should begin new session */
  61.     AUTH_BADVERF=3,            /* bogus verifier (seal broken) */
  62.     AUTH_REJECTEDVERF=4,        /* verifier expired or was replayed */
  63.     AUTH_TOOWEAK=5,            /* rejected due to security reasons */
  64.     /*
  65.      * failed locally
  66.     */
  67.     AUTH_INVALIDRESP=6,        /* bogus response verifier */
  68.     AUTH_FAILED=7            /* some unknown reason */
  69. };
  70.  
  71. #if (__mc68000__ || __sparc__ || __vax__ || __i386__ || __arm__)
  72. typedef u_long u_int32;    /* 32-bit unsigned integers */
  73. #endif
  74.  
  75. union des_block {
  76.     struct {
  77.         u_int32 high;
  78.         u_int32 low;
  79.     } key;
  80.     char c[8];
  81. };
  82.  
  83. typedef union des_block des_block;
  84.  
  85.  
  86. extern bool_t xdr_des_block();
  87.  
  88. /*
  89.  * Authentication info.  Opaque to client.
  90.  */
  91. struct opaque_auth {
  92.     enum_t    oa_flavor;        /* flavor of auth */
  93.     caddr_t    oa_base;        /* address of more auth stuff */
  94.     u_int    oa_length;        /* not to exceed MAX_AUTH_BYTES */
  95. };
  96.  
  97.  
  98. /*
  99.  * Auth handle, interface to client side authenticators.
  100.  */
  101. typedef struct {
  102.     struct    opaque_auth    ah_cred;
  103.     struct    opaque_auth    ah_verf;
  104.     union    des_block    ah_key;
  105.     struct auth_ops {
  106.         void    (*ah_nextverf)();
  107.         int    (*ah_marshal)();    /* nextverf & serialize */
  108.         int    (*ah_validate)();    /* validate varifier */
  109.         int    (*ah_refresh)();    /* refresh credentials */
  110.         void    (*ah_destroy)();    /* destroy this structure */
  111.     } *ah_ops;
  112.     caddr_t ah_private;
  113. } AUTH;
  114.  
  115.  
  116. /*
  117.  * Authentication ops.
  118.  * The ops and the auth handle provide the interface to the authenticators.
  119.  *
  120.  * AUTH    *auth;
  121.  * XDR    *xdrs;
  122.  * struct opaque_auth verf;
  123.  */
  124. #define AUTH_NEXTVERF(auth)        \
  125.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  126. #define auth_nextverf(auth)        \
  127.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  128.  
  129. #define AUTH_MARSHALL(auth, xdrs)    \
  130.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  131. #define auth_marshall(auth, xdrs)    \
  132.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  133.  
  134. #define AUTH_VALIDATE(auth, verfp)    \
  135.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  136. #define auth_validate(auth, verfp)    \
  137.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  138.  
  139. #define AUTH_REFRESH(auth)        \
  140.         ((*((auth)->ah_ops->ah_refresh))(auth))
  141. #define auth_refresh(auth)        \
  142.         ((*((auth)->ah_ops->ah_refresh))(auth))
  143.  
  144. #define AUTH_DESTROY(auth)        \
  145.         ((*((auth)->ah_ops->ah_destroy))(auth))
  146. #define auth_destroy(auth)        \
  147.         ((*((auth)->ah_ops->ah_destroy))(auth))
  148.  
  149.  
  150. extern struct opaque_auth _null_auth;
  151.  
  152.  
  153. /*
  154.  * These are the various implementations of client side authenticators.
  155.  */
  156.  
  157. /*
  158.  * Unix style authentication
  159.  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
  160.  *    char *machname;
  161.  *    int uid;
  162.  *    int gid;
  163.  *    int len;
  164.  *    int *aup_gids;
  165.  */
  166. extern AUTH *authunix_create __P((char * __machine, uid_t __uid, gid_t __gid,
  167.         int __len, gid_t * __aup_gids));
  168. extern AUTH *authunix_create_default __P((void));    /* takes no parameters */
  169. extern AUTH *authnone_create __P((void));        /* takes no parameters */
  170. struct sockaddr;
  171.  
  172. extern AUTH *authdes_create __P((char * __machine, u_int __window,
  173.         struct sockaddr *__syncaddr, des_block*__ckey));
  174.  
  175.  
  176. __END_DECLS
  177.  
  178. #define AUTH_NONE    0        /* no authentication */
  179. #define    AUTH_NULL    0        /* backward compatibility */
  180. #define    AUTH_UNIX    1        /* unix style (uid, gids) */
  181. #define    AUTH_SHORT    2        /* short hand unix style */
  182. #define AUTH_DES    3        /* des style (encrypted timestamps) */
  183.  
  184. #endif /* _PRC_AUTH_H */
  185.