aclstruct.h 9.5 KB

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