/linux-2.6.21.1-rsbac-1.3.4/include/rsbac/gen_lists.h

Go to the documentation of this file.
00001 /*************************************************** */
00002 /* Rule Set Based Access Control                     */
00003 /* Author and (c) 1999-2007: Amon Ott <ao@rsbac.org> */
00004 /* Generic lists - internal structures               */
00005 /* Last modified: 13/Feb/2007                        */
00006 /*************************************************** */
00007 
00008 #ifndef __RSBAC_GEN_LISTS_H
00009 #define __RSBAC_GEN_LISTS_H
00010 
00011 #include <linux/init.h>
00012 #include <rsbac/rkmem.h>
00013 #include <rsbac/lists.h>
00014 #include <rsbac/repl_lists.h>
00015 
00016 /* Maximum number of items per single list, the real limit is at
00017  * RSBAC_LIST_MAX_NR_ITEMS * nr_hashes.
00018  * Limit can be disabled per list with RSBAC_LIST_NO_MAX flag.
00019  */
00020 
00021 #define RSBAC_LIST_MAX_NR_ITEMS 50000
00022 #define RSBAC_LIST_MAX_NR_SUBITEMS 50000
00023 
00024 #define RSBAC_LIST_MAX_NR_ITEMS_LIMIT 1000000
00025 
00026 #define RSBAC_LIST_DISK_VERSION 10003
00027 #define RSBAC_LIST_DISK_OLD_VERSION 10002
00028 #define RSBAC_LIST_NONAME "(no name)"
00029 #define RSBAC_LIST_PROC_NAME "gen_lists"
00030 #define RSBAC_LIST_COUNTS_PROC_NAME "gen_lists_counts"
00031 
00032 #define RSBAC_LIST_TA_KEY 0xface99
00033 
00034 #define RSBAC_LIST_MAX_OLD_HASH 32
00035 #define RSBAC_LIST_LOL_MAX_OLD_HASH 16
00036 
00037 /* If number of items per hashed list is bigger than this and flag
00038    RSBAC_LIST_AUTO_HASH_RESIZE is set, rehash */
00039 #define RSBAC_LIST_AUTO_REHASH_TRIGGER 50
00040 
00041 /* Rehashing interval in s - rehashing is triggered by rsbacd, so might happen
00042  * less frequently, if rsbacd wakes up later.
00043  */
00044 #define RSBAC_LIST_REHASH_INTERVAL 60
00045 
00046 /* Check lists every n seconds. Also called from rsbacd, so might take longer. */
00047 
00048 //#define RSBAC_LIST_CHECK_INTERVAL 1800
00049 
00050 /* Prototypes */
00051 
00052 /* Init */
00053 #ifdef CONFIG_RSBAC_INIT_DELAY
00054 int rsbac_list_init(void);
00055 #else
00056 int __init rsbac_list_init(void);
00057 #endif
00058 
00059 /* mount / umount */
00060 int rsbac_list_mount(kdev_t kdev);
00061 int rsbac_list_umount(kdev_t kdev);
00062 
00063 /* Status checking */
00064 int rsbac_check_lists(int correct);
00065 
00066 #if defined(CONFIG_RSBAC_AUTO_WRITE)
00067 int rsbac_write_lists(rsbac_boolean_t need_lock);
00068 #endif
00069 
00070 /* Data Structures */
00071 
00072 /* All items will be organized in double linked lists
00073  * However, we do not know the descriptor or item sizes, so we will access them
00074    with offsets later and only define the list links here.
00075  */
00076 
00077 struct rsbac_list_item_t {
00078         struct rsbac_list_item_t *prev;
00079         struct rsbac_list_item_t *next;
00080         rsbac_time_t max_age;
00081 };
00082 
00083 /* lists of lists ds */
00084 struct rsbac_list_lol_item_t {
00085         struct rsbac_list_lol_item_t *prev;
00086         struct rsbac_list_lol_item_t *next;
00087         struct rsbac_list_item_t *head;
00088         struct rsbac_list_item_t *tail;
00089         struct rsbac_list_item_t *curr;
00090         u_long count;
00091         rsbac_time_t max_age;
00092 };
00093 
00094 typedef __u32 rsbac_list_count_t;
00095 
00096 struct rsbac_list_hashed_t {
00097         struct rsbac_list_item_t *head;
00098         struct rsbac_list_item_t *tail;
00099         struct rsbac_list_item_t *curr;
00100         rsbac_list_count_t count;
00101 #ifdef CONFIG_RSBAC_LIST_TRANS
00102         rsbac_ta_number_t ta_copied;
00103         struct rsbac_list_item_t *ta_head;
00104         struct rsbac_list_item_t *ta_tail;
00105         struct rsbac_list_item_t *ta_curr;
00106         rsbac_list_count_t ta_count;
00107 #endif
00108 };
00109 
00110 struct rsbac_list_lol_hashed_t {
00111         struct rsbac_list_lol_item_t *head;
00112         struct rsbac_list_lol_item_t *tail;
00113         struct rsbac_list_lol_item_t *curr;
00114         rsbac_list_count_t count;
00115 #ifdef CONFIG_RSBAC_LIST_TRANS
00116         rsbac_ta_number_t ta_copied;
00117         struct rsbac_list_lol_item_t *ta_head;
00118         struct rsbac_list_lol_item_t *ta_tail;
00119         struct rsbac_list_lol_item_t *ta_curr;
00120         rsbac_list_count_t ta_count;
00121 #endif
00122 };
00123 
00124 /* Since all registrations will be organized in double linked lists, we must
00125  * have list items and a list head.
00126  * The pointer to this item will also be used as list handle. */
00127 
00128 struct rsbac_list_reg_item_t {
00129         struct rsbac_list_info_t info;
00130         u_int flags;
00131         rsbac_list_compare_function_t *compare;
00132         rsbac_list_get_conv_t *get_conv;
00133         void *def_data;
00134         char name[RSBAC_LIST_MAX_FILENAME + 1];
00135         kdev_t device;
00136         rwlock_t lock;
00137         rsbac_boolean_t dirty;
00138         rsbac_boolean_t no_write;
00139         struct rsbac_nanotime_t lastchange;
00140         u_int nr_hashes;
00141         u_int max_items_per_hash;
00142         rsbac_list_hash_function_t * hash_function;
00143         char old_name_base[RSBAC_LIST_MAX_FILENAME + 1];
00144 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
00145         struct proc_dir_entry *proc_entry_p;
00146 #endif
00147         struct rsbac_list_reg_item_t *prev;
00148         struct rsbac_list_reg_item_t *next;
00149         struct rsbac_list_reg_item_t *self;
00150         /* The hashed list heads are allocated dynamically! */
00151         struct rsbac_list_hashed_t * hashed;
00152 };
00153 
00154 struct rsbac_list_lol_reg_item_t {
00155         struct rsbac_list_lol_info_t info;
00156         u_int flags;
00157         rsbac_list_compare_function_t *compare;
00158         rsbac_list_compare_function_t *subcompare;
00159         rsbac_list_get_conv_t *get_conv;
00160         rsbac_list_get_conv_t *get_subconv;
00161         void *def_data;
00162         void *def_subdata;
00163         char name[RSBAC_LIST_MAX_FILENAME + 1];
00164         kdev_t device;
00165         rwlock_t lock;
00166         rsbac_boolean_t dirty;
00167         rsbac_boolean_t no_write;
00168         struct rsbac_nanotime_t lastchange;
00169         u_int nr_hashes;
00170         u_int max_items_per_hash;
00171         u_int max_subitems;
00172         rsbac_list_hash_function_t * hash_function;
00173         char old_name_base[RSBAC_LIST_MAX_FILENAME + 1];
00174 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
00175         struct proc_dir_entry *proc_entry_p;
00176 #endif
00177         struct rsbac_list_lol_reg_item_t *prev;
00178         struct rsbac_list_lol_reg_item_t *next;
00179         struct rsbac_list_lol_reg_item_t *self;
00180         /* The hashed list heads are allocated dynamically! */
00181         struct rsbac_list_lol_hashed_t * hashed;
00182 };
00183 
00184 /* To provide consistency we use spinlocks for all list accesses. The
00185    'curr' entry is used to avoid repeated lookups for the same item. */
00186 
00187 struct rsbac_list_reg_head_t {
00188         struct rsbac_list_reg_item_t *head;
00189         struct rsbac_list_reg_item_t *tail;
00190         struct rsbac_list_reg_item_t *curr;
00191         rwlock_t lock;
00192         u_int count;
00193 };
00194 
00195 struct rsbac_list_lol_reg_head_t {
00196         struct rsbac_list_lol_reg_item_t *head;
00197         struct rsbac_list_lol_reg_item_t *tail;
00198         struct rsbac_list_lol_reg_item_t *curr;
00199         rwlock_t lock;
00200         u_int count;
00201 };
00202 
00203 /* Internal helper list of filled write buffers */
00204 
00205 struct rsbac_list_buffer_t {
00206         struct rsbac_list_buffer_t * next;
00207         u_int len;
00208         char data[0];
00209 };
00210 
00211 #define RSBAC_LIST_BUFFER_SIZE 8192
00212 #define RSBAC_LIST_BUFFER_DATA_SIZE (RSBAC_LIST_BUFFER_SIZE - sizeof(struct rsbac_list_buffer_t))
00213 
00214 struct rsbac_list_write_item_t {
00215         struct rsbac_list_write_item_t *prev;
00216         struct rsbac_list_write_item_t *next;
00217         struct rsbac_list_reg_item_t *list;
00218         struct rsbac_list_buffer_t *buffer;
00219         char name[RSBAC_LIST_MAX_FILENAME + 1];
00220         kdev_t device;
00221 };
00222 
00223 struct rsbac_list_write_head_t {
00224         struct rsbac_list_write_item_t *head;
00225         struct rsbac_list_write_item_t *tail;
00226         u_int count;
00227 };
00228 
00229 struct rsbac_list_lol_write_item_t {
00230         struct rsbac_list_lol_write_item_t *prev;
00231         struct rsbac_list_lol_write_item_t *next;
00232         struct rsbac_list_lol_reg_item_t *list;
00233         struct rsbac_list_buffer_t *buffer;
00234         char name[RSBAC_LIST_MAX_FILENAME + 1];
00235         kdev_t device;
00236 };
00237 
00238 struct rsbac_list_lol_write_head_t {
00239         struct rsbac_list_lol_write_item_t *head;
00240         struct rsbac_list_lol_write_item_t *tail;
00241         u_int count;
00242 };
00243 
00244 
00245 /* Data structs for file timeout book keeping list filelist */
00246 struct rsbac_list_filelist_desc_t {
00247         char filename[RSBAC_LIST_MAX_FILENAME + 1];
00248 };
00249 
00250 struct rsbac_list_filelist_data_t {
00251         rsbac_time_t timestamp;
00252         rsbac_time_t max_age;
00253 };
00254 
00255 struct rsbac_list_ta_data_t {
00256         rsbac_time_t start;
00257         rsbac_time_t timeout;
00258         rsbac_uid_t commit_uid;
00259         char password[RSBAC_LIST_TA_MAX_PASSLEN];
00260 };
00261 
00262 #endif

Generated on Wed May 16 11:53:27 2007 for RSBAC by  doxygen 1.5.1