home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / detk45he.zip / stack16 / rpc / auth.h < prev    next >
Text File  |  1999-05-11  |  6KB  |  177 lines

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