aclstruct.h 7.5 KB

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