aclstruct.h 7.7 KB

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