aclpriv.h 6.4 KB

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