aclpriv.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. /*
  42. * ACL private data structure definitions
  43. */
  44. #ifndef ACL_PARSER_HEADER
  45. #define ACL_PARSER_HEADER
  46. #include <netsite.h>
  47. #include <plhash.h>
  48. #include <base/pool.h>
  49. #include <base/plist.h>
  50. #include <libaccess/las.h>
  51. #define ACL_TERM_BSIZE 4
  52. #define ACL_FALSE_IDX -2
  53. #define ACL_TRUE_IDX -1
  54. #define ACL_MIN_IDX 0
  55. #define ACL_EXPR_STACK 1024
  56. #define ACL_TABLE_THRESHOLD 10
  57. #define ACL_NO_UNPUT 1 /* unput is not used and causes compiler warnings */
  58. typedef enum {
  59. ACL_EXPR_OP_AND,
  60. ACL_EXPR_OP_OR,
  61. ACL_EXPR_OP_NOT
  62. } ACLExprOp_t;
  63. typedef struct ACLExprEntry {
  64. char *attr_name; /* LAS name input */
  65. CmpOp_t comparator; /* LAS comparator input */
  66. char *attr_pattern; /* LAS attribute input */
  67. int false_idx; /* index, -1 true, -2 false */
  68. int true_idx; /* index, -1 true, -2 false */
  69. int start_flag; /* marks start of an expr */
  70. void *las_cookie; /* private data store for LAS */
  71. LASEvalFunc_t las_eval_func; /* LAS function */
  72. } ACLExprEntry_t;
  73. typedef struct ACLExprRaw {
  74. char *attr_name; /* expr lval */
  75. CmpOp_t comparator; /* comparator */
  76. char *attr_pattern; /* expr rval */
  77. ACLExprOp_t logical; /* logical operator */
  78. } ACLExprRaw_t;
  79. typedef struct ACLExprStack {
  80. char *expr_text[ACL_EXPR_STACK];
  81. ACLExprRaw_t *expr[ACL_EXPR_STACK];
  82. int stack_index;
  83. int found_subexpression;
  84. int last_subexpression;
  85. } ACLExprStack_t;
  86. typedef struct ACLExprHandle {
  87. char *expr_tag;
  88. char *acl_tag;
  89. int expr_number;
  90. ACLExprType_t expr_type;
  91. int expr_flags;
  92. int expr_argc;
  93. char **expr_argv;
  94. PList_t expr_auth;
  95. ACLExprEntry_t *expr_arry;
  96. int expr_arry_size;
  97. int expr_term_index;
  98. ACLExprRaw_t *expr_raw;
  99. int expr_raw_index;
  100. int expr_raw_size;
  101. struct ACLExprHandle *expr_next; /* Null-terminated */
  102. } ACLExprHandle_t;
  103. typedef struct ACLHandle {
  104. int ref_count;
  105. char *tag;
  106. PFlags_t flags;
  107. char *las_name;
  108. pblock *pb;
  109. char **attr_name;
  110. int expr_count;
  111. ACLExprHandle_t *expr_list_head; /* Null-terminated */
  112. ACLExprHandle_t *expr_list_tail;
  113. } ACLHandle_t;
  114. typedef struct ACLWrapper {
  115. ACLHandle_t *acl;
  116. struct ACLWrapper *wrap_next;
  117. } ACLWrapper_t;
  118. #define ACL_LIST_STALE 0x1
  119. #define ACL_LIST_IS_STALE(x) ((x)->flags & ACL_LIST_STALE)
  120. typedef struct ACLListHandle {
  121. ACLWrapper_t *acl_list_head; /* Null-terminated */
  122. ACLWrapper_t *acl_list_tail; /* Null-terminated */
  123. int acl_count;
  124. void *acl_sym_table;
  125. void *cache;
  126. uint32 flags;
  127. int ref_count;
  128. } ACLListHandle_t;
  129. typedef struct ACLAceNumEntry {
  130. int acenum;
  131. struct ACLAceNumEntry *next;
  132. struct ACLAceNumEntry *chain; /* only used for freeing memory */
  133. } ACLAceNumEntry_t;
  134. typedef struct ACLAceEntry {
  135. ACLExprHandle_t *acep;
  136. /* Array of auth block ptrs for all the expr
  137. clauses in this ACE */
  138. PList_t *autharray;
  139. /* PList with auth blocks for ALL attributes */
  140. PList_t global_auth;
  141. struct ACLAceEntry *next; /* Null-terminated list */
  142. } ACLAceEntry_t;
  143. typedef struct PropList PropList_t;
  144. typedef struct ACLEvalHandle {
  145. pool_handle_t *pool;
  146. ACLListHandle_t *acllist;
  147. PList_t subject;
  148. PList_t resource;
  149. int default_result;
  150. } ACLEvalHandle_t;
  151. typedef struct ACLListCache {
  152. /* Hash table for all access rights used in all acls in this list. Each
  153. * hash entry has a list of ACE numbers that relate to this referenced
  154. * access right.
  155. */
  156. PLHashTable *Table;
  157. char *deny_response;
  158. char *deny_type;
  159. ACLAceEntry_t *acelist; /* Evaluation order
  160. * list of all ACEs
  161. */
  162. ACLAceNumEntry_t *chain_head; /* Chain of all Ace num
  163. * entries for this
  164. * ACL list so we can free them
  165. */
  166. ACLAceNumEntry_t *chain_tail;
  167. } ACLListCache_t;
  168. /* this is to speed up acl_to_str_append */
  169. typedef struct acl_string_s {
  170. char * str;
  171. long str_size;
  172. long str_len;
  173. } acl_string_t;
  174. NSPR_BEGIN_EXTERN_C
  175. extern int ACL_ExprDisplay( ACLExprHandle_t *acl_expr );
  176. extern int ACL_AssertAcl( ACLHandle_t *acl );
  177. extern int ACL_EvalDestroyContext ( ACLListCache_t *cache );
  178. extern time_t *acl_get_req_time(PList_t resource);
  179. NSPR_END_EXTERN_C
  180. #endif