aclstruct.h 9.4 KB

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