auth.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:6k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* auth.h - authentication interface */
  2. /* Copyright 1984-1992 Wind River Systems, Inc. */
  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. /*      @(#)auth.h 1.1 86/02/03 SMI      */
  32. /*
  33. * auth.h, Authentication interface.
  34. *
  35. * Copyright (C) 1984, Sun Microsystems, Inc.
  36. *
  37. * The data structures are completely opaque to the client.  The client
  38. * is required to pass a AUTH * to routines that create rpc
  39. * "sessions".
  40. */
  41. /*
  42. modification history
  43. --------------------
  44. 01i,22sep92,rrr  added support for c++
  45. 01h,26may92,rrr  the tree shuffle
  46. 01g,26feb92,wmd  added #pragma align 1 to align properly data structures.
  47. 01f,23feb91,del  removed useless checking and typedef of u_int32 as u_long.
  48. 01e,24oct90,shl  deleted redundant function declarations.
  49. 01d,05oct90,shl  added ANSI function prototypes.
  50.                  made #endif ANSI style.
  51.                  added copyright notice.
  52. 01c,30apr90,gae  fixed definition of u_int32 -- dependent of compiler define.
  53. 01b,26oct89,hjb  upgraded to release 4.0
  54. */
  55. #ifndef __INCauthh
  56. #define __INCauthh
  57. #ifdef __cplusplus
  58. extern "C" {
  59. #endif
  60. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  61. #pragma align 1                 /* tell gcc960 not to optimize alignments */
  62. #endif  /* CPU_FAMILY==I960 */
  63. #define MAX_AUTH_BYTES 400
  64. #define MAXNETNAMELEN 255   /* maximum length of network user's name - 4.0 */
  65. /*
  66.  * Status returned from authentication check
  67.  */
  68. enum auth_stat {
  69. AUTH_OK=0,
  70. /*
  71.  * failed at remote end
  72.  */
  73. AUTH_BADCRED=1, /* bogus credentials (seal broken) */
  74. AUTH_REJECTEDCRED=2, /* client should begin new session */
  75. AUTH_BADVERF=3, /* bogus verifier (seal broken) */
  76. AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */
  77. AUTH_TOOWEAK=5, /* rejected due to security reasons */
  78. /*
  79.  * failed locally
  80. */
  81. AUTH_INVALIDRESP=6, /* bogus response verifier */
  82. AUTH_FAILED=7 /* some unknown reason */
  83. };
  84. union des_block {
  85. struct {
  86. u_long high;
  87. u_long low;
  88. } key;
  89. char c[8];
  90. };
  91. typedef union des_block des_block;
  92. /*
  93.  * Authentication info.  Opaque to client.
  94.  */
  95. struct opaque_auth {
  96. enum_t oa_flavor; /* flavor of auth */
  97. caddr_t oa_base; /* address of more auth stuff */
  98. u_int oa_length; /* not to exceed MAX_AUTH_BYTES */
  99. };
  100. /*
  101.  * Auth handle, interface to client side authenticators.
  102.  */
  103. typedef struct {
  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)();
  109. int (*ah_marshal)(); /* nextverf & serialize */
  110. int (*ah_validate)(); /* validate varifier */
  111. int (*ah_refresh)(); /* refresh credentials */
  112. void (*ah_destroy)(); /* destroy this structure */
  113. } *ah_ops;
  114. caddr_t ah_private;
  115. } AUTH;
  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. #define AUTH_MARSHALL(auth, xdrs)
  129. ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  130. #define auth_marshall(auth, xdrs)
  131. ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  132. #define AUTH_VALIDATE(auth, verfp)
  133. ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  134. #define auth_validate(auth, verfp)
  135. ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  136. #define AUTH_REFRESH(auth)
  137. ((*((auth)->ah_ops->ah_refresh))(auth))
  138. #define auth_refresh(auth)
  139. ((*((auth)->ah_ops->ah_refresh))(auth))
  140. #define AUTH_DESTROY(auth)
  141. ((*((auth)->ah_ops->ah_destroy))(auth))
  142. #define auth_destroy(auth)
  143. ((*((auth)->ah_ops->ah_destroy))(auth))
  144. extern struct opaque_auth _null_auth;
  145. /*
  146.  * These are the various implementations of client side authenticators.
  147.  */
  148. /*
  149.  * Unix style authentication
  150.  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
  151.  * char *machname;
  152.  * int uid;
  153.  * int gid;
  154.  * int len;
  155.  * int *aup_gids;
  156.  */
  157. extern AUTH *authdes_create (); /* 4.0 */
  158. #define AUTH_NONE 0 /* no authentication -- 4.0 */
  159. #define AUTH_NULL 0 /* backward compatibility */
  160. #define AUTH_UNIX 1 /* unix style (uid, gids) */
  161. #define AUTH_SHORT 2 /* short hand unix style */
  162. /* function declarations */
  163. #if defined(__STDC__) || defined(__cplusplus)
  164. extern   AUTH * authnone_create (void);
  165. extern    AUTH * authunix_create (char *machname, int uid, int gid,
  166.  int len, int *aup_gids);
  167. extern    AUTH * authunix_create_default(void); /* takes no parameters */
  168. extern   bool_t xdr_des_block (XDR *xdrs, union des_block *blkp);
  169. #else
  170. extern    AUTH * authunix_create ();
  171. extern   AUTH * authnone_create ();
  172. extern    AUTH * authunix_create_default();    /* takes no parameters */
  173. extern   bool_t xdr_des_block ();
  174. #endif /* __STDC__ */
  175. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  176. #pragma align 0                 /* turn off alignment requirement */
  177. #endif  /* CPU_FAMILY==I960 */
  178. #ifdef __cplusplus
  179. }
  180. #endif
  181. #endif /* __INCauthh */