home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 6 File / 06-File.zip / mc454src.zip / mc-4.5.4.src / os2emx / rpc / auth.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-04  |  4.9 KB  |  184 lines

  1. /* modified 1995 by hv for EMX OS/2
  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.  *    from: @(#)auth.h 1.17 88/02/08 SMI
  31.  *    from: @(#)auth.h    2.3 88/08/07 4.0 RPCSRC
  32.  *    auth.h,v 1.3 1995/05/30 04:55:09 rgrimes Exp
  33.  */
  34.  
  35. /*
  36.  * auth.h, Authentication interface.
  37.  *
  38.  * Copyright (C) 1984, Sun Microsystems, Inc.
  39.  *
  40.  * The data structures are completely opaque to the client.  The client
  41.  * is required to pass a AUTH * to routines that create rpc
  42.  * "sessions".
  43.  */
  44.  
  45. #ifndef _RPC_AUTH_H
  46. #define _RPC_AUTH_H
  47.  
  48. #if defined(__cplusplus)
  49. extern "C" {
  50. #endif
  51.  
  52. #define MAX_AUTH_BYTES    400
  53. #define MAXNETNAMELEN    255    /* maximum length of network user's name */
  54.  
  55. /*
  56.  * Status returned from authentication check
  57.  */
  58. enum auth_stat {
  59.     AUTH_OK=0,
  60.     /*
  61.      * failed at remote end
  62.      */
  63.     AUTH_BADCRED=1,            /* bogus credentials (seal broken) */
  64.     AUTH_REJECTEDCRED=2,        /* client should begin new session */
  65.     AUTH_BADVERF=3,            /* bogus verifier (seal broken) */
  66.     AUTH_REJECTEDVERF=4,        /* verifier expired or was replayed */
  67.     AUTH_TOOWEAK=5,            /* rejected due to security reasons */
  68.     /*
  69.      * failed locally
  70.     */
  71.     AUTH_INVALIDRESP=6,        /* bogus response verifier */
  72.     AUTH_FAILED=7            /* some unknown reason */
  73. };
  74.  
  75. #if (mc68000 || sparc || vax || i386 || tahoe || hp300)
  76. typedef u_long u_int32;    /* 32-bit unsigned integers */
  77. #endif
  78.  
  79. union des_block {
  80.     struct {
  81.         u_int32 high;
  82.         u_int32 low;
  83.     } key;
  84.     char c[8];
  85. };
  86. typedef union des_block des_block;
  87. bool_t xdr_des_block (XDR *, des_block *);
  88.  
  89. /*
  90.  * Authentication info.  Opaque to client.
  91.  */
  92. struct opaque_auth {
  93.     enum_t    oa_flavor;        /* flavor of auth */
  94.     caddr_t    oa_base;        /* address of more auth stuff */
  95.     u_int    oa_length;        /* not to exceed MAX_AUTH_BYTES */
  96. };
  97.  
  98.  
  99. /*
  100.  * Auth handle, interface to client side authenticators.
  101.  */
  102. typedef struct {
  103.     struct    opaque_auth    ah_cred;
  104.     struct    opaque_auth    ah_verf;
  105.     union    des_block    ah_key;
  106.     struct auth_ops {
  107.         void    (*ah_nextverf)();
  108.         int    (*ah_marshal)();    /* nextverf & serialize */
  109.         int    (*ah_validate)();    /* validate varifier */
  110.         int    (*ah_refresh)();    /* refresh credentials */
  111.         void    (*ah_destroy)();    /* destroy this structure */
  112.     } *ah_ops;
  113.     caddr_t ah_private;
  114. } AUTH;
  115.  
  116.  
  117. /*
  118.  * Authentication ops.
  119.  * The ops and the auth handle provide the interface to the authenticators.
  120.  *
  121.  * AUTH    *auth;
  122.  * XDR    *xdrs;
  123.  * struct opaque_auth verf;
  124.  */
  125. #define AUTH_NEXTVERF(auth)        \
  126.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  127. #define auth_nextverf(auth)        \
  128.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  129.  
  130. #define AUTH_MARSHALL(auth, xdrs)    \
  131.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  132. #define auth_marshall(auth, xdrs)    \
  133.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  134.  
  135. #define AUTH_VALIDATE(auth, verfp)    \
  136.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  137. #define auth_validate(auth, verfp)    \
  138.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  139.  
  140. #define AUTH_REFRESH(auth)        \
  141.         ((*((auth)->ah_ops->ah_refresh))(auth))
  142. #define auth_refresh(auth)        \
  143.         ((*((auth)->ah_ops->ah_refresh))(auth))
  144.  
  145. #define AUTH_DESTROY(auth)        \
  146.         ((*((auth)->ah_ops->ah_destroy))(auth))
  147. #define auth_destroy(auth)        \
  148.         ((*((auth)->ah_ops->ah_destroy))(auth))
  149.  
  150.  
  151. extern struct opaque_auth _null_auth;
  152.  
  153.  
  154. /*
  155.  * These are the various implementations of client side authenticators.
  156.  */
  157.  
  158. /*
  159.  * Unix style authentication
  160.  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
  161.  *    char *machname;
  162.  *    int uid;
  163.  *    int gid;
  164.  *    int len;
  165.  *    int *aup_gids;
  166.  */
  167. AUTH *authunix_create        (char *, int, int, int, int *);
  168. AUTH *authunix_create_default    (void);
  169. AUTH *authnone_create        (void);
  170. AUTH *authdes_create();
  171.  
  172. #define AUTH_NONE    0        /* no authentication */
  173. #define    AUTH_NULL    0        /* backward compatibility */
  174. #define    AUTH_UNIX    1        /* unix style (uid, gids) */
  175. #define    AUTH_SHORT    2        /* short hand unix style */
  176. #define AUTH_DES    3        /* des style (encrypted timestamps) */
  177.  
  178. #if defined(__cplusplus)
  179. }
  180. #endif
  181.  
  182.  
  183. #endif /* !_RPC_AUTH_H */
  184.