aclstruct.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifndef __aclstruct_h
  39. #define __aclstruct_h
  40. /*
  41. * Description (aclstruct.h)
  42. *
  43. * This file defines types and data structures used to construct
  44. * representations of Access Control Lists (ACLs) in memory.
  45. */
  46. #include "base/systems.h"
  47. #include "base/file.h"
  48. #include "base/lexer.h"
  49. #include "nsauth.h" /* authentication types */
  50. #include "symbols.h" /* typed symbol support */
  51. #include "ipfstruct.h" /* IP address filter structures */
  52. #include "dnfstruct.h" /* DNS name filter structures */
  53. NSPR_BEGIN_EXTERN_C
  54. /* Forward type definitions */
  55. typedef struct ACL_s ACL_t;
  56. /*
  57. * Description (InetHost_t)
  58. *
  59. * This type defines a structure which represents a list of Internet
  60. * hosts by IP address and netmask, or by fully or partially
  61. * qualified DNS name.
  62. */
  63. typedef struct InetHost_s InetHost_t;
  64. struct InetHost_s {
  65. IPFilter_t inh_ipf; /* reference to IP filter */
  66. DNSFilter_t inh_dnf; /* reference to DNS filter */
  67. };
  68. /*
  69. * Description (HostSpec_t)
  70. *
  71. * This type describes a named list of hosts.
  72. */
  73. typedef struct HostSpec_s HostSpec_t;
  74. struct HostSpec_s {
  75. Symbol_t hs_sym; /* symbol name, type ACLSYMHOST */
  76. InetHost_t hs_host; /* host information */
  77. };
  78. /*
  79. * Description (UidUser_t)
  80. *
  81. * This type represents a list of users and groups using unique
  82. * integer identifiers.
  83. */
  84. typedef struct UidUser_s UidUser_t;
  85. struct UidUser_s {
  86. USIList_t uu_user; /* list of user ids */
  87. USIList_t uu_group; /* list of group ids */
  88. };
  89. /*
  90. * Description (UserSpec_t)
  91. *
  92. * This type describes a named list of users and groups.
  93. */
  94. typedef struct UserSpec_s UserSpec_t;
  95. struct UserSpec_s {
  96. Symbol_t us_sym; /* list name, type ACLSYMUSER */
  97. int us_flags; /* bit flags */
  98. #define ACL_USALL 0x1 /* any authenticated user */
  99. UidUser_t us_user; /* user list structure */
  100. };
  101. /*
  102. * Description (ACClients_t)
  103. *
  104. * This type defines the structure of action-specific information
  105. * for access control directives with action codes ACD_ALLOW and
  106. * ACD_DENY. These directives specify access control constraints
  107. * on users/groups and hosts.
  108. */
  109. typedef struct ACClients_s ACClients_t;
  110. struct ACClients_s {
  111. ACClients_t * cl_next; /* list link */
  112. HostSpec_t * cl_host; /* host specification pointer */
  113. UserSpec_t * cl_user; /* user list pointer */
  114. };
  115. /*
  116. * Description (RealmSpec_t)
  117. *
  118. * This type describes a named realm.
  119. */
  120. typedef struct RealmSpec_s RealmSpec_t;
  121. struct RealmSpec_s {
  122. Symbol_t rs_sym; /* realm name, type ACLSYMREALM */
  123. Realm_t rs_realm; /* realm information */
  124. };
  125. /*
  126. * Description (ACAuth_t)
  127. *
  128. * This type defines the structure of action-specific information
  129. * for an access control directive with action code ACD_AUTH,
  130. * which specifies information about authentication requirements.
  131. */
  132. typedef struct ACAuth_s ACAuth_t;
  133. struct ACAuth_s {
  134. RealmSpec_t * au_realm; /* pointer to realm information */
  135. };
  136. /*
  137. * Description (ACDirective_t)
  138. *
  139. * This type defines a structure which represents an access control
  140. * directive. Each directive specifies an access control action
  141. * to be taken during ACL evaluation. The ACDirective_t structure
  142. * begins an action-specific structure which contains the
  143. * parameters for an action.
  144. */
  145. typedef struct ACDirective_s ACDirective_t;
  146. struct ACDirective_s {
  147. ACDirective_t * acd_next; /* next directive in ACL */
  148. short acd_action; /* directive action code */
  149. short acd_flags; /* action modifier flags */
  150. /* Begin action-specific information */
  151. union {
  152. ACClients_t * acu_cl; /* ACD_ALLOW, ACD_DENY */
  153. ACAuth_t acu_auth; /* ACD_AUTH */
  154. } acd_u;
  155. };
  156. #define acd_cl acd_u.acu_cl
  157. #define acd_auth acd_u.acu_auth
  158. /* Define acd_action codes */
  159. #define ACD_ALLOW 1 /* allow access */
  160. #define ACD_DENY 2 /* deny access */
  161. #define ACD_AUTH 3 /* specify authentication realm */
  162. #define ACD_EXEC 4 /* execute (conditionally) */
  163. /* Define acd_flags values */
  164. #define ACD_ACTION 0xf /* bits reserved for acd_action */
  165. #define ACD_FORCE 0x10 /* force of action */
  166. #define ACD_DEFAULT 0 /* default action */
  167. #define ACD_ALWAYS ACD_FORCE /* immediate action */
  168. #define ACD_EXALLOW 0x20 /* execute if allow */
  169. #define ACD_EXDENY 0x40 /* execute if deny */
  170. #define ACD_EXAUTH 0x80 /* execute if authenticate */
  171. /*
  172. * Description (RightDef_t)
  173. *
  174. * This type describes a named access right. Each access right has
  175. * an associated unique integer id. A list of all access rights
  176. * known in an ACL context is maintained, with its head in the
  177. * ACContext_t structure.
  178. */
  179. typedef struct RightDef_s RightDef_t;
  180. struct RightDef_s {
  181. Symbol_t rd_sym; /* right name, type ACLSYMRIGHT */
  182. RightDef_t * rd_next; /* next on ACContext_t list */
  183. USI_t rd_id; /* unique id */
  184. };
  185. /*
  186. * Description (RightSpec_t)
  187. *
  188. * This type describes a named list of access rights.
  189. */
  190. typedef struct RightSpec_s RightSpec_t;
  191. struct RightSpec_s {
  192. Symbol_t rs_sym; /* list name, type ACLSYMRDEF */
  193. USIList_t rs_list; /* list of right ids */
  194. };
  195. /*
  196. * Description (ACContext_t)
  197. *
  198. * This type defines a structure that defines a context for a set
  199. * of Access Control Lists. This includes references to an
  200. * authentication database, if any, and a symbol table containing
  201. * access right definitions. It also serves as a list head for the
  202. * ACLs which are defined in the specified context.
  203. */
  204. typedef struct ACContext_s ACContext_t;
  205. struct ACContext_s {
  206. void * acc_stp; /* symbol table handle */
  207. ACL_t * acc_acls; /* list of ACLs */
  208. RightDef_t * acc_rights; /* list of access right definitions */
  209. int acc_refcnt; /* reference count */
  210. };
  211. /*
  212. * Description (ACL_t)
  213. *
  214. * This type defines the structure that represents an Access Control
  215. * List (ACL). An ACL has a user-assigned name and an internally
  216. * assigned identifier (which is an index in an object directory).
  217. * It references a list of access rights which are to be allowed or
  218. * denied, according to the ACL specifications. It references an
  219. * ordered list of ACL directives, which specify who has and who does
  220. * not have the associated access rights.
  221. */
  222. struct ACL_s {
  223. Symbol_t acl_sym; /* ACL name, type ACLSYMACL */
  224. ACL_t * acl_next; /* next ACL on a list */
  225. ACContext_t * acl_acc; /* context for this ACL */
  226. USI_t acl_id; /* id of this ACL */
  227. int acl_refcnt; /* reference count */
  228. RightSpec_t * acl_rights; /* access rights list */
  229. ACDirective_t * acl_dirf; /* first directive pointer */
  230. ACDirective_t * acl_dirl; /* last directive pointer */
  231. };
  232. /* Define symbol type codes */
  233. #define ACLSYMACL 0 /* ACL */
  234. #define ACLSYMRIGHT 1 /* access right */
  235. #define ACLSYMRDEF 2 /* access rights list */
  236. #define ACLSYMREALM 3 /* realm name */
  237. #define ACLSYMHOST 4 /* host specifications */
  238. #define ACLSYMUSER 5 /* user/group list */
  239. /*
  240. * Description (ACLFile_t)
  241. *
  242. * This type describes a structure containing information about
  243. * an open ACL description file.
  244. */
  245. typedef struct ACLFile_s ACLFile_t;
  246. struct ACLFile_s {
  247. ACLFile_t * acf_next; /* list link */
  248. char * acf_filename; /* pointer to filename string */
  249. LEXStream_t * acf_lst; /* LEX stream handle */
  250. SYS_FILE acf_fd; /* file descriptor */
  251. int acf_flags; /* bit flags (unused) */
  252. int acf_lineno; /* current line number */
  253. void * acf_token; /* LEX token handle */
  254. int acf_ttype; /* current token type */
  255. };
  256. NSPR_END_EXTERN_C
  257. #endif /* __aclstruct_h */