auth.h 4.7 KB

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