aclstruct.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. #ifndef __aclstruct_h
  7. #define __aclstruct_h
  8. /*
  9. * Description (aclstruct.h)
  10. *
  11. * This file defines types and data structures used to construct
  12. * representations of Access Control Lists (ACLs) in memory.
  13. */
  14. #include "base/systems.h"
  15. #include "base/file.h"
  16. #include "base/lexer.h"
  17. #include "nsauth.h" /* authentication types */
  18. #include "symbols.h" /* typed symbol support */
  19. #include "ipfstruct.h" /* IP address filter structures */
  20. #include "dnfstruct.h" /* DNS name filter structures */
  21. NSPR_BEGIN_EXTERN_C
  22. /* Forward type definitions */
  23. typedef struct ACL_s ACL_t;
  24. /*
  25. * Description (InetHost_t)
  26. *
  27. * This type defines a structure which represents a list of Internet
  28. * hosts by IP address and netmask, or by fully or partially
  29. * qualified DNS name.
  30. */
  31. typedef struct InetHost_s InetHost_t;
  32. struct InetHost_s {
  33. IPFilter_t inh_ipf; /* reference to IP filter */
  34. DNSFilter_t inh_dnf; /* reference to DNS filter */
  35. };
  36. /*
  37. * Description (HostSpec_t)
  38. *
  39. * This type describes a named list of hosts.
  40. */
  41. typedef struct HostSpec_s HostSpec_t;
  42. struct HostSpec_s {
  43. Symbol_t hs_sym; /* symbol name, type ACLSYMHOST */
  44. InetHost_t hs_host; /* host information */
  45. };
  46. /*
  47. * Description (UidUser_t)
  48. *
  49. * This type represents a list of users and groups using unique
  50. * integer identifiers.
  51. */
  52. typedef struct UidUser_s UidUser_t;
  53. struct UidUser_s {
  54. USIList_t uu_user; /* list of user ids */
  55. USIList_t uu_group; /* list of group ids */
  56. };
  57. /*
  58. * Description (UserSpec_t)
  59. *
  60. * This type describes a named list of users and groups.
  61. */
  62. typedef struct UserSpec_s UserSpec_t;
  63. struct UserSpec_s {
  64. Symbol_t us_sym; /* list name, type ACLSYMUSER */
  65. int us_flags; /* bit flags */
  66. #define ACL_USALL 0x1 /* any authenticated user */
  67. UidUser_t us_user; /* user list structure */
  68. };
  69. /*
  70. * Description (ACClients_t)
  71. *
  72. * This type defines the structure of action-specific information
  73. * for access control directives with action codes ACD_ALLOW and
  74. * ACD_DENY. These directives specify access control constraints
  75. * on users/groups and hosts.
  76. */
  77. typedef struct ACClients_s ACClients_t;
  78. struct ACClients_s {
  79. ACClients_t * cl_next; /* list link */
  80. HostSpec_t * cl_host; /* host specification pointer */
  81. UserSpec_t * cl_user; /* user list pointer */
  82. };
  83. /*
  84. * Description (RealmSpec_t)
  85. *
  86. * This type describes a named realm.
  87. */
  88. typedef struct RealmSpec_s RealmSpec_t;
  89. struct RealmSpec_s {
  90. Symbol_t rs_sym; /* realm name, type ACLSYMREALM */
  91. Realm_t rs_realm; /* realm information */
  92. };
  93. /*
  94. * Description (ACAuth_t)
  95. *
  96. * This type defines the structure of action-specific information
  97. * for an access control directive with action code ACD_AUTH,
  98. * which specifies information about authentication requirements.
  99. */
  100. typedef struct ACAuth_s ACAuth_t;
  101. struct ACAuth_s {
  102. RealmSpec_t * au_realm; /* pointer to realm information */
  103. };
  104. /*
  105. * Description (ACDirective_t)
  106. *
  107. * This type defines a structure which represents an access control
  108. * directive. Each directive specifies an access control action
  109. * to be taken during ACL evaluation. The ACDirective_t structure
  110. * begins an action-specific structure which contains the
  111. * parameters for an action.
  112. */
  113. typedef struct ACDirective_s ACDirective_t;
  114. struct ACDirective_s {
  115. ACDirective_t * acd_next; /* next directive in ACL */
  116. short acd_action; /* directive action code */
  117. short acd_flags; /* action modifier flags */
  118. /* Begin action-specific information */
  119. union {
  120. ACClients_t * acu_cl; /* ACD_ALLOW, ACD_DENY */
  121. ACAuth_t acu_auth; /* ACD_AUTH */
  122. } acd_u;
  123. };
  124. #define acd_cl acd_u.acu_cl
  125. #define acd_auth acd_u.acu_auth
  126. /* Define acd_action codes */
  127. #define ACD_ALLOW 1 /* allow access */
  128. #define ACD_DENY 2 /* deny access */
  129. #define ACD_AUTH 3 /* specify authentication realm */
  130. #define ACD_EXEC 4 /* execute (conditionally) */
  131. /* Define acd_flags values */
  132. #define ACD_ACTION 0xf /* bits reserved for acd_action */
  133. #define ACD_FORCE 0x10 /* force of action */
  134. #define ACD_DEFAULT 0 /* default action */
  135. #define ACD_ALWAYS ACD_FORCE /* immediate action */
  136. #define ACD_EXALLOW 0x20 /* execute if allow */
  137. #define ACD_EXDENY 0x40 /* execute if deny */
  138. #define ACD_EXAUTH 0x80 /* execute if authenticate */
  139. /*
  140. * Description (RightDef_t)
  141. *
  142. * This type describes a named access right. Each access right has
  143. * an associated unique integer id. A list of all access rights
  144. * known in an ACL context is maintained, with its head in the
  145. * ACContext_t structure.
  146. */
  147. typedef struct RightDef_s RightDef_t;
  148. struct RightDef_s {
  149. Symbol_t rd_sym; /* right name, type ACLSYMRIGHT */
  150. RightDef_t * rd_next; /* next on ACContext_t list */
  151. USI_t rd_id; /* unique id */
  152. };
  153. /*
  154. * Description (RightSpec_t)
  155. *
  156. * This type describes a named list of access rights.
  157. */
  158. typedef struct RightSpec_s RightSpec_t;
  159. struct RightSpec_s {
  160. Symbol_t rs_sym; /* list name, type ACLSYMRDEF */
  161. USIList_t rs_list; /* list of right ids */
  162. };
  163. /*
  164. * Description (ACContext_t)
  165. *
  166. * This type defines a structure that defines a context for a set
  167. * of Access Control Lists. This includes references to an
  168. * authentication database, if any, and a symbol table containing
  169. * access right definitions. It also serves as a list head for the
  170. * ACLs which are defined in the specified context.
  171. */
  172. typedef struct ACContext_s ACContext_t;
  173. struct ACContext_s {
  174. void * acc_stp; /* symbol table handle */
  175. ACL_t * acc_acls; /* list of ACLs */
  176. RightDef_t * acc_rights; /* list of access right definitions */
  177. int acc_refcnt; /* reference count */
  178. };
  179. /*
  180. * Description (ACL_t)
  181. *
  182. * This type defines the structure that represents an Access Control
  183. * List (ACL). An ACL has a user-assigned name and an internally
  184. * assigned identifier (which is an index in an object directory).
  185. * It references a list of access rights which are to be allowed or
  186. * denied, according to the ACL specifications. It references an
  187. * ordered list of ACL directives, which specify who has and who does
  188. * not have the associated access rights.
  189. */
  190. struct ACL_s {
  191. Symbol_t acl_sym; /* ACL name, type ACLSYMACL */
  192. ACL_t * acl_next; /* next ACL on a list */
  193. ACContext_t * acl_acc; /* context for this ACL */
  194. USI_t acl_id; /* id of this ACL */
  195. int acl_refcnt; /* reference count */
  196. RightSpec_t * acl_rights; /* access rights list */
  197. ACDirective_t * acl_dirf; /* first directive pointer */
  198. ACDirective_t * acl_dirl; /* last directive pointer */
  199. };
  200. /* Define symbol type codes */
  201. #define ACLSYMACL 0 /* ACL */
  202. #define ACLSYMRIGHT 1 /* access right */
  203. #define ACLSYMRDEF 2 /* access rights list */
  204. #define ACLSYMREALM 3 /* realm name */
  205. #define ACLSYMHOST 4 /* host specifications */
  206. #define ACLSYMUSER 5 /* user/group list */
  207. /*
  208. * Description (ACLFile_t)
  209. *
  210. * This type describes a structure containing information about
  211. * an open ACL description file.
  212. */
  213. typedef struct ACLFile_s ACLFile_t;
  214. struct ACLFile_s {
  215. ACLFile_t * acf_next; /* list link */
  216. char * acf_filename; /* pointer to filename string */
  217. LEXStream_t * acf_lst; /* LEX stream handle */
  218. SYS_FILE acf_fd; /* file descriptor */
  219. int acf_flags; /* bit flags (unused) */
  220. int acf_lineno; /* current line number */
  221. void * acf_token; /* LEX token handle */
  222. int acf_ttype; /* current token type */
  223. };
  224. NSPR_END_EXTERN_C
  225. #endif /* __aclstruct_h */