aclpriv.h 6.4 KB

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