lists.h File Reference

#include <linux/init.h>
#include <linux/vmalloc.h>
#include <rsbac/rkmem.h>

Go to the source code of this file.

Defines

#define RSBAC_LIST_VERSION   3
#define RSBAC_LIST_MAX_FILENAME   15
#define RSBAC_LIST_MAX_AGE_LIMIT   (3600 * 24 * 366 * 10)
#define RSBAC_LIST_MAX_ITEM_SIZE   (RSBAC_MAX_KMALLOC - 64)
#define RSBAC_LIST_PERSIST   1
#define RSBAC_LIST_IGNORE_OLD   2
#define RSBAC_LIST_IGNORE_UNSUPP_VERSION   4
#define RSBAC_LIST_NO_WRITE   8
#define RSBAC_LIST_BACKUP   16
#define RSBAC_LIST_DEF_DATA   32
#define RSBAC_LIST_DEF_SUBDATA   64

Typedefs

typedef void * rsbac_list_handle_t
typedef __u32 rsbac_list_key_t
typedef int rsbac_list_compare_function_t (void *desc1, void *desc2)
typedef int rsbac_list_data_compare_function_t (void *data1, void *data2)
typedef int rsbac_list_conv_function_t (void *old_desc, void *old_data, void *new_desc, void *new_data)
typedef rsbac_list_conv_function_trsbac_list_get_conv_t (rsbac_version_t old_version)

Functions

int rsbac_list_compare_u32 (void *desc1, void *desc2)
rsbac_version_t rsbac_list_version (void)
int rsbac_list_register (rsbac_version_t ds_version, rsbac_list_handle_t *handle_p, struct rsbac_list_info_t *info_p, u_int flags, rsbac_list_compare_function_t *compare, rsbac_list_get_conv_t *get_conv, void *def_data, char *name, kdev_t device)
int rsbac_list_lol_register (rsbac_version_t ds_version, rsbac_list_handle_t *handle_p, struct rsbac_list_lol_info_t *info_p, u_int flags, rsbac_list_compare_function_t *compare, rsbac_list_compare_function_t *subcompare, rsbac_list_get_conv_t *get_conv, rsbac_list_get_conv_t *get_subconv, void *def_data, void *def_subdata, char *name, kdev_t device)
int rsbac_list_destroy (rsbac_list_handle_t *handle_p, rsbac_list_key_t key)
int rsbac_list_lol_destroy (rsbac_list_handle_t *handle_p, rsbac_list_key_t key)
int rsbac_list_detach (rsbac_list_handle_t *handle_p, rsbac_list_key_t key)
int rsbac_list_lol_detach (rsbac_list_handle_t *handle_p, rsbac_list_key_t key)
int rsbac_list_no_write (rsbac_list_handle_t handle, rsbac_list_key_t key, rsbac_boolean_t no_write)
int rsbac_list_lol_no_write (rsbac_list_handle_t handle, rsbac_list_key_t key, rsbac_boolean_t no_write)
int rsbac_list_check (rsbac_list_handle_t handle, int correct)
int rsbac_list_lol_check (rsbac_list_handle_t handle, int correct)
int rsbac_list_add (rsbac_list_handle_t handle, void *desc, void *data)
int rsbac_ta_list_add_ttl (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, rsbac_time_t ttl, void *desc, void *data)
int rsbac_list_add_ttl (rsbac_list_handle_t handle, rsbac_time_t ttl, void *desc, void *data)
int rsbac_ta_list_lol_subadd_ttl (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, rsbac_time_t ttl, void *desc, void *subdesc, void *subdata)
int rsbac_list_lol_subadd (rsbac_list_handle_t handle, void *desc, void *subdesc, void *subdata)
int rsbac_list_lol_subadd_ttl (rsbac_list_handle_t handle, rsbac_time_t ttl, void *desc, void *subdesc, void *subdata)
int rsbac_list_lol_add (rsbac_list_handle_t handle, void *desc, void *data)
int rsbac_ta_list_lol_add_ttl (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, rsbac_time_t ttl, void *desc, void *data)
int rsbac_list_lol_add_ttl (rsbac_list_handle_t handle, rsbac_time_t ttl, void *desc, void *data)
int rsbac_ta_list_remove (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc)
int rsbac_list_remove (rsbac_list_handle_t handle, void *desc)
int rsbac_ta_list_remove_all (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle)
int rsbac_list_remove_all (rsbac_list_handle_t handle)
int rsbac_ta_list_lol_subremove (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc, void *subdesc)
int rsbac_list_lol_subremove (rsbac_list_handle_t handle, void *desc, void *subdesc)
int rsbac_ta_list_lol_subremove_from_all (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *subdesc)
int rsbac_list_lol_subremove_from_all (rsbac_list_handle_t handle, void *subdesc)
int rsbac_ta_list_lol_subremove_all (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc)
int rsbac_list_lol_subremove_all (rsbac_list_handle_t handle, void *desc)
int rsbac_ta_list_lol_remove (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc)
int rsbac_list_lol_remove (rsbac_list_handle_t handle, void *desc)
int rsbac_ta_list_lol_remove_all (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle)
int rsbac_list_lol_remove_all (rsbac_list_handle_t handle)
int rsbac_list_get_data (rsbac_list_handle_t handle, void *desc, void *data)
int rsbac_ta_list_get_data_ttl (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, rsbac_time_t *ttl_p, void *desc, void *data)
int rsbac_list_get_data_ttl (rsbac_list_handle_t handle, rsbac_time_t *ttl_p, void *desc, void *data)
int rsbac_list_lol_get_subdata (rsbac_list_handle_t handle, void *desc, void *subdesc, void *subdata)
int rsbac_ta_list_lol_get_subdata_ttl (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, rsbac_time_t *ttl_p, void *desc, void *subdesc, void *subdata)
int rsbac_list_lol_get_subdata_ttl (rsbac_list_handle_t handle, rsbac_time_t *ttl_p, void *desc, void *subdesc, void *subdata)
int rsbac_list_lol_get_data (rsbac_list_handle_t handle, void *desc, void *data)
int rsbac_ta_list_lol_get_data_ttl (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, rsbac_time_t *ttl_p, void *desc, void *data)
int rsbac_list_lol_get_data_ttl (rsbac_list_handle_t handle, rsbac_time_t *ttl_p, void *desc, void *data)
int rsbac_ta_list_get_desc (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc, void *data, rsbac_list_data_compare_function_t compare)
int rsbac_list_get_desc (rsbac_list_handle_t handle, void *desc, void *data, rsbac_list_data_compare_function_t compare)
int rsbac_ta_list_lol_get_desc (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc, void *data, rsbac_list_data_compare_function_t compare)
int rsbac_list_lol_get_desc (rsbac_list_handle_t handle, void *desc, void *data, rsbac_list_data_compare_function_t compare)
int rsbac_ta_list_get_max_desc (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc)
int rsbac_list_get_max_desc (rsbac_list_handle_t handle, void *desc)
int rsbac_ta_list_get_next_desc (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *old_desc, void *next_desc)
int rsbac_list_get_next_desc (rsbac_list_handle_t handle, void *old_desc, void *next_desc)
int rsbac_ta_list_lol_get_next_desc (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *old_desc, void *next_desc)
int rsbac_list_lol_get_next_desc (rsbac_list_handle_t handle, void *old_desc, void *next_desc)
int rsbac_ta_list_exist (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc)
int rsbac_list_exist (rsbac_list_handle_t handle, void *desc)
int rsbac_ta_list_lol_subexist (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc, void *subdesc)
int rsbac_list_lol_subexist (rsbac_list_handle_t handle, void *desc, void *subdesc)
int rsbac_ta_list_lol_exist (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc)
int rsbac_list_lol_exist (rsbac_list_handle_t handle, void *desc)
int rsbac_ta_list_lol_subexist_compare (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc, void *subdesc, rsbac_list_compare_function_t compare)
int rsbac_list_lol_subexist_compare (rsbac_list_handle_t handle, void *desc, void *subdesc, rsbac_list_compare_function_t compare)
long rsbac_ta_list_count (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle)
long rsbac_list_count (rsbac_list_handle_t handle)
long rsbac_ta_list_lol_subcount (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc)
long rsbac_list_lol_subcount (rsbac_list_handle_t handle, void *desc)
long rsbac_ta_list_lol_all_subcount (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle)
long rsbac_list_lol_all_subcount (rsbac_list_handle_t handle)
long rsbac_ta_list_lol_count (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle)
long rsbac_list_lol_count (rsbac_list_handle_t handle)
long rsbac_ta_list_get_all_desc (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void **array_p)
long rsbac_list_get_all_desc (rsbac_list_handle_t handle, void **array_p)
long rsbac_list_lol_get_all_subdesc (rsbac_list_handle_t handle, void *desc, void **array_p)
long rsbac_ta_list_lol_get_all_subdesc_ttl (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc, void **array_p, rsbac_time_t **ttl_array_p)
long rsbac_list_lol_get_all_subdesc_ttl (rsbac_list_handle_t handle, void *desc, void **array_p, rsbac_time_t **ttl_array_p)
long rsbac_ta_list_lol_get_all_desc (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void **array_p)
long rsbac_list_lol_get_all_desc (rsbac_list_handle_t handle, void **array_p)
long rsbac_ta_list_get_all_data (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void **array_p)
long rsbac_list_get_all_data (rsbac_list_handle_t handle, void **array_p)
long rsbac_ta_list_lol_get_all_subdata (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc, void **array_p)
long rsbac_list_lol_get_all_subdata (rsbac_list_handle_t handle, void *desc, void **array_p)
long rsbac_ta_list_lol_get_all_data (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void **array_p)
long rsbac_list_lol_get_all_data (rsbac_list_handle_t handle, void **array_p)
int rsbac_list_get_item_size (rsbac_list_handle_t handle)
int rsbac_list_lol_get_subitem_size (rsbac_list_handle_t handle)
int rsbac_list_lol_get_item_size (rsbac_list_handle_t handle)
long rsbac_list_get_all_items (rsbac_list_handle_t handle, void **array_p)
long rsbac_ta_list_get_all_items_ttl (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void **array_p, rsbac_time_t **ttl_array_p)
long rsbac_list_get_all_items_ttl (rsbac_list_handle_t handle, void **array_p, rsbac_time_t **ttl_array_p)
long rsbac_list_lol_get_all_subitems (rsbac_list_handle_t handle, void *desc, void **array_p)
long rsbac_ta_list_lol_get_all_subitems_ttl (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc, void **array_p, rsbac_time_t **ttl_array_p)
long rsbac_list_lol_get_all_subitems_ttl (rsbac_list_handle_t handle, void *desc, void **array_p, rsbac_time_t **ttl_array_p)
long rsbac_ta_list_lol_get_all_items (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void **array_p)
long rsbac_list_lol_get_all_items (rsbac_list_handle_t handle, void **array_p)


Define Documentation

#define RSBAC_LIST_BACKUP   16
 

Definition at line 51 of file lists.h.

Referenced by init_module(), register_dev_lists(), register_user_lists(), rsbac_init_acl(), rsbac_init_pm(), rsbac_init_rc(), rsbac_init_um(), rsbac_list_destroy(), rsbac_list_detach(), rsbac_list_lol_destroy(), rsbac_list_lol_detach(), rsbac_list_lol_register(), and rsbac_list_register().

#define RSBAC_LIST_DEF_DATA   32
 

Definition at line 57 of file lists.h.

Referenced by acl_register_fd_lists(), auth_register_fd_lists(), create_lol_reg(), create_reg(), mac_register_fd_lists(), register_dev_lists(), register_fd_lists(), register_ipc_lists(), register_process_lists(), register_user_lists(), rsbac_check_lists(), rsbac_init_acl(), rsbac_init_auth(), rsbac_init_debug(), rsbac_init_mac(), rsbac_init_rc(), rsbac_list_lol_check(), rsbac_ta_list_lol_subadd_ttl(), rsbac_ta_list_lol_subremove(), and rsbac_ta_list_lol_subremove_all().

#define RSBAC_LIST_DEF_SUBDATA   64
 

Definition at line 62 of file lists.h.

Referenced by create_lol_reg(), and rsbac_init_rc().

#define RSBAC_LIST_IGNORE_OLD   2
 

Definition at line 39 of file lists.h.

Referenced by read_list(), and read_lol_list().

#define RSBAC_LIST_IGNORE_UNSUPP_VERSION   4
 

Definition at line 45 of file lists.h.

Referenced by read_list(), and read_lol_list().

#define RSBAC_LIST_MAX_AGE_LIMIT   (3600 * 24 * 366 * 10)
 

Definition at line 27 of file lists.h.

Referenced by rsbac_list_lol_register(), rsbac_list_register(), rsbac_ta_list_add_ttl(), rsbac_ta_list_lol_add_ttl(), and rsbac_ta_list_lol_subadd_ttl().

#define RSBAC_LIST_MAX_FILENAME   15
 

Definition at line 24 of file lists.h.

Referenced by create_lol_reg(), create_reg(), fill_buffer(), fill_lol_buffer(), lookup_lol_reg_name(), and lookup_reg_name().

#define RSBAC_LIST_MAX_ITEM_SIZE   (RSBAC_MAX_KMALLOC - 64)
 

Definition at line 30 of file lists.h.

Referenced by rsbac_list_lol_register(), and rsbac_list_register().

#define RSBAC_LIST_NO_WRITE   8
 

Definition at line 48 of file lists.h.

Referenced by create_lol_reg(), and create_reg().

#define RSBAC_LIST_PERSIST   1
 

Definition at line 36 of file lists.h.

Referenced by acl_register_fd_lists(), auth_register_fd_lists(), init_module(), mac_register_fd_lists(), register_dev_lists(), register_fd_lists(), register_user_lists(), rsbac_check_lists(), rsbac_init_acl(), rsbac_init_debug(), rsbac_init_pm(), rsbac_init_rc(), rsbac_init_um(), rsbac_list_destroy(), rsbac_list_detach(), rsbac_list_init(), rsbac_list_lol_destroy(), rsbac_list_lol_detach(), rsbac_list_lol_register(), and rsbac_list_register().

#define RSBAC_LIST_VERSION   3
 

Definition at line 18 of file lists.h.

Referenced by acl_register_fd_lists(), auth_register_fd_lists(), init_module(), mac_register_fd_lists(), register_dev_lists(), register_fd_lists(), register_ipc_lists(), register_process_lists(), register_user_lists(), rsbac_init_acl(), rsbac_init_auth(), rsbac_init_debug(), rsbac_init_mac(), rsbac_init_pm(), rsbac_init_rc(), rsbac_init_um(), rsbac_list_init(), rsbac_list_lol_register(), rsbac_list_register(), and rsbac_list_version().


Typedef Documentation

typedef int rsbac_list_compare_function_t(void *desc1, void *desc2)
 

Definition at line 73 of file lists.h.

typedef int rsbac_list_conv_function_t(void *old_desc, void *old_data, void *new_desc, void *new_data)
 

Definition at line 89 of file lists.h.

typedef int rsbac_list_data_compare_function_t(void *data1, void *data2)
 

Definition at line 84 of file lists.h.

typedef rsbac_list_conv_function_t* rsbac_list_get_conv_t(rsbac_version_t old_version)
 

Definition at line 98 of file lists.h.

typedef void* rsbac_list_handle_t
 

Definition at line 20 of file lists.h.

typedef __u32 rsbac_list_key_t
 

Definition at line 21 of file lists.h.


Function Documentation

int rsbac_list_add rsbac_list_handle_t  handle,
void *  desc,
void *  data
 

Definition at line 7101 of file gen_lists.c.

References RSBAC_LIST_TTL_KEEP, and rsbac_ta_list_add_ttl().

Referenced by need_overwrite_func(), register_user_lists(), request_func(), rsbac_adf_log_switch(), rsbac_do_init(), rsbac_init(), rsbac_init_acl(), rsbac_init_rc(), rsbac_kthread_notify(), set_attr_func(), syscall_func(), and write_func().

07105   {
07106     return rsbac_ta_list_add_ttl(0, handle, RSBAC_LIST_TTL_KEEP, desc, data);
07107   }

int rsbac_list_add_ttl rsbac_list_handle_t  handle,
rsbac_time_t  ttl,
void *  desc,
void *  data
 

Definition at line 7089 of file gen_lists.c.

References rsbac_ta_list_add_ttl().

Referenced by set_attr_fd().

07094   {
07095     return rsbac_ta_list_add_ttl(0, handle, ttl, desc, data);
07096   }

int rsbac_list_check rsbac_list_handle_t  handle,
int  correct
 

Definition at line 5653 of file gen_lists.c.

References rsbac_list_reg_item_t::count, rsbac_list_info_t::data_size, rsbac_list_reg_item_t::def_data, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::device, rsbac_list_reg_item_t::dirty, do_remove_item(), rsbac_list_reg_item_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, rsbac_list_item_t::max_age, rsbac_list_reg_item_t::name, rsbac_list_item_t::next, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_printk(), rsbac_list_reg_item_t::self, and TRUE.

05656   {
05657     struct rsbac_list_reg_item_t * list;
05658     struct rsbac_list_item_t     * item_p;
05659     struct rsbac_list_item_t     * next_item_p;
05660     u_long lock_flags;
05661     u_long rlock_flags;
05662     u_long tmp_count;
05663 
05664     if(!handle)
05665       return -RSBAC_EINVALIDVALUE;
05666     if(!list_initialized)
05667       return -RSBAC_ENOTINITIALIZED;
05668 
05669     list = (struct rsbac_list_reg_item_t *) handle;
05670     if(!list || (list->self != list))
05671       return -RSBAC_EINVALIDVALUE;
05672 
05673     rsbac_read_lock(&reg_head.lock, &rlock_flags);
05674 #ifdef CONFIG_RSBAC_DEBUG
05675     if(rsbac_debug_lists)
05676       rsbac_printk(KERN_DEBUG "rsbac_list_check: checking list %s.\n",
05677              list->name);
05678 #endif
05679     rsbac_write_lock(&list->lock, &lock_flags);
05680     tmp_count = 0;
05681     item_p = list->head;
05682     while(item_p)
05683       {
05684         if(   (   item_p->max_age
05685                && (item_p->max_age <= RSBAC_CURRENT_TIME)
05686               )
05687            || (   list->def_data
05688                && !memcmp(((char *) item_p) + sizeof(*item_p) + list->info.desc_size,
05689                           list->def_data,
05690                           list->info.data_size)
05691               )
05692           )
05693           {
05694             next_item_p = item_p->next;
05695             do_remove_item(list, item_p);
05696             item_p = next_item_p;
05697             list->dirty = TRUE;
05698           }
05699         else
05700           {
05701             tmp_count++;
05702             item_p = item_p->next;
05703           }
05704       }
05705     if(tmp_count != list->count)
05706       {
05707         if(correct)
05708           {
05709             rsbac_printk(KERN_WARNING
05710                          "rsbac_list_check(): correcting count mismatch for list %s on device %02u:%02u - was %u, counted %lu!\n",
05711                          list->name, RSBAC_MAJOR(list->device), RSBAC_MINOR(list->device), list->count, tmp_count);
05712             list->count = tmp_count;
05713             list->dirty = TRUE;
05714           }
05715         else
05716           {
05717             rsbac_printk(KERN_WARNING
05718                          "rsbac_list_check(): count mismatch for list %s on device %02u:%02u - is %u, counted %lu!\n",
05719                          list->name, RSBAC_MAJOR(list->device), RSBAC_MINOR(list->device), list->count, tmp_count);
05720           }
05721       }
05722     rsbac_write_unlock(&list->lock, &lock_flags);
05723     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
05724     return 0;
05725   }

int rsbac_list_compare_u32 void *  desc1,
void *  desc2
 

Definition at line 5055 of file gen_lists.c.

Referenced by acl_register_fd_lists(), auth_register_fd_lists(), mac_register_fd_lists(), register_fd_lists(), register_process_lists(), register_user_lists(), rsbac_init_acl(), rsbac_init_pm(), rsbac_init_rc(), and rsbac_list_init().

05056   {
05057     if( *((__u32*) desc1) < *((__u32*) desc2))
05058       return -1;
05059     return( *((__u32*) desc1) != *((__u32*) desc2));
05060   }

long rsbac_list_count rsbac_list_handle_t  handle  ) 
 

Definition at line 9535 of file gen_lists.c.

References rsbac_ta_list_count().

Referenced by register_user_lists(), rsbac_check_acl(), rsbac_init_acl(), rsbac_init_rc(), rsbac_stats(), rsbac_stats_acl(), rsbac_stats_pm(), rsbac_stats_rc(), and rsbac_stats_um().

09536   {
09537     return rsbac_ta_list_count(0, handle);
09538   }

int rsbac_list_destroy rsbac_list_handle_t handle_p,
rsbac_list_key_t  key
 

Definition at line 6299 of file gen_lists.c.

References rsbac_list_reg_item_t::flags, rsbac_list_reg_item_t::info, rsbac_list_info_t::key, list_initialized, rsbac_list_reg_head_t::lock, lookup_reg(), rsbac_list_reg_item_t::name, NULL, proc_rsbac_backup_p, remove_reg(), RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_BACKUP, RSBAC_LIST_PERSIST, and rsbac_printk().

06300   {
06301     struct rsbac_list_reg_item_t * reg_item_p;
06302     u_long lock_flags;
06303     int err = 0;
06304 
06305     if(!handle_p)
06306       return -RSBAC_EINVALIDPOINTER;
06307     if(!*handle_p)
06308       return -RSBAC_EINVALIDVALUE;
06309     if(!list_initialized)
06310       return -RSBAC_ENOTINITIALIZED;
06311 
06312     rsbac_write_lock(&reg_head.lock, &lock_flags);
06313     reg_item_p = lookup_reg((struct rsbac_list_reg_item_t *) *handle_p);
06314     if(!reg_item_p)
06315       {
06316         rsbac_write_unlock(&reg_head.lock, &lock_flags);
06317         rsbac_printk(KERN_WARNING "rsbac_list_destroy: destroying list failed due to invalid handle!\n");
06318         return -RSBAC_EINVALIDVALUE;
06319       }
06320     if(reg_item_p->info.key != key)
06321       {
06322         rsbac_write_unlock(&reg_head.lock, &lock_flags);
06323         rsbac_printk(KERN_WARNING "rsbac_list_destroy: destroying list %s denied due to invalid key!\n",
06324                reg_item_p->name);
06325         return -EPERM;
06326       }
06327 #ifdef CONFIG_RSBAC_DEBUG
06328     if(rsbac_debug_lists)
06329       {
06330         rsbac_printk(KERN_DEBUG "rsbac_list_destroy: destroying list %s.\n",
06331                reg_item_p->name);
06332       }
06333 #endif
06334 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
06335     /* delete proc entry, if it exists */
06336     if(   (reg_item_p->flags & RSBAC_LIST_BACKUP)
06337        && reg_item_p->proc_entry_p
06338       )
06339       {
06340         remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p);
06341         reg_item_p->proc_entry_p = NULL;
06342       }
06343 #endif
06344 
06345 #if 0
06346     if(reg_item_p->flags & RSBAC_LIST_PERSIST)
06347       err = unlink_list(reg_item_p);
06348 #endif
06349 
06350     remove_reg(reg_item_p);
06351     *handle_p = NULL; 
06352     rsbac_write_unlock(&reg_head.lock, &lock_flags);
06353     return err;
06354   }

int rsbac_list_detach rsbac_list_handle_t handle_p,
rsbac_list_key_t  key
 

Definition at line 6421 of file gen_lists.c.

References rsbac_list_write_item_t::buflen, rsbac_list_write_head_t::count, rsbac_list_reg_item_t::dirty, FALSE, fill_buffer(), rsbac_list_reg_item_t::flags, rsbac_list_write_head_t::head, rsbac_list_reg_item_t::info, rsbac_list_info_t::key, list_initialized, rsbac_list_reg_head_t::lock, lookup_reg(), rsbac_list_reg_item_t::name, rsbac_list_reg_item_t::no_write, NULL, proc_rsbac_backup_p, remove_reg(), RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_ENOTWRITABLE, RSBAC_LIST_BACKUP, RSBAC_LIST_PERSIST, rsbac_list_write_buffers(), rsbac_printk(), rsbac_list_write_head_t::tail, rsbac_list_write_head_t::total, and TRUE.

Referenced by aci_detach_fd_lists(), cleanup_module(), and init_module().

06422   {
06423     struct rsbac_list_reg_item_t * reg_item_p;
06424     u_long lock_flags;
06425     int err = 0;
06426 
06427     if(!handle_p)
06428       return -RSBAC_EINVALIDPOINTER;
06429     if(!*handle_p)
06430       return -RSBAC_EINVALIDVALUE;
06431     if(!list_initialized)
06432       return -RSBAC_ENOTINITIALIZED;
06433 
06434     rsbac_read_lock(&reg_head.lock, &lock_flags);
06435     reg_item_p = lookup_reg((struct rsbac_list_reg_item_t *) *handle_p);
06436     if(!reg_item_p)
06437       {
06438         rsbac_read_unlock(&reg_head.lock, &lock_flags);
06439         rsbac_printk(KERN_WARNING "rsbac_list_detach: detaching list failed due to invalid handle!\n");
06440         return -RSBAC_EINVALIDVALUE;
06441       }
06442     if(reg_item_p->info.key != key)
06443       {
06444         rsbac_read_unlock(&reg_head.lock, &lock_flags);
06445         rsbac_printk(KERN_WARNING "rsbac_list_detach: detaching list %s denied due to invalid key %u!\n",
06446                reg_item_p->name,
06447                key);
06448         return -EPERM;
06449       }
06450 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
06451     /* delete proc entry, if it exists */
06452     if(   (reg_item_p->flags & RSBAC_LIST_BACKUP)
06453        && reg_item_p->proc_entry_p
06454       )
06455       {
06456         remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p);
06457         reg_item_p->proc_entry_p = NULL;
06458       }
06459 #endif
06460 #ifndef CONFIG_RSBAC_NO_WRITE
06461     /* final write, if dirty etc. */
06462     if(   (reg_item_p->flags & RSBAC_LIST_PERSIST)
06463        && reg_item_p->dirty
06464        && !reg_item_p->no_write
06465       )
06466       {
06467         struct rsbac_list_write_head_t       write_head;
06468         struct rsbac_list_write_item_t     * write_item_p;
06469 
06470         reg_item_p->dirty = FALSE;
06471         err = fill_buffer(reg_item_p, &write_item_p);
06472         if(!err)
06473           {
06474             write_head.head = write_item_p;
06475             write_head.tail = write_item_p;
06476             write_head.total = write_item_p->buflen;
06477             write_head.count = 1;
06478             rsbac_read_unlock(&reg_head.lock, &lock_flags);
06479             rsbac_list_write_buffers(write_head, TRUE);
06480           }
06481         else
06482           {
06483             rsbac_read_unlock(&reg_head.lock, &lock_flags);
06484             if(err != -RSBAC_ENOTWRITABLE)
06485               {
06486                 rsbac_printk(KERN_WARNING
06487                        "rsbac_list_detach(): fill_buffer() for list %s returned error %i\n",
06488                        reg_item_p->name, err);
06489               }
06490           }
06491       }
06492     else
06493       rsbac_read_unlock(&reg_head.lock, &lock_flags);
06494 #else
06495     rsbac_read_unlock(&reg_head.lock, &lock_flags);
06496 #endif
06497     /* disable handle */
06498     *handle_p = NULL; 
06499     /* too bad that the list might have been changed again - we do not care anymore */
06500     rsbac_write_lock(&reg_head.lock, &lock_flags);
06501     remove_reg(reg_item_p);
06502     rsbac_write_unlock(&reg_head.lock, &lock_flags);
06503     return err;
06504   }

int rsbac_list_exist rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 9060 of file gen_lists.c.

References rsbac_ta_list_exist().

Referenced by init_module(), rsbac_check_acl(), and rsbac_init_rc().

09063   {
09064     return rsbac_ta_list_exist(0, handle, desc);
09065   }

long rsbac_list_get_all_data rsbac_list_handle_t  handle,
void **  array_p
 

Definition at line 10041 of file gen_lists.c.

References rsbac_ta_list_get_all_data().

10044   {
10045     return rsbac_ta_list_get_all_data(0, handle, array_p);
10046   }

long rsbac_list_get_all_desc rsbac_list_handle_t  handle,
void **  array_p
 

Definition at line 9661 of file gen_lists.c.

References rsbac_ta_list_get_all_desc().

09664   {
09665     return rsbac_ta_list_get_all_desc(0, handle, array_p);
09666   }

long rsbac_list_get_all_items rsbac_list_handle_t  handle,
void **  array_p
 

Definition at line 10496 of file gen_lists.c.

References NULL, and rsbac_ta_list_get_all_items_ttl().

10497   {
10498     return rsbac_ta_list_get_all_items_ttl(0, handle, array_p, NULL);
10499   }

long rsbac_list_get_all_items_ttl rsbac_list_handle_t  handle,
void **  array_p,
rsbac_time_t **  ttl_array_p
 

Definition at line 10485 of file gen_lists.c.

References rsbac_ta_list_get_all_items_ttl().

10489   {
10490     return rsbac_ta_list_get_all_items_ttl(0, handle, array_p, ttl_array_p);
10491   }

int rsbac_list_get_data rsbac_list_handle_t  handle,
void *  desc,
void *  data
 

Definition at line 8322 of file gen_lists.c.

References NULL, and rsbac_ta_list_get_data_ttl().

Referenced by init_module(), rsbac_do_init(), rsbac_init(), and rsbac_init_debug().

08323   {
08324     return rsbac_ta_list_get_data_ttl(0, handle, NULL, desc, data);
08325   }

int rsbac_list_get_data_ttl rsbac_list_handle_t  handle,
rsbac_time_t ttl_p,
void *  desc,
void *  data
 

Definition at line 8311 of file gen_lists.c.

References rsbac_ta_list_get_data_ttl().

08315   {
08316     return rsbac_ta_list_get_data_ttl(0, handle, ttl_p, desc, data);
08317   }

int rsbac_list_get_desc rsbac_list_handle_t  handle,
void *  desc,
void *  data,
rsbac_list_data_compare_function_t  compare
 

Definition at line 8903 of file gen_lists.c.

References rsbac_ta_list_get_desc().

Referenced by rsbac_rc_get_boot_role().

08908   {
08909     return rsbac_ta_list_get_desc(0, handle, desc, data, compare);
08910   }

int rsbac_list_get_item_size rsbac_list_handle_t  handle  ) 
 

Definition at line 10289 of file gen_lists.c.

References rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::info, list_initialized, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, and rsbac_list_reg_item_t::self.

10290   {
10291     struct rsbac_list_reg_item_t * list;
10292 
10293     if(!handle)
10294       return -RSBAC_EINVALIDVALUE;
10295     if(!list_initialized)
10296       return -RSBAC_ENOTINITIALIZED;
10297 
10298     list = (struct rsbac_list_reg_item_t *) handle;
10299     if(list->self != list)
10300       return -RSBAC_EINVALIDVALUE;
10301     return list->info.desc_size + list->info.data_size;
10302   }

int rsbac_list_get_max_desc rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 8645 of file gen_lists.c.

References rsbac_ta_list_get_max_desc().

Referenced by rsbac_init_acl().

08646   {
08647     return rsbac_ta_list_get_max_desc(0, handle, desc);
08648   }

int rsbac_list_get_next_desc rsbac_list_handle_t  handle,
void *  old_desc,
void *  next_desc
 

Definition at line 8730 of file gen_lists.c.

References rsbac_ta_list_get_next_desc().

08731   {
08732     return rsbac_ta_list_get_next_desc(0, handle, old_desc, next_desc);
08733   }

int rsbac_list_lol_add rsbac_list_handle_t  handle,
void *  desc,
void *  data
 

Definition at line 7484 of file gen_lists.c.

References RSBAC_LIST_TTL_KEEP, and rsbac_ta_list_lol_add_ttl().

Referenced by rsbac_init_acl(), rsbac_init_rc(), rsbac_pm_pp_intersec(), and rsbac_pm_pp_union().

07488   {
07489     return rsbac_ta_list_lol_add_ttl(0, handle, RSBAC_LIST_TTL_KEEP, desc, data);
07490   }

int rsbac_list_lol_add_ttl rsbac_list_handle_t  handle,
rsbac_time_t  ttl,
void *  desc,
void *  data
 

Definition at line 7472 of file gen_lists.c.

References rsbac_ta_list_lol_add_ttl().

07477   {
07478     return rsbac_ta_list_lol_add_ttl(0, handle, ttl, desc, data);
07479   }

long rsbac_list_lol_all_subcount rsbac_list_handle_t  handle  ) 
 

Definition at line 9444 of file gen_lists.c.

References rsbac_ta_list_lol_all_subcount().

Referenced by rsbac_stats_acl(), rsbac_stats_auth(), rsbac_stats_mac(), rsbac_stats_pm(), and rsbac_stats_um().

09445   {
09446     return rsbac_ta_list_lol_all_subcount(0, handle);
09447   }

int rsbac_list_lol_check rsbac_list_handle_t  handle,
int  correct
 

Definition at line 5730 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::count, rsbac_list_lol_item_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_reg_item_t::def_subdata, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::device, do_remove_lol_item(), do_remove_lol_subitem(), rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_reg_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, rsbac_list_item_t::max_age, rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::name, rsbac_list_item_t::next, rsbac_list_lol_item_t::next, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, rsbac_printk(), rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size.

05733   {
05734     struct rsbac_list_lol_reg_item_t * lol_list;
05735     struct rsbac_list_lol_item_t     * lol_item_p;
05736     struct rsbac_list_lol_item_t     * next_lol_item_p;
05737     struct rsbac_list_item_t         * lol_subitem_p;
05738     struct rsbac_list_item_t         * next_lol_subitem_p;
05739     u_long lock_flags;
05740     u_long rlock_flags;
05741     u_long tmp_count;
05742     u_long tmp_subcount;
05743 
05744     if(!handle)
05745       return -RSBAC_EINVALIDVALUE;
05746     if(!list_initialized)
05747       return -RSBAC_ENOTINITIALIZED;
05748 
05749     lol_list = (struct rsbac_list_lol_reg_item_t *) handle;
05750     if(!lol_list || (lol_list->self != lol_list))
05751       return -RSBAC_EINVALIDVALUE;
05752 
05753     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
05754 #ifdef CONFIG_RSBAC_DEBUG
05755     if(rsbac_debug_lists)
05756       rsbac_printk(KERN_DEBUG "rsbac_list_lol_check: checking list %s.\n",
05757              lol_list->name);
05758 #endif
05759     rsbac_write_lock(&lol_list->lock, &lock_flags);
05760     tmp_count = 0;
05761     lol_item_p = lol_list->head;
05762     while(lol_item_p)
05763       {
05764         if(   (   lol_item_p->max_age
05765                && (lol_item_p->max_age <= RSBAC_CURRENT_TIME)
05766               )
05767            || (   lol_list->def_data
05768                && !lol_item_p->count
05769                && !memcmp(((char *) lol_item_p) + sizeof(*lol_item_p) + lol_list->info.desc_size,
05770                           lol_list->def_data,
05771                           lol_list->info.data_size)
05772               )
05773            || (   !lol_list->info.data_size
05774                && (lol_list->flags & RSBAC_LIST_DEF_DATA)
05775                && !lol_item_p->count
05776               )
05777           )
05778           {
05779             next_lol_item_p = lol_item_p->next;
05780             do_remove_lol_item(lol_list, lol_item_p);
05781             lol_item_p = next_lol_item_p;
05782           }
05783         else
05784           {
05785             tmp_count++;
05786             tmp_subcount = 0;
05787             lol_subitem_p = lol_item_p->head;
05788             while(lol_subitem_p)
05789               {
05790                 if(   (   lol_subitem_p->max_age
05791                        && (lol_subitem_p->max_age <= RSBAC_CURRENT_TIME)
05792                       )
05793                    || (   lol_list->def_subdata
05794                        && !memcmp(((char *) lol_subitem_p) + sizeof(*lol_subitem_p) + lol_list->info.subdesc_size,
05795                                   lol_list->def_subdata,
05796                                   lol_list->info.subdata_size)
05797                       )
05798                   )
05799                   {
05800                     next_lol_subitem_p = lol_subitem_p->next;
05801                     do_remove_lol_subitem(lol_item_p, lol_subitem_p);
05802                     lol_subitem_p = next_lol_subitem_p;
05803                   }
05804                 else
05805                   {
05806                     tmp_subcount++;
05807                     lol_subitem_p = lol_subitem_p->next;
05808                   }
05809               }
05810             if(tmp_subcount != lol_item_p->count)
05811               {
05812                 if(correct)
05813                   {
05814                      rsbac_printk(KERN_WARNING
05815                                   "rsbac_list_lol_check(): correcting count mismatch for list of lists %s sublist on %02u:%02u - was %lu, counted %lu!\n",
05816                                   lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_item_p->count, tmp_subcount);
05817                     lol_item_p->count = tmp_subcount;
05818                   }
05819                 else
05820                   {
05821                     rsbac_printk(KERN_WARNING
05822                                  "rsbac_list_lol_check(): count mismatch for list of lists %s sublist on %02u:%02u - is %lu, counted %lu!\n",
05823                                  lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_item_p->count, tmp_subcount);
05824                   }
05825               }
05826             lol_item_p = lol_item_p->next;
05827           }
05828       }
05829     if(tmp_count != lol_list->count)
05830       {
05831         if(correct)
05832           {
05833             rsbac_printk(KERN_WARNING
05834                          "rsbac_list_lol_check(): correcting count mismatch for list of lists %s on %02u:%02u - was %u, counted %lu!\n",
05835                          lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_list->count, tmp_count);
05836             lol_list->count = tmp_count;
05837           }
05838         else
05839           {
05840             rsbac_printk(KERN_WARNING
05841                          "rsbac_list_lol_check(): count mismatch for list of lists %s on %02u:%02u - is %u, counted %lu!\n",
05842                          lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_list->count, tmp_count);
05843           }
05844       }
05845     rsbac_write_unlock(&lol_list->lock, &lock_flags);
05846     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
05847     return 0;
05848   }

long rsbac_list_lol_count rsbac_list_handle_t  handle  ) 
 

Definition at line 9493 of file gen_lists.c.

References rsbac_ta_list_lol_count().

Referenced by rsbac_check_acl(), rsbac_init_acl(), rsbac_stats_acl(), rsbac_stats_auth(), rsbac_stats_mac(), rsbac_stats_pm(), and rsbac_stats_um().

09494   {
09495     return rsbac_ta_list_lol_count(0, handle);
09496   }

int rsbac_list_lol_destroy rsbac_list_handle_t handle_p,
rsbac_list_key_t  key
 

Definition at line 6359 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_reg_item_t::info, rsbac_list_lol_info_t::key, list_initialized, rsbac_list_lol_reg_head_t::lock, lookup_lol_reg(), rsbac_list_lol_reg_item_t::name, NULL, proc_rsbac_backup_p, remove_lol_reg(), RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_BACKUP, RSBAC_LIST_PERSIST, and rsbac_printk().

06360   {
06361     struct rsbac_list_lol_reg_item_t * reg_item_p;
06362     u_long lock_flags;
06363     int err = 0;
06364 
06365     if(!handle_p)
06366       return -RSBAC_EINVALIDPOINTER;
06367     if(!*handle_p)
06368       return -RSBAC_EINVALIDVALUE;
06369     if(!list_initialized)
06370       return -RSBAC_ENOTINITIALIZED;
06371 
06372     rsbac_write_lock(&lol_reg_head.lock, &lock_flags);
06373     reg_item_p = lookup_lol_reg((struct rsbac_list_lol_reg_item_t *) *handle_p);
06374     if(!reg_item_p)
06375       {
06376         rsbac_write_unlock(&lol_reg_head.lock, &lock_flags);
06377         rsbac_printk(KERN_WARNING "rsbac_list_lol_destroy: destroying list failed due to invalid handle!\n");
06378         return -RSBAC_EINVALIDVALUE;
06379       }
06380     if(reg_item_p->info.key != key)
06381       {
06382         rsbac_write_unlock(&lol_reg_head.lock, &lock_flags);
06383         rsbac_printk(KERN_WARNING "rsbac_list_lol_destroy: destroying list %s denied due to invalid key %u!\n",
06384                reg_item_p->name,
06385                key);
06386         return -EPERM;
06387       }
06388 #ifdef CONFIG_RSBAC_DEBUG
06389     if(rsbac_debug_lists)
06390       {
06391         rsbac_printk(KERN_DEBUG "rsbac_list_lol_destroy: destroying list %s.\n",
06392                reg_item_p->name);
06393       }
06394 #endif
06395 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
06396     /* delete proc entry, if it exists */
06397     if(   (reg_item_p->flags & RSBAC_LIST_BACKUP)
06398        && reg_item_p->proc_entry_p
06399       )
06400       {
06401         remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p);
06402         reg_item_p->proc_entry_p = NULL;
06403       }
06404 #endif
06405 #if 0
06406     if(reg_item_p->flags & RSBAC_LIST_PERSIST)
06407       err = unlink_lol_list(reg_item_p);
06408 #endif
06409 
06410     remove_lol_reg(reg_item_p);
06411     *handle_p = NULL; 
06412     rsbac_write_unlock(&lol_reg_head.lock, &lock_flags);
06413     return err;
06414   }

int rsbac_list_lol_detach rsbac_list_handle_t handle_p,
rsbac_list_key_t  key
 

Definition at line 6509 of file gen_lists.c.

References rsbac_list_lol_write_item_t::buflen, rsbac_list_lol_write_head_t::count, rsbac_list_lol_reg_item_t::dirty, FALSE, fill_lol_buffer(), rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_write_head_t::head, rsbac_list_lol_reg_item_t::info, rsbac_list_lol_info_t::key, list_initialized, rsbac_list_lol_reg_head_t::lock, lookup_lol_reg(), rsbac_list_lol_reg_item_t::name, rsbac_list_lol_reg_item_t::no_write, NULL, proc_rsbac_backup_p, remove_lol_reg(), RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_ENOTWRITABLE, RSBAC_LIST_BACKUP, RSBAC_LIST_PERSIST, rsbac_list_write_lol_buffers(), rsbac_printk(), rsbac_list_lol_write_head_t::tail, rsbac_list_lol_write_head_t::total, and TRUE.

Referenced by acl_detach_fd_lists(), auth_detach_fd_lists(), and mac_detach_fd_lists().

06510   {
06511     struct rsbac_list_lol_reg_item_t * reg_item_p;
06512     u_long lock_flags;
06513     int err = 0;
06514 
06515     if(!handle_p)
06516       return -RSBAC_EINVALIDPOINTER;
06517     if(!*handle_p)
06518       return -RSBAC_EINVALIDVALUE;
06519     if(!list_initialized)
06520       return -RSBAC_ENOTINITIALIZED;
06521 
06522     rsbac_read_lock(&lol_reg_head.lock, &lock_flags);
06523     reg_item_p = lookup_lol_reg((struct rsbac_list_lol_reg_item_t *) *handle_p);
06524     if(!reg_item_p)
06525       {
06526         rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06527         rsbac_printk(KERN_WARNING "rsbac_list_lol_detach: detaching list failed due to invalid handle!\n");
06528         return -RSBAC_EINVALIDVALUE;
06529       }
06530     if(reg_item_p->info.key != key)
06531       {
06532         rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06533         rsbac_printk(KERN_WARNING "rsbac_list_lol_detach: detaching list %s denied due to invalid key %u!\n",
06534                reg_item_p->name,
06535                key);
06536         return -EPERM;
06537       }
06538 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
06539     /* delete proc entry, if it exists */
06540     if(   (reg_item_p->flags & RSBAC_LIST_BACKUP)
06541        && reg_item_p->proc_entry_p
06542       )
06543       {
06544         remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p);
06545         reg_item_p->proc_entry_p = NULL;
06546       }
06547 #endif
06548 #ifndef CONFIG_RSBAC_NO_WRITE
06549     /* final write, if dirty etc. */
06550     if(   (reg_item_p->flags & RSBAC_LIST_PERSIST)
06551        && reg_item_p->dirty
06552        && !reg_item_p->no_write
06553       )
06554       {
06555         struct rsbac_list_lol_write_head_t       write_head;
06556         struct rsbac_list_lol_write_item_t     * write_item_p;
06557 
06558         reg_item_p->dirty = FALSE;
06559         err = fill_lol_buffer(reg_item_p, &write_item_p);
06560         if(!err)
06561           {
06562             write_head.head = write_item_p;
06563             write_head.tail = write_item_p;
06564             write_head.total = write_item_p->buflen;
06565             write_head.count = 1;
06566             rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06567             rsbac_list_write_lol_buffers(write_head, TRUE);
06568           }
06569         else
06570           {
06571             rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06572             if(err != -RSBAC_ENOTWRITABLE)
06573               {
06574                 rsbac_printk(KERN_WARNING
06575                        "rsbac_list_lol_detach(): fill_buffer() for list %s returned error %i\n",
06576                        reg_item_p->name, err);
06577               }
06578           }
06579       }
06580     else
06581       rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06582 #else
06583     rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06584 #endif
06585     /* disable handle */
06586     *handle_p = NULL; 
06587     /* too bad that the list might have been changed again - we do not care anymore */
06588     rsbac_write_lock(&lol_reg_head.lock, &lock_flags);
06589     remove_lol_reg(reg_item_p);
06590     rsbac_write_unlock(&lol_reg_head.lock, &lock_flags);
06591     return err;
06592   }

int rsbac_list_lol_exist rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 9308 of file gen_lists.c.

References rsbac_ta_list_lol_exist().

Referenced by rsbac_pm_pp_intersec(), rsbac_pm_pp_subset(), rsbac_pm_pp_superset(), and rsbac_pm_pp_union().

09311   {
09312     return rsbac_ta_list_lol_exist(0, handle, desc);
09313   }

long rsbac_list_lol_get_all_data rsbac_list_handle_t  handle,
void **  array_p
 

Definition at line 10277 of file gen_lists.c.

References rsbac_ta_list_lol_get_all_data().

10280   {
10281     return rsbac_ta_list_lol_get_all_data(0, handle, array_p);
10282   }

long rsbac_list_lol_get_all_desc rsbac_list_handle_t  handle,
void **  array_p
 

Definition at line 9907 of file gen_lists.c.

References rsbac_ta_list_lol_get_all_desc().

Referenced by rsbac_check_acl(), and rsbac_init_rc().

09908   {
09909     return rsbac_ta_list_lol_get_all_desc(0, handle, array_p);
09910   }

long rsbac_list_lol_get_all_items rsbac_list_handle_t  handle,
void **  array_p
 

Definition at line 10737 of file gen_lists.c.

References rsbac_ta_list_lol_get_all_items().

10740   {
10741     return rsbac_ta_list_lol_get_all_items(0, handle, array_p);
10742   }

long rsbac_list_lol_get_all_subdata rsbac_list_handle_t  handle,
void *  desc,
void **  array_p
 

Definition at line 10145 of file gen_lists.c.

References rsbac_ta_list_lol_get_all_subdata().

10149   {
10150     return rsbac_ta_list_lol_get_all_subdata(0, handle, desc, array_p);
10151   }

long rsbac_list_lol_get_all_subdesc rsbac_list_handle_t  handle,
void *  desc,
void **  array_p
 

Definition at line 9786 of file gen_lists.c.

References NULL, and rsbac_ta_list_lol_get_all_subdesc_ttl().

Referenced by rsbac_check_acl(), rsbac_pm_pp_intersec(), rsbac_pm_pp_subset(), rsbac_pm_pp_superset(), and rsbac_pm_pp_union().

09787   {
09788     return rsbac_ta_list_lol_get_all_subdesc_ttl(0, handle,
09789                                                  desc, array_p, NULL);
09790   }

long rsbac_list_lol_get_all_subdesc_ttl rsbac_list_handle_t  handle,
void *  desc,
void **  array_p,
rsbac_time_t **  ttl_array_p
 

Definition at line 9770 of file gen_lists.c.

References rsbac_ta_list_lol_get_all_subdesc_ttl().

Referenced by copy_fp_cap_set_item(), copy_fp_tru_set_item(), copy_pp_cap_set_item_handle(), and copy_pp_tru_set_item_handle().

09775   {
09776     return rsbac_ta_list_lol_get_all_subdesc_ttl(0,
09777                                                  handle,
09778                                                  desc,
09779                                                  array_p,
09780                                                  ttl_array_p);
09781   }

long rsbac_list_lol_get_all_subitems rsbac_list_handle_t  handle,
void *  desc,
void **  array_p
 

Definition at line 10616 of file gen_lists.c.

References NULL, and rsbac_ta_list_lol_get_all_subitems_ttl().

10617   {
10618     return rsbac_ta_list_lol_get_all_subitems_ttl(0, handle, desc,
10619                                                   array_p, NULL);
10620   }

long rsbac_list_lol_get_all_subitems_ttl rsbac_list_handle_t  handle,
void *  desc,
void **  array_p,
rsbac_time_t **  ttl_array_p
 

Definition at line 10603 of file gen_lists.c.

References rsbac_ta_list_lol_get_all_subitems_ttl().

10608   {
10609     return rsbac_ta_list_lol_get_all_subitems_ttl(0, handle, desc,
10610                                                   array_p, ttl_array_p);
10611   }

int rsbac_list_lol_get_data rsbac_list_handle_t  handle,
void *  desc,
void *  data
 

Definition at line 8573 of file gen_lists.c.

References NULL, and rsbac_ta_list_lol_get_data_ttl().

08576   {
08577     return rsbac_ta_list_lol_get_data_ttl(0, handle, NULL, desc, data);
08578   }

int rsbac_list_lol_get_data_ttl rsbac_list_handle_t  handle,
rsbac_time_t ttl_p,
void *  desc,
void *  data
 

Definition at line 8562 of file gen_lists.c.

References rsbac_ta_list_lol_get_data_ttl().

08566   {
08567     return rsbac_ta_list_lol_get_data_ttl(0, handle, ttl_p, desc, data);
08568   }

int rsbac_list_lol_get_desc rsbac_list_handle_t  handle,
void *  desc,
void *  data,
rsbac_list_data_compare_function_t  compare
 

Definition at line 8984 of file gen_lists.c.

References rsbac_ta_list_lol_get_desc().

08989   {
08990     return rsbac_ta_list_lol_get_desc(0, handle, desc, data, compare);
08991   }

int rsbac_list_lol_get_item_size rsbac_list_handle_t  handle  ) 
 

Definition at line 10325 of file gen_lists.c.

References rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::info, list_initialized, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, and rsbac_list_lol_reg_item_t::self.

10326   {
10327     struct rsbac_list_lol_reg_item_t * list;
10328 
10329     if(!handle)
10330       return -RSBAC_EINVALIDVALUE;
10331     if(!list_initialized)
10332       return -RSBAC_ENOTINITIALIZED;
10333 
10334     list = (struct rsbac_list_lol_reg_item_t *) handle;
10335     if(list->self != list)
10336       return -RSBAC_EINVALIDVALUE;
10337     return list->info.desc_size + list->info.data_size;
10338   }

int rsbac_list_lol_get_next_desc rsbac_list_handle_t  handle,
void *  old_desc,
void *  next_desc
 

Definition at line 8815 of file gen_lists.c.

References rsbac_ta_list_lol_get_next_desc().

08819   {
08820     return rsbac_ta_list_lol_get_next_desc(0, handle, old_desc, next_desc);
08821   }

int rsbac_list_lol_get_subdata rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc,
void *  subdata
 

Definition at line 8457 of file gen_lists.c.

References NULL, and rsbac_ta_list_lol_get_subdata_ttl().

Referenced by rsbac_rc_check_comp().

08462   {
08463     return rsbac_ta_list_lol_get_subdata_ttl(0, handle, NULL, desc, subdesc, subdata);
08464   }

int rsbac_list_lol_get_subdata_ttl rsbac_list_handle_t  handle,
rsbac_time_t ttl_p,
void *  desc,
void *  subdesc,
void *  subdata
 

Definition at line 8443 of file gen_lists.c.

References rsbac_ta_list_lol_get_subdata_ttl().

08449   {
08450     return rsbac_ta_list_lol_get_subdata_ttl(0, handle,
08451                                              ttl_p, desc, subdesc, subdata);
08452   }

int rsbac_list_lol_get_subitem_size rsbac_list_handle_t  handle  ) 
 

Definition at line 10307 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::info, list_initialized, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size.

Referenced by rsbac_rc_copy_role().

10308   {
10309     struct rsbac_list_lol_reg_item_t * list;
10310 
10311     if(!handle)
10312       return -RSBAC_EINVALIDVALUE;
10313     if(!list_initialized)
10314       return -RSBAC_ENOTINITIALIZED;
10315 
10316     list = (struct rsbac_list_lol_reg_item_t *) handle;
10317     if(list->self != list)
10318       return -RSBAC_EINVALIDVALUE;
10319     return list->info.subdesc_size + list->info.subdata_size;
10320   }

int rsbac_list_lol_no_write rsbac_list_handle_t  handle,
rsbac_list_key_t  key,
rsbac_boolean_t  no_write
 

Definition at line 6637 of file gen_lists.c.

References FALSE, rsbac_list_lol_reg_item_t::info, rsbac_list_lol_info_t::key, list_initialized, rsbac_list_lol_reg_head_t::lock, lookup_lol_reg(), rsbac_list_lol_reg_item_t::name, rsbac_list_lol_reg_item_t::no_write, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_printk(), and TRUE.

06638   {
06639     struct rsbac_list_lol_reg_item_t * reg_item_p;
06640     u_long lock_flags;
06641 
06642     if(   !handle
06643        || (   (no_write != FALSE )
06644            && (no_write != TRUE )
06645           )
06646       )
06647       return -RSBAC_EINVALIDVALUE;
06648     if(!list_initialized)
06649       return -RSBAC_ENOTINITIALIZED;
06650 
06651     rsbac_read_lock(&lol_reg_head.lock, &lock_flags);
06652     reg_item_p = lookup_lol_reg((struct rsbac_list_lol_reg_item_t *) handle);
06653     if(!reg_item_p)
06654       {
06655         rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06656         rsbac_printk(KERN_WARNING "rsbac_list_lol_no_write: setting no_write for list denied due to invalid handle!\n");
06657         return -RSBAC_EINVALIDVALUE;
06658       }
06659     if(reg_item_p->info.key != key)
06660       {
06661         rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06662         rsbac_printk(KERN_WARNING "rsbac_list_lol_no_write: setting no_write for list %s denied due to invalid key %u!\n",
06663                reg_item_p->name,
06664                key);
06665         return -EPERM;
06666       }
06667     reg_item_p->no_write = no_write;
06668     rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06669     return 0;
06670   }

int rsbac_list_lol_register rsbac_version_t  ds_version,
rsbac_list_handle_t handle_p,
struct rsbac_list_lol_info_t info_p,
u_int  flags,
rsbac_list_compare_function_t compare,
rsbac_list_compare_function_t subcompare,
rsbac_list_get_conv_t get_conv,
rsbac_list_get_conv_t get_subconv,
void *  def_data,
void *  def_subdata,
char *  name,
kdev_t  device
 

Definition at line 6110 of file gen_lists.c.

References add_lol_reg(), clear_lol_reg(), create_lol_reg(), rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, get_error_name(), rsbac_list_lol_info_t::key, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_reg_name(), lookup_reg_name(), rsbac_list_lol_info_t::max_age, rsbac_list_lol_reg_item_t::name, NULL, proc_rsbac_backup_p, read_lol_list(), RSBAC_ECOULDNOTADDITEM, RSBAC_EEXISTS, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDVALUE, RSBAC_EINVALIDVERSION, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_kfree(), rsbac_kmalloc(), RSBAC_LIST_BACKUP, RSBAC_LIST_MAX_AGE_LIMIT, RSBAC_LIST_MAX_ITEM_SIZE, RSBAC_LIST_PERSIST, RSBAC_LIST_VERSION, RSBAC_MAXNAMELEN, rsbac_printk(), rsbac_root_dev, rsbac_list_lol_info_t::subdata_size, rsbac_list_lol_info_t::subdesc_size, and rsbac_list_lol_info_t::version.

Referenced by acl_register_fd_lists(), auth_register_fd_lists(), mac_register_fd_lists(), rsbac_init_acl(), rsbac_init_auth(), rsbac_init_mac(), rsbac_init_pm(), rsbac_init_rc(), and rsbac_init_um().

06123   {
06124     struct rsbac_list_lol_reg_item_t * reg_item_p;
06125     struct rsbac_list_lol_reg_item_t * new_reg_item_p;
06126     u_long lock_flags;
06127     int    err = 0;
06128 
06129     if(ds_version != RSBAC_LIST_VERSION)
06130       return -RSBAC_EINVALIDVERSION;
06131     if(!handle_p)
06132       return -RSBAC_EINVALIDPOINTER;
06133     *handle_p = NULL;
06134     if(!info_p->key || !info_p->version || !info_p->desc_size)
06135       return -RSBAC_EINVALIDVALUE;
06136     if(info_p->max_age > RSBAC_LIST_MAX_AGE_LIMIT)
06137       return -RSBAC_EINVALIDVALUE;
06138     if(info_p->desc_size + info_p->data_size > RSBAC_LIST_MAX_ITEM_SIZE)
06139       return -RSBAC_EINVALIDVALUE;
06140     if(info_p->subdesc_size + info_p->subdata_size > RSBAC_LIST_MAX_ITEM_SIZE)
06141       return -RSBAC_EINVALIDVALUE;
06142     if(!list_initialized)
06143       return -RSBAC_ENOTINITIALIZED;
06144     if(name)
06145       {
06146         struct rsbac_list_reg_item_t     * std_reg_item_p;
06147 
06148         rsbac_read_lock(&lol_reg_head.lock, &lock_flags);
06149         reg_item_p = lookup_lol_reg_name(name, device);
06150         rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06151         if(reg_item_p)
06152           {
06153 #ifdef CONFIG_RSBAC_DEBUG
06154             if(rsbac_debug_lists)
06155               {
06156                 rsbac_printk(KERN_DEBUG "rsbac_list_lol_register: list name %s already exists on device %02u:%02u!\n",
06157                        name, RSBAC_MAJOR(device), RSBAC_MINOR(device));
06158               }
06159 #endif
06160             return -RSBAC_EEXISTS;
06161           }
06162         rsbac_read_lock(&reg_head.lock, &lock_flags);
06163         std_reg_item_p = lookup_reg_name(name, device);
06164         rsbac_read_unlock(&reg_head.lock, &lock_flags);
06165         if(std_reg_item_p)
06166           {
06167 #ifdef CONFIG_RSBAC_DEBUG
06168             if(rsbac_debug_lists)
06169               {
06170                 rsbac_printk(KERN_DEBUG "rsbac_list_register: list name %s already exists on device %02u:%02u!\n",
06171                        name, RSBAC_MAJOR(device), RSBAC_MINOR(device));
06172               }
06173 #endif
06174             return -RSBAC_EEXISTS;
06175           }
06176       }
06177     else
06178       if(flags & RSBAC_LIST_PERSIST)
06179         {
06180           rsbac_printk(KERN_WARNING
06181                  "rsbac_list_lol_register: trial to register persistent list of lists without name.\n");
06182           return -RSBAC_EINVALIDVALUE;
06183         }
06184 
06185     if(flags & RSBAC_LIST_PERSIST)
06186       {
06187         if(RSBAC_IS_AUTO_DEV(device))
06188           device = rsbac_root_dev;
06189         if(!RSBAC_MAJOR(device))
06190           flags &= ~RSBAC_LIST_PERSIST;
06191       }
06192 
06193 #ifdef CONFIG_RSBAC_DEBUG
06194     if(rsbac_debug_lists)
06195       {
06196         rsbac_printk(KERN_DEBUG "rsbac_list_lol_register: registering list of lists %s.\n",
06197                name);
06198       }
06199 #endif
06200     new_reg_item_p = create_lol_reg(info_p, flags, compare, subcompare,
06201                                     get_conv, get_subconv,
06202                                     def_data, def_subdata,
06203                                     name, device);
06204     if(!new_reg_item_p)
06205       {
06206         return -RSBAC_ECOULDNOTADDITEM;
06207       }
06208     /* Restore from disk */
06209     if(flags & RSBAC_LIST_PERSIST)
06210       {
06211 #ifdef CONFIG_RSBAC_DEBUG
06212         if(rsbac_debug_lists)
06213           {
06214             rsbac_printk(KERN_DEBUG "rsbac_list_lol_register: restoring list %s from device %02u:%02u.\n",
06215                    name, RSBAC_MAJOR(device), RSBAC_MINOR(device));
06216           }
06217 #endif
06218         err = read_lol_list(new_reg_item_p);
06219         /* not found is no error */
06220         if(err == -RSBAC_ENOTFOUND)
06221           err = 0;
06222         else
06223         if(err)
06224           {
06225 #ifdef CONFIG_RSBAC_DEBUG
06226             if(rsbac_debug_lists)
06227               {
06228                 char * tmp = rsbac_kmalloc(RSBAC_MAXNAMELEN);
06229 
06230                 if(tmp)
06231                   {
06232                     get_error_name(tmp, err);
06233                     rsbac_printk(KERN_DEBUG "rsbac_list_lol_register: restoring list %s from device %02u:%02u failed with error %s, unregistering list.\n",
06234                            name,
06235                            RSBAC_MAJOR(device),RSBAC_MINOR(device),
06236                            tmp);
06237                     rsbac_kfree(tmp);
06238                   }
06239               }
06240 #endif
06241             clear_lol_reg(new_reg_item_p);
06242             return err;
06243           }
06244 #ifdef CONFIG_RSBAC_DEBUG
06245         else
06246           {
06247             if(rsbac_debug_lists)
06248               {
06249                 rsbac_printk(KERN_DEBUG "rsbac_list_lol_register: restoring list %s from device %02u:%02u was successful.\n",
06250                        name,
06251                        RSBAC_MAJOR(device),RSBAC_MINOR(device));
06252               }
06253           }
06254 #endif
06255       }
06256 
06257     rsbac_write_lock(&lol_reg_head.lock, &lock_flags);
06258     reg_item_p = add_lol_reg(new_reg_item_p);
06259     rsbac_write_unlock(&lol_reg_head.lock, &lock_flags);
06260     if(!reg_item_p)
06261       {
06262         rsbac_printk(KERN_WARNING
06263                "rsbac_list_lol_register: inserting list %s failed!\n",
06264                name);
06265         /* cleanup */
06266         clear_lol_reg(new_reg_item_p);
06267         return -RSBAC_ECOULDNOTADDITEM;
06268       }
06269 
06270     /* finish */
06271 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
06272     /* create proc entry, if requested */
06273     if(flags & RSBAC_LIST_BACKUP)
06274       {
06275         reg_item_p->proc_entry_p = create_proc_entry(reg_item_p->name,
06276                                                      S_IFREG | S_IRUGO,
06277                                                      proc_rsbac_backup_p);
06278         if(reg_item_p->proc_entry_p)
06279           {
06280             reg_item_p->proc_entry_p->read_proc = lol_backup_proc_read;
06281             reg_item_p->proc_entry_p->data = reg_item_p;
06282           }
06283       }
06284     else
06285       {
06286         reg_item_p->proc_entry_p = NULL;
06287       }
06288 #endif
06289     *handle_p = reg_item_p;
06290     return err;
06291   }

int rsbac_list_lol_remove rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 8112 of file gen_lists.c.

References rsbac_ta_list_lol_remove().

Referenced by copy_fp_cap_set_item(), copy_fp_tru_set_item(), copy_pp_cap_set_item_handle(), copy_pp_tru_set_item_handle(), and rsbac_check_acl().

08115   {
08116     return rsbac_ta_list_lol_remove(0, handle, desc);
08117   }

int rsbac_list_lol_remove_all rsbac_list_handle_t  handle  ) 
 

Definition at line 8208 of file gen_lists.c.

References rsbac_ta_list_lol_remove_all().

08209   {
08210     return rsbac_ta_list_lol_remove_all(0, handle);
08211   }

int rsbac_list_lol_subadd rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc,
void *  subdata
 

Definition at line 7322 of file gen_lists.c.

References RSBAC_LIST_TTL_KEEP, and rsbac_ta_list_lol_subadd_ttl().

Referenced by rsbac_auth_p_capset_member(), rsbac_init_acl(), rsbac_init_rc(), rsbac_pm_pp_intersec(), and rsbac_pm_pp_union().

07327   {
07328     return rsbac_ta_list_lol_subadd_ttl(0, handle, RSBAC_LIST_TTL_KEEP, desc, subdesc, subdata);
07329   }

int rsbac_list_lol_subadd_ttl rsbac_list_handle_t  handle,
rsbac_time_t  ttl,
void *  desc,
void *  subdesc,
void *  subdata
 

Definition at line 7309 of file gen_lists.c.

References rsbac_ta_list_lol_subadd_ttl().

Referenced by copy_fp_cap_set_item(), copy_fp_tru_set_item(), copy_pp_cap_set_item_handle(), and copy_pp_tru_set_item_handle().

07315   {
07316     return rsbac_ta_list_lol_subadd_ttl(0, handle, ttl, desc, subdesc, subdata);
07317   }

long rsbac_list_lol_subcount rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 9379 of file gen_lists.c.

References rsbac_ta_list_lol_subcount().

Referenced by rsbac_pm_pp_only().

09382   {
09383     return rsbac_ta_list_lol_subcount(0, handle, desc);
09384   }

int rsbac_list_lol_subexist rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc
 

Definition at line 9144 of file gen_lists.c.

References rsbac_ta_list_lol_subexist().

Referenced by rsbac_init_rc(), rsbac_mac_p_truset_member(), rsbac_pm_pp_intersec(), rsbac_pm_pp_only(), rsbac_pm_pp_subset(), rsbac_pm_pp_superset(), rsbac_rc_check_comp(), and rsbac_ta_list_lol_subexist_compare().

09148   {
09149     return rsbac_ta_list_lol_subexist(0, handle, desc, subdesc);
09150   }

int rsbac_list_lol_subexist_compare rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc,
rsbac_list_compare_function_t  compare
 

Definition at line 9232 of file gen_lists.c.

References rsbac_ta_list_lol_subexist_compare().

Referenced by rsbac_auth_p_capset_member().

09237   {
09238     return rsbac_ta_list_lol_subexist_compare(0, handle,
09239                                               desc, subdesc, compare);
09240   }

int rsbac_list_lol_subremove rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc
 

Definition at line 7813 of file gen_lists.c.

References rsbac_ta_list_lol_subremove().

Referenced by rsbac_check_acl(), and rsbac_pm_pp_intersec().

07817   {
07818     return rsbac_ta_list_lol_subremove(0, handle, desc, subdesc);
07819   }

int rsbac_list_lol_subremove_all rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 8024 of file gen_lists.c.

References rsbac_ta_list_lol_subremove_all().

08025   {
08026     return rsbac_ta_list_lol_subremove_all(0, handle, desc);
08027   }

int rsbac_list_lol_subremove_from_all rsbac_list_handle_t  handle,
void *  subdesc
 

Definition at line 7912 of file gen_lists.c.

References rsbac_ta_list_lol_subremove_from_all().

07915   {
07916     return rsbac_ta_list_lol_subremove_from_all(0, handle, subdesc);
07917   }

int rsbac_list_no_write rsbac_list_handle_t  handle,
rsbac_list_key_t  key,
rsbac_boolean_t  no_write
 

Definition at line 6599 of file gen_lists.c.

References FALSE, rsbac_list_reg_item_t::info, rsbac_list_info_t::key, list_initialized, rsbac_list_reg_head_t::lock, lookup_reg(), rsbac_list_reg_item_t::name, rsbac_list_reg_item_t::no_write, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_printk(), and TRUE.

06600   {
06601     struct rsbac_list_reg_item_t * reg_item_p;
06602     u_long lock_flags;
06603 
06604     if(   !handle
06605        || (   (no_write != FALSE )
06606            && (no_write != TRUE )
06607           )
06608       )
06609       return -RSBAC_EINVALIDVALUE;
06610     if(!list_initialized)
06611       return -RSBAC_ENOTINITIALIZED;
06612 
06613     rsbac_read_lock(&reg_head.lock, &lock_flags);
06614     reg_item_p = lookup_reg((struct rsbac_list_reg_item_t *) handle);
06615     if(!reg_item_p)
06616       {
06617         rsbac_read_unlock(&reg_head.lock, &lock_flags);
06618         rsbac_printk(KERN_WARNING "rsbac_list_no_write: setting no_write for list denied due to invalid handle!\n");
06619         return -RSBAC_EINVALIDVALUE;
06620       }
06621     if(reg_item_p->info.key != key)
06622       {
06623         rsbac_read_unlock(&reg_head.lock, &lock_flags);
06624         rsbac_printk(KERN_WARNING "rsbac_list_no_write: setting no_write for list %s denied due to invalid key %u!\n",
06625                reg_item_p->name,
06626                key);
06627         return -EPERM;
06628       }
06629     reg_item_p->no_write = no_write;
06630     rsbac_read_unlock(&reg_head.lock, &lock_flags);
06631     return 0;
06632   }

int rsbac_list_register rsbac_version_t  ds_version,
rsbac_list_handle_t handle_p,
struct rsbac_list_info_t info_p,
u_int  flags,
rsbac_list_compare_function_t compare,
rsbac_list_get_conv_t get_conv,
void *  def_data,
char *  name,
kdev_t  device
 

Definition at line 5888 of file gen_lists.c.

References add_reg(), clear_reg(), create_reg(), rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, get_error_name(), rsbac_list_info_t::key, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_reg_head_t::lock, lookup_lol_reg_name(), lookup_reg_name(), rsbac_list_info_t::max_age, rsbac_list_reg_item_t::name, NULL, proc_rsbac_backup_p, read_list(), RSBAC_ECOULDNOTADDITEM, RSBAC_EEXISTS, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDVALUE, RSBAC_EINVALIDVERSION, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_kfree(), rsbac_kmalloc(), RSBAC_LIST_BACKUP, RSBAC_LIST_MAX_AGE_LIMIT, RSBAC_LIST_MAX_ITEM_SIZE, RSBAC_LIST_PERSIST, RSBAC_LIST_VERSION, RSBAC_MAXNAMELEN, rsbac_printk(), rsbac_root_dev, and rsbac_list_info_t::version.

Referenced by init_module(), register_dev_lists(), register_fd_lists(), register_ipc_lists(), register_process_lists(), register_user_lists(), rsbac_init_acl(), rsbac_init_debug(), rsbac_init_pm(), rsbac_init_rc(), rsbac_init_um(), and rsbac_list_init().

05898   {
05899     struct rsbac_list_reg_item_t     * reg_item_p;
05900     struct rsbac_list_reg_item_t     * new_reg_item_p;
05901     u_long lock_flags;
05902     int    err = 0;
05903 
05904     if(ds_version != RSBAC_LIST_VERSION)
05905       {
05906         if(name)
05907           {
05908             rsbac_printk(KERN_WARNING
05909                    "rsbac_list_register: wrong ds_version %u for list %s, expected %u!\n",
05910                    ds_version,
05911                    name,
05912                    RSBAC_LIST_VERSION);
05913           }
05914         return -RSBAC_EINVALIDVERSION;
05915       }
05916     if(!handle_p || !info_p)
05917       return -RSBAC_EINVALIDPOINTER;
05918     *handle_p = NULL;
05919     if(!info_p->key || !info_p->version || !info_p->desc_size)
05920       return -RSBAC_EINVALIDVALUE;
05921     if(info_p->max_age > RSBAC_LIST_MAX_AGE_LIMIT)
05922       return -RSBAC_EINVALIDVALUE;
05923     if(info_p->desc_size + info_p->data_size > RSBAC_LIST_MAX_ITEM_SIZE)
05924       return -RSBAC_EINVALIDVALUE;
05925     if(!list_initialized)
05926       return -RSBAC_ENOTINITIALIZED;
05927     if(name)
05928       {
05929         struct rsbac_list_lol_reg_item_t * lol_reg_item_p;
05930 
05931         rsbac_read_lock(&reg_head.lock, &lock_flags);
05932         reg_item_p = lookup_reg_name(name, device);
05933         rsbac_read_unlock(&reg_head.lock, &lock_flags);
05934         if(reg_item_p)
05935           {
05936 #ifdef CONFIG_RSBAC_DEBUG
05937             if(rsbac_debug_lists)
05938               {
05939                 rsbac_printk(KERN_DEBUG "rsbac_list_register: list name %s already exists on device %02u:%02u!\n",
05940                        name, RSBAC_MAJOR(device), RSBAC_MINOR(device));
05941               }
05942 #endif
05943             return -RSBAC_EEXISTS;
05944           }
05945         rsbac_read_lock(&lol_reg_head.lock, &lock_flags);
05946         lol_reg_item_p = lookup_lol_reg_name(name, device);
05947         rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
05948         if(lol_reg_item_p)
05949           {
05950 #ifdef CONFIG_RSBAC_DEBUG
05951             if(rsbac_debug_lists)
05952               {
05953                 rsbac_printk(KERN_DEBUG "rsbac_list_register: list name %s already exists on device %02u:%02u!\n",
05954                        name, RSBAC_MAJOR(device), RSBAC_MINOR(device));
05955               }
05956 #endif
05957             return -RSBAC_EEXISTS;
05958           }
05959       }
05960     else
05961       if(flags & RSBAC_LIST_PERSIST)
05962         {
05963           rsbac_printk(KERN_WARNING
05964                  "rsbac_list_register: trial to register persistent list without name.\n");
05965           return -RSBAC_EINVALIDVALUE;
05966         }
05967 
05968     if(flags & RSBAC_LIST_PERSIST)
05969       {
05970         if(RSBAC_IS_AUTO_DEV(device))
05971           device = rsbac_root_dev;
05972         if(!RSBAC_MAJOR(device))
05973           flags &= ~RSBAC_LIST_PERSIST;
05974       }
05975 
05976 #ifdef CONFIG_RSBAC_DEBUG
05977     if(rsbac_debug_lists)
05978       {
05979         rsbac_printk(KERN_DEBUG "rsbac_list_register: registering list %s for device %02u:%02u.\n",
05980                name, RSBAC_MAJOR(device),RSBAC_MINOR(device));
05981       }
05982 #endif
05983     new_reg_item_p = create_reg(info_p, flags, compare, get_conv, def_data, name, device);
05984     if(!new_reg_item_p)
05985       {
05986         return -RSBAC_ECOULDNOTADDITEM;
05987       }
05988     /* Restore from disk, but only for real device mounts */
05989     if(   (flags & RSBAC_LIST_PERSIST)
05990        && RSBAC_MAJOR(device)
05991       )
05992       {
05993 #ifdef CONFIG_RSBAC_DEBUG
05994         if(rsbac_debug_lists)
05995           {
05996             rsbac_printk(KERN_DEBUG "rsbac_list_register: restoring list %s from device %02u:%02u.\n",
05997                    name, RSBAC_MAJOR(device), RSBAC_MINOR(device));
05998           }
05999 #endif
06000         err = read_list(new_reg_item_p);
06001         /* not found is no error */
06002         if(err == -RSBAC_ENOTFOUND)
06003           err = 0;
06004         else
06005         if(err)
06006           {
06007 #ifdef CONFIG_RSBAC_DEBUG
06008             if(rsbac_debug_lists)
06009               {
06010                 char * tmp = rsbac_kmalloc(RSBAC_MAXNAMELEN);
06011 
06012                 if(tmp)
06013                   {
06014                     get_error_name(tmp, err);
06015                     rsbac_printk(KERN_DEBUG "rsbac_list_register: restoring list %s from device %02u:%02u failed with error %s, unregistering list.\n",
06016                            name,
06017                            RSBAC_MAJOR(device),RSBAC_MINOR(device),
06018                            tmp);
06019                     rsbac_kfree(tmp);
06020                   }
06021               }
06022 #endif
06023             clear_reg(new_reg_item_p);
06024             return err;
06025           }
06026 #ifdef CONFIG_RSBAC_DEBUG
06027         else
06028           {
06029             if(rsbac_debug_lists)
06030               {
06031                 rsbac_printk(KERN_DEBUG "rsbac_list_register: restoring list %s from device %02u:%02u was successful.\n",
06032                        name,
06033                        RSBAC_MAJOR(device),RSBAC_MINOR(device));
06034               }
06035           }
06036 #endif
06037       }
06038 
06039     rsbac_write_lock(&reg_head.lock, &lock_flags);
06040     reg_item_p = add_reg(new_reg_item_p);
06041     rsbac_write_unlock(&reg_head.lock, &lock_flags);
06042     if(!reg_item_p)
06043       {
06044         rsbac_printk(KERN_WARNING
06045                "rsbac_list_register: inserting list %s failed!\n",
06046                name);
06047         /* cleanup */
06048         clear_reg(new_reg_item_p);
06049         return -RSBAC_ECOULDNOTADDITEM;
06050       }
06051 
06052     /* finish */
06053 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
06054     /* create proc entry, if requested */
06055     if(flags & RSBAC_LIST_BACKUP)
06056       {
06057         reg_item_p->proc_entry_p = create_proc_entry(reg_item_p->name,
06058                                                      S_IFREG | S_IRUGO,
06059                                                      proc_rsbac_backup_p);
06060         if(reg_item_p->proc_entry_p)
06061           {
06062             reg_item_p->proc_entry_p->read_proc = backup_proc_read;
06063             reg_item_p->proc_entry_p->data = reg_item_p;
06064           }
06065       }
06066     else
06067       {
06068         reg_item_p->proc_entry_p = NULL;
06069       }
06070 #endif
06071     *handle_p = reg_item_p;
06072     return err;
06073   }

int rsbac_list_remove rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 7576 of file gen_lists.c.

References rsbac_ta_list_remove().

07579   {
07580     return rsbac_ta_list_remove(0, handle, desc);
07581   }

int rsbac_list_remove_all rsbac_list_handle_t  handle  ) 
 

Definition at line 7672 of file gen_lists.c.

References rsbac_ta_list_remove_all().

07673   {
07674     return rsbac_ta_list_remove_all(0, handle);
07675   }

rsbac_version_t rsbac_list_version void   ) 
 

Definition at line 5856 of file gen_lists.c.

References RSBAC_LIST_VERSION.

05857   {
05858     return RSBAC_LIST_VERSION;
05859   }

int rsbac_ta_list_add_ttl rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
rsbac_time_t  ttl,
void *  desc,
void *  data
 

Definition at line 6954 of file gen_lists.c.

References add_item(), rsbac_list_info_t::data_size, rsbac_list_reg_item_t::def_data, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::dirty, do_remove_item(), rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, lookup_item(), rsbac_list_item_t::max_age, RSBAC_EBUSY, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_MAX_AGE_LIMIT, RSBAC_LIST_TTL_KEEP, rsbac_ta_list_exist(), rsbac_list_reg_item_t::self, touch, and TRUE.

Referenced by rsbac_acl_add_group(), rsbac_acl_add_to_acl_entry(), rsbac_acl_change_group(), rsbac_acl_remove_from_acl_entry(), rsbac_acl_set_acl_entry(), rsbac_list_add(), rsbac_list_add_ttl(), rsbac_pm_add_target(), rsbac_pm_set_data(), rsbac_rc_copy_role(), rsbac_rc_copy_type(), rsbac_rc_set_item(), rsbac_um_add_group(), rsbac_um_mod_group(), rsbac_um_set_group_pass(), set_attr_dev(), set_attr_fd(), set_attr_ipc(), set_attr_process(), and set_attr_user().

06960   {
06961     struct rsbac_list_reg_item_t * list;
06962     struct rsbac_list_item_t     * item_p;
06963     u_long lock_flags, rlock_flags;
06964 
06965     if(!handle || !desc)
06966       return -RSBAC_EINVALIDVALUE;
06967     if(!list_initialized)
06968       return -RSBAC_ENOTINITIALIZED;
06969 
06970     list = (struct rsbac_list_reg_item_t *) handle;
06971     if(!list || (list->self != list))
06972       return -RSBAC_EINVALIDVALUE;
06973 
06974 #ifdef CONFIG_RSBAC_LIST_TRANS
06975     if(ta_number && !rsbac_ta_list_exist(0, ta_handle, &ta_number))
06976       return -RSBAC_EINVALIDTRANSACTION;
06977 #endif
06978 
06979     rsbac_read_lock(&reg_head.lock, &rlock_flags);
06980     if(list->info.data_size && !data)
06981       {
06982         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
06983         return -RSBAC_EINVALIDVALUE;
06984       }
06985 
06986 /*
06987 #ifdef CONFIG_RSBAC_DEBUG
06988     if(rsbac_debug_lists)
06989       rsbac_printk(KERN_DEBUG "rsbac_ta_list_add_ttl: adding to list %s.\n",
06990              list->name);
06991 #endif
06992 */
06993     if(ttl && (ttl != RSBAC_LIST_TTL_KEEP))
06994       {
06995         if(ttl > RSBAC_LIST_MAX_AGE_LIMIT)
06996           ttl = RSBAC_LIST_MAX_AGE_LIMIT;
06997         ttl += RSBAC_CURRENT_TIME;
06998       }
06999     rsbac_write_lock(&list->lock, &lock_flags);
07000 
07001 #ifdef CONFIG_RSBAC_LIST_TRANS
07002     if(!ta_number)
07003 #endif
07004       {
07005         item_p = lookup_item(list, desc);
07006         if(item_p)
07007           { /* exists -> update data, if any */
07008             if(ttl != RSBAC_LIST_TTL_KEEP)
07009               item_p->max_age = ttl;
07010             if(data && list->info.data_size)
07011               {
07012                 if(   list->def_data
07013                    && !item_p->max_age
07014                    && !memcmp(list->def_data, data, list->info.data_size)
07015                   )
07016                   do_remove_item(list, item_p);
07017                 else
07018                   memcpy(((char *) item_p) + sizeof(*item_p) + list->info.desc_size,
07019                          data, list->info.data_size);
07020               }
07021           }
07022         else
07023           {
07024             if(ttl == RSBAC_LIST_TTL_KEEP)
07025               ttl = 0;
07026             if(   !list->def_data
07027                || memcmp(list->def_data, data, list->info.data_size)
07028               )
07029               add_item(list, ttl, desc, data);
07030           }
07031         touch(list);
07032         list->dirty = TRUE;
07033       }
07034 #ifdef CONFIG_RSBAC_LIST_TRANS
07035     if(   list->ta_copied
07036        || ta_number
07037       )
07038       {
07039         if(!list->ta_copied)
07040           ta_copy(ta_number, list);
07041         else
07042           if(ta_number)
07043             {
07044               if(list->ta_copied != ta_number)
07045                 {
07046                   rsbac_write_unlock(&list->lock, &lock_flags);
07047                   rsbac_read_unlock(&reg_head.lock, &rlock_flags);
07048                   return -RSBAC_EBUSY;
07049                 }
07050             }
07051           else
07052             ta_number = list->ta_copied;
07053         item_p = ta_lookup_item(ta_number, list, desc);
07054         if(item_p)
07055           { /* exists -> update data, if any */
07056             if(ttl != RSBAC_LIST_TTL_KEEP)
07057               item_p->max_age = ttl;
07058             if(data && list->info.data_size)
07059               {
07060                 if(   list->def_data
07061                    && !item_p->max_age
07062                    && !memcmp(list->def_data, data, list->info.data_size)
07063                   )
07064                   ta_do_remove_item(list, item_p);
07065                 else
07066                   memcpy(((char *) item_p) + sizeof(*item_p) + list->info.desc_size,
07067                          data, list->info.data_size);
07068               }
07069           }
07070         else
07071           {
07072             if(ttl == RSBAC_LIST_TTL_KEEP)
07073               ttl = 0;
07074             if(   !list->def_data
07075                || memcmp(list->def_data, data, list->info.data_size)
07076               )
07077               ta_add_item(ta_number, list, ttl, desc, data);
07078           }
07079       }
07080 #endif
07081     rsbac_write_unlock(&list->lock, &lock_flags);
07082     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
07083     return 0;
07084   }

long rsbac_ta_list_count rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle
 

Definition at line 9501 of file gen_lists.c.

References rsbac_list_reg_item_t::count, list_initialized, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.

Referenced by rsbac_list_count(), rsbac_rc_get_list(), rsbac_ta_list_all_dev(), rsbac_ta_list_all_group(), rsbac_ta_list_all_user(), and rsbac_um_get_group_list().

09504   {
09505     struct rsbac_list_reg_item_t * list;
09506 
09507     if(!handle)
09508       return -RSBAC_EINVALIDVALUE;
09509     if(!list_initialized)
09510       return -RSBAC_ENOTINITIALIZED;
09511 
09512     list = (struct rsbac_list_reg_item_t *) handle;
09513     if(list->self != list)
09514       return -RSBAC_EINVALIDVALUE;
09515 
09516 #ifdef CONFIG_RSBAC_LIST_TRANS
09517     if(ta_number)
09518       {
09519         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09520           return -RSBAC_EINVALIDTRANSACTION;
09521       }
09522 #endif
09523 
09524 #ifdef CONFIG_RSBAC_LIST_TRANS
09525     if(ta_number && (list->ta_copied == ta_number))
09526       return list->ta_count;
09527     else
09528 #endif
09529     return list->count;
09530   }

int rsbac_ta_list_exist rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 8997 of file gen_lists.c.

References FALSE, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, lookup_item(), rsbac_list_item_t::max_age, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, rsbac_ta_list_exist(), rsbac_list_reg_item_t::self, and TRUE.

Referenced by rsbac_acl_add_group(), rsbac_acl_add_group_member(), rsbac_acl_change_group(), rsbac_acl_get_group_members(), rsbac_acl_group_exist(), rsbac_acl_remove_group_member(), rsbac_list_exist(), rsbac_pm_exists(), rsbac_rc_role_exists(), rsbac_rc_set_item(), rsbac_rc_type_exists(), rsbac_ta_list_add_ttl(), rsbac_ta_list_all_dev(), rsbac_ta_list_count(), rsbac_ta_list_exist(), rsbac_ta_list_get_all_data(), rsbac_ta_list_get_all_desc(), rsbac_ta_list_get_all_items_ttl(), rsbac_ta_list_get_data_ttl(), rsbac_ta_list_get_desc(), rsbac_ta_list_get_max_desc(), rsbac_ta_list_get_next_desc(), rsbac_ta_list_lol_add_ttl(), rsbac_ta_list_lol_all_subcount(), rsbac_ta_list_lol_count(), rsbac_ta_list_lol_exist(), rsbac_ta_list_lol_get_all_data(), rsbac_ta_list_lol_get_all_desc(), rsbac_ta_list_lol_get_all_items(), rsbac_ta_list_lol_get_all_subdata(), rsbac_ta_list_lol_get_all_subdesc_ttl(), rsbac_ta_list_lol_get_all_subitems_ttl(), rsbac_ta_list_lol_get_data_ttl(), rsbac_ta_list_lol_get_desc(), rsbac_ta_list_lol_get_next_desc(), rsbac_ta_list_lol_get_subdata_ttl(), rsbac_ta_list_lol_remove(), rsbac_ta_list_lol_remove_all(), rsbac_ta_list_lol_subadd_ttl(), rsbac_ta_list_lol_subcount(), rsbac_ta_list_lol_subexist(), rsbac_ta_list_lol_subexist_compare(), rsbac_ta_list_lol_subremove(), rsbac_ta_list_lol_subremove_all(), rsbac_ta_list_lol_subremove_from_all(), rsbac_ta_list_remove(), rsbac_ta_list_remove_all(), rsbac_um_add_gm(), rsbac_um_add_group(), rsbac_um_add_user(), rsbac_um_get_gm_user_list(), rsbac_um_get_group_item(), rsbac_um_group_exists(), rsbac_um_mod_group(), rsbac_um_mod_user(), and rsbac_um_remove_group().

09001   {
09002     struct rsbac_list_reg_item_t * list;
09003     u_long lock_flags, rlock_flags;
09004     struct rsbac_list_item_t     * item_p;
09005     int result;
09006 
09007     if(!handle || !desc)
09008       return FALSE;
09009     if(!list_initialized)
09010       return FALSE;
09011 
09012     list = (struct rsbac_list_reg_item_t *) handle;
09013     if(list->self != list)
09014       return -RSBAC_EINVALIDVALUE;
09015 
09016 #ifdef CONFIG_RSBAC_LIST_TRANS
09017     if(ta_number)
09018       {
09019         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09020           return -RSBAC_EINVALIDTRANSACTION;
09021       }
09022 #endif
09023 
09024     rsbac_read_lock(&reg_head.lock, &rlock_flags);
09025 /*
09026 #ifdef CONFIG_RSBAC_DEBUG
09027     if(rsbac_debug_lists)
09028       rsbac_printk(KERN_DEBUG "rsbac_list_exist: testing on list %s.\n",
09029              list->name);
09030 #endif
09031 */
09032     rsbac_read_lock(&list->lock, &lock_flags);
09033 
09034 #ifdef CONFIG_RSBAC_LIST_TRANS
09035     if(ta_number && (list->ta_copied == ta_number))
09036       item_p = ta_lookup_item(ta_number, list, desc);
09037     else
09038 #endif
09039     item_p = lookup_item(list, desc);
09040     if(   item_p
09041        && (   !item_p->max_age
09042            || (item_p->max_age > RSBAC_CURRENT_TIME)
09043           )
09044       )
09045       { /* exists -> TRUE */
09046         result = TRUE;
09047       }
09048     else
09049       {
09050         result = FALSE;
09051       }
09052     rsbac_read_unlock(&list->lock, &lock_flags);
09053     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
09054     return result;
09055   }

long rsbac_ta_list_get_all_data rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void **  array_p
 

Definition at line 9920 of file gen_lists.c.

References rsbac_list_reg_item_t::count, rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, rsbac_list_item_t::max_age, rsbac_list_item_t::next, NULL, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_reg_item_t::self.

Referenced by rsbac_acl_list_groups(), rsbac_acl_remove_user(), and rsbac_list_get_all_data().

09924   {
09925     struct rsbac_list_reg_item_t * list;
09926     struct rsbac_list_item_t     * item_p;
09927            char                  * buffer;
09928     u_long lock_flags, rlock_flags;
09929     u_long offset = 0;
09930     long result = 0;
09931     u_int item_size;
09932     u_int item_offset;
09933 
09934     if(!handle)
09935       return -RSBAC_EINVALIDVALUE;
09936     if(!array_p)
09937       return -RSBAC_EINVALIDVALUE;
09938     if(!list_initialized)
09939       return -RSBAC_ENOTINITIALIZED;
09940 
09941     list = (struct rsbac_list_reg_item_t *) handle;
09942     if(list->self != list)
09943       return -RSBAC_EINVALIDVALUE;
09944     *array_p = NULL;
09945 
09946 #ifdef CONFIG_RSBAC_LIST_TRANS
09947     if(ta_number)
09948       {
09949         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09950           return -RSBAC_EINVALIDTRANSACTION;
09951       }
09952 #endif
09953 
09954     rsbac_read_lock(&reg_head.lock, &rlock_flags);
09955 /*
09956 #ifdef CONFIG_RSBAC_DEBUG
09957     if(rsbac_debug_lists)
09958       rsbac_printk(KERN_DEBUG "rsbac_list_get_all_data: list %s.\n",
09959              list->name);
09960 #endif
09961 */
09962     rsbac_read_lock(&list->lock, &lock_flags);
09963     if(!list->info.data_size)
09964       {
09965         rsbac_read_unlock(&list->lock, &lock_flags);
09966         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
09967         return -RSBAC_EINVALIDREQUEST;
09968       }
09969 #ifdef CONFIG_RSBAC_LIST_TRANS
09970     if(ta_number && (list->ta_copied == ta_number))
09971       {
09972         if(list->ta_count)
09973           {
09974             item_size = list->info.data_size;
09975             item_offset = list->info.desc_size;
09976             buffer = rsbac_vmalloc(item_size * list->ta_count);
09977             if(buffer)
09978               {
09979                 item_p = list->ta_head;
09980                 while(item_p)
09981                   {
09982                     if(   !item_p->max_age
09983                        || (item_p->max_age > RSBAC_CURRENT_TIME)
09984                       )
09985                       {
09986                         memcpy(buffer + offset,
09987                                ((char *) item_p) + sizeof(*item_p) + item_offset,
09988                                item_size);
09989                         offset += item_size;
09990                         result++;
09991                       }
09992                     item_p = item_p->next;
09993                   }
09994                 *array_p = buffer;
09995               }
09996             else
09997               {
09998                 result = -RSBAC_ENOMEM;
09999               }
10000           }
10001       }
10002     else
10003 #endif
10004     if(list->count)
10005       {
10006         item_size = list->info.data_size;
10007         item_offset = list->info.desc_size;
10008         buffer = rsbac_vmalloc(item_size * list->count);
10009         if(buffer)
10010           {
10011             item_p = list->head;
10012             while(item_p)
10013               {
10014                 if(   !item_p->max_age
10015                    || (item_p->max_age > RSBAC_CURRENT_TIME)
10016                   )
10017                   {
10018                     memcpy(buffer + offset,
10019                            ((char *) item_p) + sizeof(*item_p) + item_offset,
10020                            item_size);
10021                     offset += item_size;
10022                     result++;
10023                   }
10024                 item_p = item_p->next;
10025               }
10026             *array_p = buffer;
10027           }
10028         else
10029           {
10030             result = -RSBAC_ENOMEM;
10031           }
10032       }
10033     rsbac_read_unlock(&list->lock, &lock_flags);
10034     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
10035     return result;
10036   }

long rsbac_ta_list_get_all_desc rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void **  array_p
 

Definition at line 9549 of file gen_lists.c.

References rsbac_list_reg_item_t::count, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, rsbac_list_item_t::max_age, rsbac_list_item_t::next, NULL, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_reg_item_t::self.

Referenced by copy_new_uids(), rsbac_list_get_all_desc(), rsbac_rc_copy_type(), rsbac_rc_get_list(), rsbac_ta_list_all_dev(), rsbac_ta_list_all_group(), rsbac_ta_list_all_user(), and rsbac_um_get_group_list().

09553   {
09554     struct rsbac_list_reg_item_t * list;
09555     struct rsbac_list_item_t     * item_p;
09556            char                  * buffer;
09557     u_long lock_flags, rlock_flags;
09558     u_long offset = 0;
09559     long result = 0;
09560     u_int item_size;
09561 
09562     if(!handle)
09563       return -RSBAC_EINVALIDVALUE;
09564     if(!array_p)
09565       return -RSBAC_EINVALIDVALUE;
09566     if(!list_initialized)
09567       return -RSBAC_ENOTINITIALIZED;
09568 
09569     list = (struct rsbac_list_reg_item_t *) handle;
09570     if(list->self != list)
09571       return -RSBAC_EINVALIDVALUE;
09572     *array_p = NULL;
09573 
09574 #ifdef CONFIG_RSBAC_LIST_TRANS
09575     if(ta_number)
09576       {
09577         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09578           return -RSBAC_EINVALIDTRANSACTION;
09579       }
09580 #endif
09581 
09582     rsbac_read_lock(&reg_head.lock, &rlock_flags);
09583 /*
09584 #ifdef CONFIG_RSBAC_DEBUG
09585     if(rsbac_debug_lists)
09586       rsbac_printk(KERN_DEBUG "rsbac_list_get_all_desc: list %s.\n",
09587              list->name);
09588 #endif
09589 */
09590     rsbac_read_lock(&list->lock, &lock_flags);
09591 #ifdef CONFIG_RSBAC_LIST_TRANS
09592     if(ta_number && (list->ta_copied == ta_number))
09593       {
09594         if(list->ta_count)
09595           {
09596             item_size = list->info.desc_size;
09597             buffer = rsbac_vmalloc(item_size * list->ta_count);
09598             if(buffer)
09599               {
09600                 item_p = list->ta_head;
09601                 while(item_p)
09602                   {
09603                     if(   !item_p->max_age
09604                        || (item_p->max_age > RSBAC_CURRENT_TIME)
09605                       )
09606                       {
09607                         memcpy(buffer + offset,
09608                                ((char *) item_p) + sizeof(*item_p),
09609                                item_size);
09610                         offset += item_size;
09611                         result++;
09612                       }
09613                     item_p = item_p->next;
09614                   }
09615                 *array_p = buffer;
09616               }
09617             else
09618               {
09619                 result = -RSBAC_ENOMEM;
09620               }
09621           }
09622       }
09623     else
09624 #endif
09625     if(list->count)
09626       {
09627         item_size = list->info.desc_size;
09628         buffer = rsbac_vmalloc(item_size * list->count);
09629         if(buffer)
09630           {
09631             item_p = list->head;
09632             while(item_p)
09633               {
09634                 if(   !item_p->max_age
09635                    || (item_p->max_age > RSBAC_CURRENT_TIME)
09636                   )
09637                   {
09638                     memcpy(buffer + offset,
09639                            ((char *) item_p) + sizeof(*item_p),
09640                            item_size);
09641                     offset += item_size;
09642                     result++;
09643                   }
09644                 item_p = item_p->next;
09645               }
09646             *array_p = buffer;
09647           }
09648         else
09649           {
09650             result = -RSBAC_ENOMEM;
09651           }
09652       }
09653     rsbac_read_unlock(&list->lock, &lock_flags);
09654     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
09655     return result;
09656   }

long rsbac_ta_list_get_all_items_ttl rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void **  array_p,
rsbac_time_t **  ttl_array_p
 

Definition at line 10349 of file gen_lists.c.

References rsbac_list_reg_item_t::count, rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, rsbac_list_item_t::max_age, rsbac_list_item_t::next, NULL, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_reg_item_t::self.

Referenced by rsbac_acl_get_tlist(), rsbac_list_get_all_items(), and rsbac_list_get_all_items_ttl().

10354   {
10355     struct rsbac_list_reg_item_t * list;
10356     struct rsbac_list_item_t     * item_p;
10357            char                  * buffer;
10358            rsbac_time_t              * ttl_p = NULL;
10359     u_long lock_flags, rlock_flags;
10360     u_long offset = 0;
10361     long result = 0;
10362     u_int item_size;
10363 
10364     if(!handle)
10365       return -RSBAC_EINVALIDVALUE;
10366     if(!array_p)
10367       return -RSBAC_EINVALIDPOINTER;
10368     if(!list_initialized)
10369       return -RSBAC_ENOTINITIALIZED;
10370 
10371     list = (struct rsbac_list_reg_item_t *) handle;
10372     if(list->self != list)
10373       return -RSBAC_EINVALIDVALUE;
10374     *array_p = NULL;
10375 
10376 #ifdef CONFIG_RSBAC_LIST_TRANS
10377     if(ta_number)
10378       {
10379         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
10380           return -RSBAC_EINVALIDTRANSACTION;
10381       }
10382 #endif
10383 
10384     rsbac_read_lock(&reg_head.lock, &rlock_flags);
10385 /*
10386 #ifdef CONFIG_RSBAC_DEBUG
10387     if(rsbac_debug_lists)
10388       rsbac_printk(KERN_DEBUG "rsbac_list_get_all_items: list %s.\n",
10389              list->name);
10390 #endif
10391 */
10392     rsbac_read_lock(&list->lock, &lock_flags);
10393 #ifdef CONFIG_RSBAC_LIST_TRANS
10394     if(ta_number && (list->ta_copied == ta_number))
10395       {
10396         if(list->ta_count)
10397           {
10398             item_size = list->info.desc_size + list->info.data_size;
10399             buffer = rsbac_vmalloc(item_size * list->ta_count);
10400             if(buffer)
10401               {
10402                 if(ttl_array_p)
10403                   ttl_p = rsbac_vmalloc(sizeof(**ttl_array_p) * list->ta_count);
10404                 item_p = list->ta_head;
10405                 while(item_p)
10406                   {
10407                     if(   !item_p->max_age
10408                        || (item_p->max_age > RSBAC_CURRENT_TIME)
10409                       )
10410                       {
10411                         memcpy(buffer + offset,
10412                                ((char *) item_p) + sizeof(*item_p),
10413                                item_size);
10414                         if(ttl_p)
10415                           {
10416                             if(item_p->max_age)
10417                               ttl_p[result] = item_p->max_age - RSBAC_CURRENT_TIME;
10418                             else
10419                               ttl_p[result] = 0;
10420                           }
10421                         offset += item_size;
10422                         result++;
10423                       }
10424                     item_p = item_p->next;
10425                   }
10426                 *array_p = buffer;
10427                 if(ttl_array_p)
10428                   *ttl_array_p = ttl_p;
10429               }
10430             else
10431               {
10432                 result = -RSBAC_ENOMEM;
10433               }
10434           }
10435       }
10436     else
10437 #endif
10438     if(list->count)
10439       {
10440         item_size = list->info.desc_size + list->info.data_size;
10441         buffer = rsbac_vmalloc(item_size * list->count);
10442         if(buffer)
10443           {
10444             if(ttl_array_p)
10445               ttl_p = rsbac_vmalloc(sizeof(**ttl_array_p) * list->count);
10446             item_p = list->head;
10447             while(item_p)
10448               {
10449                 if(   !item_p->max_age
10450                    || (item_p->max_age > RSBAC_CURRENT_TIME)
10451                   )
10452                   {
10453                     memcpy(buffer + offset,
10454                            ((char *) item_p) + sizeof(*item_p),
10455                            item_size);
10456                     if(ttl_p)
10457                       {
10458                         if(item_p->max_age)
10459                           ttl_p[result] = item_p->max_age - RSBAC_CURRENT_TIME;
10460                         else
10461                           ttl_p[result] = 0;
10462                       }
10463                     offset += item_size;
10464                     result++;
10465                   }
10466                 item_p = item_p->next;
10467               }
10468             *array_p = buffer;
10469             if(ttl_array_p)
10470               *ttl_array_p = ttl_p;
10471           }
10472         else
10473           {
10474             result = -RSBAC_ENOMEM;
10475           }
10476       }
10477     rsbac_read_unlock(&list->lock, &lock_flags);
10478     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
10479     return result;
10480   }

int rsbac_ta_list_get_data_ttl rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
rsbac_time_t ttl_p,
void *  desc,
void *  data
 

Definition at line 8219 of file gen_lists.c.

References rsbac_list_info_t::data_size, rsbac_list_reg_item_t::def_data, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, lookup_item(), rsbac_list_item_t::max_age, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.

Referenced by get_attr_dev(), get_attr_fd(), get_attr_ipc(), get_attr_process(), get_attr_user(), rsbac_acl_add_to_acl_entry(), rsbac_acl_get_group_entry(), rsbac_acl_get_rights(), rsbac_acl_get_single_right(), rsbac_acl_remove_from_acl_entry(), rsbac_list_get_data(), rsbac_list_get_data_ttl(), rsbac_pm_exists(), rsbac_pm_get_all_data(), rsbac_pm_get_data(), rsbac_pm_set_data(), rsbac_rc_copy_role(), rsbac_rc_copy_type(), rsbac_rc_get_item(), rsbac_rc_set_item(), rsbac_um_get_group_item(), rsbac_um_mod_group(), rsbac_um_set_group_pass(), set_attr_dev(), set_attr_fd(), set_attr_ipc(), set_attr_process(), and set_attr_user().

08225   {
08226     struct rsbac_list_reg_item_t * list;
08227     struct rsbac_list_item_t     * item_p;
08228     u_long lock_flags, rlock_flags;
08229     int err = 0;
08230 
08231     if(!handle || !desc)
08232       return -RSBAC_EINVALIDVALUE;
08233     if(!list_initialized)
08234       return -RSBAC_ENOTINITIALIZED;
08235 
08236     list = (struct rsbac_list_reg_item_t *) handle;
08237     if(list->self != list)
08238       return -RSBAC_EINVALIDVALUE;
08239 
08240 #ifdef CONFIG_RSBAC_LIST_TRANS
08241     if(ta_number)
08242       {
08243         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08244           return -RSBAC_EINVALIDTRANSACTION;
08245       }
08246 #endif
08247 
08248     rsbac_read_lock(&reg_head.lock, &rlock_flags);
08249 /*
08250 #ifdef CONFIG_RSBAC_DEBUG
08251     if(rsbac_debug_lists)
08252       rsbac_printk(KERN_DEBUG "rsbac_list_get_data: getting data from list %s.\n",
08253              list->name);
08254 #endif
08255 */
08256     if(data && !list->info.data_size)
08257       {
08258         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08259         return -RSBAC_EINVALIDREQUEST;
08260       }
08261 
08262     rsbac_read_lock(&list->lock, &lock_flags);
08263 #ifdef CONFIG_RSBAC_LIST_TRANS
08264     if(ta_number && (list->ta_copied == ta_number))
08265       item_p = ta_lookup_item(ta_number, list, desc);
08266     else
08267 #endif
08268       item_p = lookup_item(list, desc);
08269     if(   item_p
08270        && (   !item_p->max_age
08271            || (item_p->max_age > RSBAC_CURRENT_TIME)
08272           )
08273       )
08274       { /* exists -> copy data, if any */
08275         if(ttl_p)
08276           {
08277             if(item_p->max_age)
08278               *ttl_p = item_p->max_age - RSBAC_CURRENT_TIME;
08279             else
08280               *ttl_p = 0;
08281           }
08282         if(data)
08283           {
08284             memcpy(data,
08285                    ((char *) item_p) + sizeof(*item_p) + list->info.desc_size,
08286                    list->info.data_size);
08287           }
08288       }
08289     else
08290       {
08291         if(!list->def_data)
08292           err = -RSBAC_ENOTFOUND;
08293         else
08294           {
08295             if(ttl_p)
08296               *ttl_p = 0;
08297             if(data)
08298               memcpy(data,
08299                      list->def_data,
08300                      list->info.data_size);
08301           }
08302       }
08303     rsbac_read_unlock(&list->lock, &lock_flags);
08304     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08305     return err;
08306   }

int rsbac_ta_list_get_desc rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc,
void *  data,
rsbac_list_data_compare_function_t  compare
 

Definition at line 8834 of file gen_lists.c.

References rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, lookup_item_data(), RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.

Referenced by rsbac_list_get_desc(), and rsbac_um_get_gid().

08840   {
08841     struct rsbac_list_reg_item_t * list;
08842     struct rsbac_list_item_t     * item_p;
08843     u_long lock_flags, rlock_flags;
08844     int err = 0;
08845 
08846     if(!handle || !desc || !data)
08847       return -RSBAC_EINVALIDVALUE;
08848     if(!list_initialized)
08849       return -RSBAC_ENOTINITIALIZED;
08850 
08851     list = (struct rsbac_list_reg_item_t *) handle;
08852     if(list->self != list)
08853       return -RSBAC_EINVALIDVALUE;
08854 
08855 #ifdef CONFIG_RSBAC_LIST_TRANS
08856     if(ta_number)
08857       {
08858         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08859           return -RSBAC_EINVALIDTRANSACTION;
08860       }
08861 #endif
08862 
08863     rsbac_read_lock(&reg_head.lock, &rlock_flags);
08864 /*
08865 #ifdef CONFIG_RSBAC_DEBUG
08866     if(rsbac_debug_lists)
08867       rsbac_printk(KERN_DEBUG "rsbac_list_get_desc: getting desc from list %s.\n",
08868              list->name);
08869 #endif
08870 */
08871     if(!list->info.data_size)
08872       {
08873         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08874         return -RSBAC_EINVALIDREQUEST;
08875       }
08876 
08877     rsbac_read_lock(&list->lock, &lock_flags);
08878 
08879 #ifdef CONFIG_RSBAC_LIST_TRANS
08880     if(ta_number && (list->ta_copied == ta_number))
08881       item_p = ta_lookup_item_data(ta_number, list, data, compare);
08882     else
08883 #endif
08884     item_p = lookup_item_data(list, data, compare);
08885     if(item_p)
08886       { /* exists -> copy desc */
08887         memcpy(desc,
08888                ((char *) item_p) + sizeof(*item_p),
08889                list->info.desc_size);
08890       }
08891     else
08892       {
08893         err = -RSBAC_ENOTFOUND;
08894       }
08895     rsbac_read_unlock(&list->lock, &lock_flags);
08896     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08897     return err;
08898   }

int rsbac_ta_list_get_max_desc rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 8583 of file gen_lists.c.

References rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, rsbac_list_item_t::max_age, rsbac_list_item_t::prev, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_reg_item_t::self, and rsbac_list_reg_item_t::tail.

Referenced by rsbac_list_get_max_desc().

08587   {
08588     struct rsbac_list_reg_item_t * list;
08589     struct rsbac_list_item_t * item_p;
08590     u_long lock_flags, rlock_flags;
08591     int err = 0;
08592 
08593     if(!handle)
08594       return -RSBAC_EINVALIDVALUE;
08595     if(!list_initialized)
08596       return -RSBAC_ENOTINITIALIZED;
08597 
08598     list = (struct rsbac_list_reg_item_t *) handle;
08599     if(list->self != list)
08600       return -RSBAC_EINVALIDVALUE;
08601 
08602 #ifdef CONFIG_RSBAC_LIST_TRANS
08603     if(ta_number)
08604       {
08605         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08606           return -RSBAC_EINVALIDTRANSACTION;
08607       }
08608 #endif
08609 
08610     rsbac_read_lock(&reg_head.lock, &rlock_flags);
08611 /*
08612 #ifdef CONFIG_RSBAC_DEBUG
08613     if(rsbac_debug_lists)
08614       rsbac_printk(KERN_DEBUG "rsbac_list_get_max_desc: list %s.\n",
08615              list->name);
08616 #endif
08617 */
08618     rsbac_read_lock(&list->lock, &lock_flags);
08619 #ifdef CONFIG_RSBAC_LIST_TRANS
08620     if(ta_number && (list->ta_copied == ta_number))
08621       item_p = list->ta_tail;
08622     else
08623 #endif
08624     item_p = list->tail;
08625     while(   item_p
08626           && item_p->max_age
08627           && (item_p->max_age > RSBAC_CURRENT_TIME)
08628          )
08629       item_p = item_p->prev;
08630     if(item_p)
08631       memcpy(desc, (char *)item_p + sizeof(*item_p), list->info.desc_size);
08632     else
08633       {
08634         memset(desc, 0, list->info.desc_size);
08635         err = -RSBAC_ENOTFOUND;
08636       }
08637     rsbac_read_unlock(&list->lock, &lock_flags);
08638     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08639     return err;
08640   }

int rsbac_ta_list_get_next_desc rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  old_desc,
void *  next_desc
 

Definition at line 8653 of file gen_lists.c.

References rsbac_list_reg_item_t::curr, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, lookup_item(), rsbac_list_item_t::max_age, rsbac_list_item_t::next, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.

Referenced by rsbac_list_get_next_desc().

08658   {
08659     struct rsbac_list_reg_item_t * list;
08660     struct rsbac_list_item_t * item_p;
08661     u_long lock_flags, rlock_flags;
08662 
08663     if(!handle)
08664       return -RSBAC_EINVALIDVALUE;
08665     if(!list_initialized)
08666       return -RSBAC_ENOTINITIALIZED;
08667     if(!next_desc)
08668       return -RSBAC_EINVALIDPOINTER;
08669 
08670     list = (struct rsbac_list_reg_item_t *) handle;
08671     if(list->self != list)
08672       return -RSBAC_EINVALIDVALUE;
08673 
08674 #ifdef CONFIG_RSBAC_LIST_TRANS
08675     if(ta_number)
08676       {
08677         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08678           return -RSBAC_EINVALIDTRANSACTION;
08679       }
08680 #endif
08681 
08682     rsbac_read_lock(&reg_head.lock, &rlock_flags);
08683 /*
08684 #ifdef CONFIG_RSBAC_DEBUG
08685     if(rsbac_debug_lists)
08686       rsbac_printk(KERN_DEBUG "rsbac_list_get_next_desc: list %s.\n",
08687              list->name);
08688 #endif
08689 */
08690     rsbac_read_lock(&list->lock, &lock_flags);
08691     if(old_desc)
08692       {
08693 #ifdef CONFIG_RSBAC_LIST_TRANS
08694         if(ta_number && (list->ta_copied == ta_number))
08695           item_p = ta_lookup_item(ta_number, list, old_desc);
08696         else
08697 #endif
08698         item_p = lookup_item(list, old_desc);
08699         if(item_p)
08700           item_p = item_p->next;
08701       }
08702     else
08703 #ifdef CONFIG_RSBAC_LIST_TRANS
08704       if(ta_number && (list->ta_copied == ta_number))
08705         item_p = list->ta_head;
08706       else
08707 #endif
08708       item_p = list->head;
08709     while(   item_p
08710           && item_p->max_age
08711           && (item_p->max_age > RSBAC_CURRENT_TIME)
08712          )
08713       item_p = item_p->next;
08714     if(item_p)
08715       {
08716         memcpy(next_desc, (char *)item_p + sizeof(*item_p), list->info.desc_size);
08717         list->curr = item_p;
08718       }
08719     rsbac_read_unlock(&list->lock, &lock_flags);
08720     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08721     if(item_p)
08722       return 0;
08723     else
08724       return -RSBAC_ENOTFOUND;
08725   }

int rsbac_ta_list_lol_add_ttl rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
rsbac_time_t  ttl,
void *  desc,
void *  data
 

Definition at line 7336 of file gen_lists.c.

References add_lol_item(), rsbac_list_lol_item_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::dirty, do_remove_lol_item(), rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_touch, lookup_lol_item(), rsbac_list_lol_item_t::max_age, RSBAC_EBUSY, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_MAX_AGE_LIMIT, RSBAC_LIST_TTL_KEEP, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.

Referenced by rsbac_acl_add_group_member(), rsbac_acl_add_to_acl_entry(), rsbac_acl_set_acl_entry(), rsbac_acl_set_mask(), rsbac_list_lol_add(), rsbac_list_lol_add_ttl(), rsbac_pm_create_set(), rsbac_um_add_user(), rsbac_um_mod_user(), and rsbac_um_set_pass().

07342   {
07343     struct rsbac_list_lol_reg_item_t * list;
07344     struct rsbac_list_lol_item_t     * item_p;
07345     u_long lock_flags, rlock_flags;
07346 
07347     if(!handle || !desc)
07348       return -RSBAC_EINVALIDVALUE;
07349     if(!list_initialized)
07350       return -RSBAC_ENOTINITIALIZED;
07351 
07352     list = (struct rsbac_list_lol_reg_item_t *) handle;
07353     if(!list || (list->self != list))
07354       return -RSBAC_EINVALIDVALUE;
07355 
07356 #ifdef CONFIG_RSBAC_LIST_TRANS
07357     if(ta_number && !rsbac_ta_list_exist(0, ta_handle, &ta_number))
07358       return -RSBAC_EINVALIDTRANSACTION;
07359 #endif
07360 
07361     if(ttl && (ttl != RSBAC_LIST_TTL_KEEP))
07362       {
07363         if(ttl > RSBAC_LIST_MAX_AGE_LIMIT)
07364           ttl = RSBAC_LIST_MAX_AGE_LIMIT;
07365         ttl += RSBAC_CURRENT_TIME;
07366       }
07367 
07368     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07369     if(list->info.data_size && !data)
07370       {
07371         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07372         return -RSBAC_EINVALIDVALUE;
07373       }
07374 
07375 /*
07376 #ifdef CONFIG_RSBAC_DEBUG
07377     if(rsbac_debug_lists)
07378       rsbac_printk(KERN_DEBUG "rsbac_list_lol_add: adding to list %s.\n",
07379              list->name);
07380 #endif
07381 */
07382     rsbac_write_lock(&list->lock, &lock_flags);
07383 
07384 #ifdef CONFIG_RSBAC_LIST_TRANS
07385     if(!ta_number)
07386 #endif
07387       {
07388         item_p = lookup_lol_item(list, desc);
07389         if(item_p)
07390           { /* exists -> update data, if any */
07391             if(ttl != RSBAC_LIST_TTL_KEEP)
07392               item_p->max_age = ttl;
07393             if(data && list->info.data_size)
07394               {
07395                 if(   list->def_data
07396                    && !item_p->max_age
07397                    && !memcmp(list->def_data, data, list->info.data_size)
07398                    && !item_p->count
07399                   )
07400                   do_remove_lol_item(list, item_p);
07401                 else
07402                   memcpy(((char *) item_p) + sizeof(*item_p) + list->info.desc_size,
07403                          data, list->info.data_size);
07404               }
07405           }
07406         else
07407           {
07408             if(ttl == RSBAC_LIST_TTL_KEEP)
07409               ttl = 0;
07410             if(   !list->def_data
07411                || memcmp(list->def_data, data, list->info.data_size)
07412               )
07413               add_lol_item(list, ttl, desc, data);
07414           }
07415         lol_touch(list);
07416         list->dirty = TRUE;
07417       }
07418 #ifdef CONFIG_RSBAC_LIST_TRANS
07419     if(list->ta_copied || ta_number)
07420       {
07421         if(!list->ta_copied)
07422           ta_lol_copy(ta_number, list);
07423         else
07424           if(ta_number)
07425             {
07426               if(list->ta_copied != ta_number)
07427                 {
07428                   rsbac_write_unlock(&list->lock, &lock_flags);
07429                   rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07430                   return -RSBAC_EBUSY;
07431                 }
07432             }
07433           else
07434             ta_number = list->ta_copied;
07435         item_p = ta_lookup_lol_item(ta_number, list, desc);
07436         if(item_p)
07437           { /* exists -> update data, if any */
07438             if(ttl != RSBAC_LIST_TTL_KEEP)
07439               item_p->max_age = ttl;
07440             if(data && list->info.data_size)
07441               {
07442                 if(   list->def_data
07443                    && !item_p->max_age
07444                    && !memcmp(list->def_data, data, list->info.data_size)
07445                    && !item_p->count
07446                   )
07447                   ta_do_remove_lol_item(list, item_p);
07448                 else
07449                   memcpy(((char *) item_p) + sizeof(*item_p) + list->info.desc_size,
07450                          data, list->info.data_size);
07451               }
07452           }
07453         else
07454           {
07455             if(ttl == RSBAC_LIST_TTL_KEEP)
07456               ttl = 0;
07457             if(   !list->def_data
07458                || memcmp(list->def_data, data, list->info.data_size)
07459               )
07460               ta_add_lol_item(ta_number, list, ttl, desc, data);
07461           }
07462       }
07463 #endif
07464     rsbac_write_unlock(&list->lock, &lock_flags);
07465     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07466     return 0;
07467   }

long rsbac_ta_list_lol_all_subcount rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle
 

Definition at line 9389 of file gen_lists.c.

References rsbac_list_lol_item_t::count, rsbac_list_lol_reg_item_t::head, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_item_t::next, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_list_lol_all_subcount().

09392   {
09393     struct rsbac_list_lol_reg_item_t * list;
09394     struct rsbac_list_lol_item_t     * sublist;
09395     u_long lock_flags, rlock_flags;
09396     long result = 0;
09397 
09398     if(!handle)
09399       return -RSBAC_EINVALIDVALUE;
09400     if(!list_initialized)
09401       return -RSBAC_ENOTINITIALIZED;
09402 
09403     list = (struct rsbac_list_lol_reg_item_t *) handle;
09404     if(list->self != list)
09405       return -RSBAC_EINVALIDVALUE;
09406 
09407 #ifdef CONFIG_RSBAC_LIST_TRANS
09408     if(ta_number)
09409       {
09410         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09411           return -RSBAC_EINVALIDTRANSACTION;
09412       }
09413 #endif
09414 
09415     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09416 /*
09417 #ifdef CONFIG_RSBAC_DEBUG
09418     if(rsbac_debug_lists)
09419       rsbac_printk(KERN_DEBUG "rsbac_list_lol_subcount: list %s.\n",
09420              list->name);
09421 #endif
09422 */
09423     rsbac_read_lock(&list->lock, &lock_flags);
09424 
09425 #ifdef CONFIG_RSBAC_LIST_TRANS
09426     if(ta_number && (list->ta_copied == ta_number))
09427       sublist = list->ta_head;
09428     else
09429 #endif
09430     sublist = list->head;
09431     while(sublist)
09432       {
09433         result += sublist->count;
09434         sublist = sublist->next;
09435       }
09436     rsbac_read_unlock(&list->lock, &lock_flags);
09437     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09438     return result;
09439   }

long rsbac_ta_list_lol_count rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle
 

Definition at line 9452 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::count, list_initialized, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_acl_list_all_dev(), rsbac_acl_list_all_major_dev(), rsbac_acl_list_all_user(), rsbac_list_lol_count(), rsbac_um_get_gm_user_list(), and rsbac_um_get_user_list().

09455   {
09456     struct rsbac_list_lol_reg_item_t * list;
09457 
09458     if(!handle)
09459       return -RSBAC_EINVALIDVALUE;
09460     if(!list_initialized)
09461       return -RSBAC_ENOTINITIALIZED;
09462 
09463     list = (struct rsbac_list_lol_reg_item_t *) handle;
09464     if(list->self != list)
09465       return -RSBAC_EINVALIDVALUE;
09466 
09467 #ifdef CONFIG_RSBAC_LIST_TRANS
09468     if(ta_number)
09469       {
09470         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09471           return -RSBAC_EINVALIDTRANSACTION;
09472       }
09473 #endif
09474 
09475 /*
09476 #ifdef CONFIG_RSBAC_DEBUG
09477     if(rsbac_debug_lists)
09478       rsbac_printk(KERN_DEBUG "rsbac_list_lol_count: list %s.\n",
09479              list->name);
09480 #endif
09481 */
09482 #ifdef CONFIG_RSBAC_LIST_TRANS
09483     if(ta_number && (list->ta_copied == ta_number))
09484       return list->ta_count;
09485     else
09486 #endif
09487     return list->count;
09488   }

int rsbac_ta_list_lol_exist rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 9245 of file gen_lists.c.

References FALSE, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_item(), rsbac_list_lol_item_t::max_age, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.

Referenced by rsbac_acl_add_group_member(), rsbac_acl_add_to_acl_entry(), rsbac_acl_set_acl_entry(), rsbac_list_lol_exist(), rsbac_pm_create_set(), rsbac_pm_exists(), rsbac_pm_remove_target(), rsbac_pm_set_exist(), rsbac_um_add_user(), rsbac_um_get_user_item(), rsbac_um_mod_user(), rsbac_um_remove_user(), and rsbac_um_user_exists().

09249   {
09250     struct rsbac_list_lol_reg_item_t * list;
09251     u_long lock_flags, rlock_flags;
09252     struct rsbac_list_lol_item_t     * item_p;
09253     int result;
09254 
09255     if(!handle || !desc)
09256       return FALSE;
09257     if(!list_initialized)
09258       return FALSE;
09259 
09260     list = (struct rsbac_list_lol_reg_item_t *) handle;
09261     if(list->self != list)
09262       return -RSBAC_EINVALIDVALUE;
09263 
09264 #ifdef CONFIG_RSBAC_LIST_TRANS
09265     if(ta_number)
09266       {
09267         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09268           return -RSBAC_EINVALIDTRANSACTION;
09269       }
09270 #endif
09271 
09272     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09273 /*
09274 #ifdef CONFIG_RSBAC_DEBUG
09275     if(rsbac_debug_lists)
09276       rsbac_printk(KERN_DEBUG "rsbac_list_lol_exist: testing on list %s.\n",
09277              list->name);
09278 #endif
09279 */
09280     rsbac_read_lock(&list->lock, &lock_flags);
09281 
09282 #ifdef CONFIG_RSBAC_LIST_TRANS
09283     if(ta_number && (list->ta_copied == ta_number))
09284       item_p = ta_lookup_lol_item(ta_number, list, desc);
09285     else
09286 #endif
09287     item_p = lookup_lol_item(list, desc);
09288     if(   item_p
09289        && (   !item_p->max_age
09290            || (item_p->max_age > RSBAC_CURRENT_TIME)
09291           )
09292       )
09293       { /* exists -> TRUE */
09294         result = TRUE;
09295       }
09296     else
09297       {
09298         result = FALSE;
09299       }
09300     rsbac_read_unlock(&list->lock, &lock_flags);
09301     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09302     return result;
09303   }

long rsbac_ta_list_lol_get_all_data rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void **  array_p
 

Definition at line 10156 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_item_t::max_age, rsbac_list_lol_item_t::next, NULL, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_list_lol_get_all_data().

10160   {
10161     struct rsbac_list_lol_reg_item_t * list;
10162     struct rsbac_list_lol_item_t     * item_p;
10163            char                      * buffer;
10164     u_long lock_flags, rlock_flags;
10165     u_long offset = 0;
10166     long result = 0;
10167     u_int item_size;
10168     u_int item_offset;
10169 
10170     if(!handle)
10171       return -RSBAC_EINVALIDVALUE;
10172     if(!array_p)
10173       return -RSBAC_EINVALIDVALUE;
10174     if(!list_initialized)
10175       return -RSBAC_ENOTINITIALIZED;
10176 
10177     list = (struct rsbac_list_lol_reg_item_t *) handle;
10178     if(list->self != list)
10179       return -RSBAC_EINVALIDVALUE;
10180     *array_p = NULL;
10181 
10182 #ifdef CONFIG_RSBAC_LIST_TRANS
10183     if(ta_number)
10184       {
10185         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
10186           return -RSBAC_EINVALIDTRANSACTION;
10187       }
10188 #endif
10189 
10190     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
10191 /*
10192 #ifdef CONFIG_RSBAC_DEBUG
10193     if(rsbac_debug_lists)
10194       rsbac_printk(KERN_DEBUG "rsbac_list_lol_get_all_desc: list %s.\n",
10195              list->name);
10196 #endif
10197 */
10198     rsbac_read_lock(&list->lock, &lock_flags);
10199     if(!list->info.data_size)
10200       {
10201         rsbac_read_unlock(&list->lock, &lock_flags);
10202         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
10203         return -RSBAC_EINVALIDREQUEST;
10204       }
10205 #ifdef CONFIG_RSBAC_LIST_TRANS
10206     if(ta_number && (list->ta_copied == ta_number))
10207       {
10208         if(list->ta_count)
10209           {
10210             item_size = list->info.data_size;
10211             item_offset = list->info.desc_size;
10212             buffer = rsbac_vmalloc(item_size * list->ta_count);
10213             if(buffer)
10214               {
10215                 item_p = list->ta_head;
10216                 while(item_p)
10217                   {
10218                     if(   !item_p->max_age
10219                        || (item_p->max_age > RSBAC_CURRENT_TIME)
10220                       )
10221                       {
10222                         memcpy(buffer + offset,
10223                                ((char *) item_p) + sizeof(*item_p) + item_offset,
10224                                item_size);
10225                         offset += item_size;
10226                         result++;
10227                       }
10228                     item_p = item_p->next;
10229                   }
10230                 *array_p = buffer;
10231               }
10232             else
10233               {
10234                 result = -RSBAC_ENOMEM;
10235               }
10236           }
10237       }
10238     else
10239 #endif
10240     if(list->count)
10241       {
10242         item_size = list->info.data_size;
10243         item_offset = list->info.desc_size;
10244         buffer = rsbac_vmalloc(item_size * list->count);
10245         if(buffer)
10246           {
10247             item_p = list->head;
10248             while(item_p)
10249               {
10250                 if(   !item_p->max_age
10251                    || (item_p->max_age > RSBAC_CURRENT_TIME)
10252                   )
10253                   {
10254                     memcpy(buffer + offset,
10255                            ((char *) item_p) + sizeof(*item_p) + item_offset,
10256                            item_size);
10257                     offset += item_size;
10258                     result++;
10259                   }
10260                 item_p = item_p->next;
10261               }
10262             *array_p = buffer;
10263           }
10264         else
10265           {
10266             result = -RSBAC_ENOMEM;
10267           }
10268       }
10269     rsbac_read_unlock(&list->lock, &lock_flags);
10270     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
10271     return result;
10272   }

long rsbac_ta_list_lol_get_all_desc rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void **  array_p
 

Definition at line 9795 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::count, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_item_t::max_age, rsbac_list_lol_item_t::next, NULL, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_acl_get_group_members(), rsbac_acl_list_all_dev(), rsbac_acl_list_all_major_dev(), rsbac_acl_list_all_user(), rsbac_list_lol_get_all_desc(), rsbac_um_get_gm_user_list(), and rsbac_um_get_user_list().

09799   {
09800     struct rsbac_list_lol_reg_item_t * list;
09801     struct rsbac_list_lol_item_t     * item_p;
09802            char                      * buffer;
09803     u_long lock_flags, rlock_flags;
09804     u_long offset = 0;
09805     long result = 0;
09806     u_int item_size;
09807 
09808     if(!handle)
09809       return -RSBAC_EINVALIDVALUE;
09810     if(!array_p)
09811       return -RSBAC_EINVALIDVALUE;
09812     if(!list_initialized)
09813       return -RSBAC_ENOTINITIALIZED;
09814 
09815     list = (struct rsbac_list_lol_reg_item_t *) handle;
09816     if(list->self != list)
09817       return -RSBAC_EINVALIDVALUE;
09818     *array_p = NULL;
09819 
09820 #ifdef CONFIG_RSBAC_LIST_TRANS
09821     if(ta_number)
09822       {
09823         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09824           return -RSBAC_EINVALIDTRANSACTION;
09825       }
09826 #endif
09827 
09828     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09829 /*
09830 #ifdef CONFIG_RSBAC_DEBUG
09831     if(rsbac_debug_lists)
09832       rsbac_printk(KERN_DEBUG "rsbac_list_lol_get_all_desc: list %s.\n",
09833              list->name);
09834 #endif
09835 */
09836     rsbac_read_lock(&list->lock, &lock_flags);
09837 #ifdef CONFIG_RSBAC_LIST_TRANS
09838     if(ta_number && (list->ta_copied == ta_number))
09839       {
09840         if(list->ta_count)
09841           {
09842             item_size = list->info.desc_size;
09843             buffer = rsbac_vmalloc(item_size * list->ta_count);
09844             if(buffer)
09845               {
09846                 item_p = list->ta_head;
09847                 while(item_p)
09848                   {
09849                     if(   !item_p->max_age
09850                        || (item_p->max_age > RSBAC_CURRENT_TIME)
09851                       )
09852                       {
09853                         memcpy(buffer + offset,
09854                                ((char *) item_p) + sizeof(*item_p),
09855                                item_size);
09856                         offset += item_size;
09857                         result++;
09858                       }
09859                     item_p = item_p->next;
09860                   }
09861                 *array_p = buffer;
09862               }
09863             else
09864               {
09865                 result = -RSBAC_ENOMEM;
09866               }
09867           }
09868       }
09869     else
09870 #endif
09871     if(list->count)
09872       {
09873         item_size = list->info.desc_size;
09874         buffer = rsbac_vmalloc(item_size * list->count);
09875         if(buffer)
09876           {
09877             item_p = list->head;
09878             while(item_p)
09879               {
09880                 if(   !item_p->max_age
09881                    || (item_p->max_age > RSBAC_CURRENT_TIME)
09882                   )
09883                   {
09884                     memcpy(buffer + offset,
09885                            ((char *) item_p) + sizeof(*item_p),
09886                            item_size);
09887                     offset += item_size;
09888                     result++;
09889                   }
09890                 item_p = item_p->next;
09891               }
09892             *array_p = buffer;
09893           }
09894         else
09895           {
09896             result = -RSBAC_ENOMEM;
09897           }
09898       }
09899     rsbac_read_unlock(&list->lock, &lock_flags);
09900     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09901     return result;
09902   }

long rsbac_ta_list_lol_get_all_items rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void **  array_p
 

Definition at line 10625 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_item_t::max_age, rsbac_list_lol_item_t::next, NULL, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_list_lol_get_all_items().

10629   {
10630     struct rsbac_list_lol_reg_item_t * list;
10631     struct rsbac_list_lol_item_t     * item_p;
10632            char                      * buffer;
10633     u_long lock_flags, rlock_flags;
10634     u_long offset = 0;
10635     long result = 0;
10636     u_int item_size;
10637 
10638     if(!handle)
10639       return -RSBAC_EINVALIDVALUE;
10640     if(!array_p)
10641       return -RSBAC_EINVALIDVALUE;
10642     if(!list_initialized)
10643       return -RSBAC_ENOTINITIALIZED;
10644 
10645     list = (struct rsbac_list_lol_reg_item_t *) handle;
10646     if(list->self != list)
10647       return -RSBAC_EINVALIDVALUE;
10648     *array_p = NULL;
10649 
10650 #ifdef CONFIG_RSBAC_LIST_TRANS
10651     if(ta_number)
10652       {
10653         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
10654           return -RSBAC_EINVALIDTRANSACTION;
10655       }
10656 #endif
10657 
10658     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
10659 /*
10660 #ifdef CONFIG_RSBAC_DEBUG
10661     if(rsbac_debug_lists)
10662       rsbac_printk(KERN_DEBUG "rsbac_list_lol_get_all_items: list %s.\n",
10663              list->name);
10664 #endif
10665 */
10666     rsbac_read_lock(&list->lock, &lock_flags);
10667 #ifdef CONFIG_RSBAC_LIST_TRANS
10668     if(ta_number && (list->ta_copied == ta_number))
10669       {
10670         if(list->ta_count)
10671           {
10672             item_size = list->info.desc_size + list->info.data_size;
10673             buffer = rsbac_vmalloc(item_size * list->ta_count);
10674             if(buffer)
10675               {
10676                 item_p = list->ta_head;
10677                 while(item_p)
10678                   {
10679                     if(   !item_p->max_age
10680                        || (item_p->max_age > RSBAC_CURRENT_TIME)
10681                       )
10682                       {
10683                         memcpy(buffer + offset,
10684                                ((char *) item_p) + sizeof(*item_p),
10685                                item_size);
10686                         offset += item_size;
10687                         result++;
10688                       }
10689                     item_p = item_p->next;
10690                   }
10691                 *array_p = buffer;
10692               }
10693             else
10694               {
10695                 result = -RSBAC_ENOMEM;
10696               }
10697           }
10698       }
10699     else
10700 #endif
10701     if(list->count)
10702       {
10703         item_size = list->info.desc_size + list->info.data_size;
10704         buffer = rsbac_vmalloc(item_size * list->count);
10705         if(buffer)
10706           {
10707             item_p = list->head;
10708             while(item_p)
10709               {
10710                 if(   !item_p->max_age
10711                    || (item_p->max_age > RSBAC_CURRENT_TIME)
10712                   )
10713                   {
10714                     memcpy(buffer + offset,
10715                            ((char *) item_p) + sizeof(*item_p),
10716                            item_size);
10717                     offset += item_size;
10718                     result++;
10719                   }
10720                 item_p = item_p->next;
10721               }
10722             *array_p = buffer;
10723           }
10724         else
10725           {
10726             result = -RSBAC_ENOMEM;
10727           }
10728       }
10729     rsbac_read_unlock(&list->lock, &lock_flags);
10730     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
10731     return result;
10732   }

long rsbac_ta_list_lol_get_all_subdata rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc,
void **  array_p
 

Definition at line 10051 of file gen_lists.c.

References rsbac_list_lol_item_t::count, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_item(), rsbac_list_item_t::max_age, rsbac_list_item_t::next, NULL, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_vmalloc, rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size.

Referenced by rsbac_list_lol_get_all_subdata().

10056   {
10057     struct rsbac_list_lol_reg_item_t * list;
10058     struct rsbac_list_lol_item_t     * sublist;
10059     struct rsbac_list_item_t         * item_p;
10060            char                      * buffer;
10061     u_long lock_flags, rlock_flags;
10062     u_long offset = 0;
10063     long result = 0;
10064     u_int item_size;
10065     u_int item_offset;
10066 
10067     if(!handle)
10068       return -RSBAC_EINVALIDVALUE;
10069     if(!array_p)
10070       return -RSBAC_EINVALIDVALUE;
10071     if(!list_initialized)
10072       return -RSBAC_ENOTINITIALIZED;
10073 
10074     list = (struct rsbac_list_lol_reg_item_t *) handle;
10075     if(list->self != list)
10076       return -RSBAC_EINVALIDVALUE;
10077     *array_p = NULL;
10078 
10079 #ifdef CONFIG_RSBAC_LIST_TRANS
10080     if(ta_number)
10081       {
10082         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
10083           return -RSBAC_EINVALIDTRANSACTION;
10084       }
10085 #endif
10086 
10087     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
10088 /*
10089 #ifdef CONFIG_RSBAC_DEBUG
10090     if(rsbac_debug_lists)
10091       rsbac_printk(KERN_DEBUG "rsbac_ta_list_lol_get_all_desc: list %s.\n",
10092              list->name);
10093 #endif
10094 */
10095     rsbac_read_lock(&list->lock, &lock_flags);
10096     if(!list->info.subdata_size)
10097       {
10098         rsbac_read_unlock(&list->lock, &lock_flags);
10099         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
10100         return -RSBAC_EINVALIDREQUEST;
10101       }
10102 #ifdef CONFIG_RSBAC_LIST_TRANS
10103     if(ta_number && (list->ta_copied == ta_number))
10104       sublist = ta_lookup_lol_item(ta_number, list, desc);
10105     else
10106 #endif
10107     sublist = lookup_lol_item(list, desc);
10108     if(sublist && sublist->count)
10109       {
10110         item_size = list->info.subdata_size;
10111         item_offset = list->info.subdesc_size;
10112         buffer = rsbac_vmalloc(item_size * sublist->count);
10113         if(buffer)
10114           {
10115             item_p = sublist->head;
10116             while(item_p)
10117               {
10118                 if(   !item_p->max_age
10119                    || (item_p->max_age > RSBAC_CURRENT_TIME)
10120                   )
10121                   {
10122                     memcpy(buffer + offset,
10123                            ((char *) item_p) + sizeof(*item_p) + item_offset,
10124                            item_size);
10125                     offset += item_size;
10126                     result++;
10127                   }
10128                 item_p = item_p->next;
10129               }
10130             *array_p = buffer;
10131           }
10132         else
10133           {
10134             result = -RSBAC_ENOMEM;
10135           }
10136       }
10137     rsbac_read_unlock(&list->lock, &lock_flags);
10138     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
10139     return result;
10140   }

long rsbac_ta_list_lol_get_all_subdesc_ttl rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc,
void **  array_p,
rsbac_time_t **  ttl_array_p
 

Definition at line 9671 of file gen_lists.c.

References rsbac_list_lol_item_t::count, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_item(), rsbac_list_item_t::max_age, rsbac_list_item_t::next, NULL, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_vmalloc, rsbac_list_lol_reg_item_t::self, and rsbac_list_lol_info_t::subdesc_size.

Referenced by rsbac_acl_get_user_groups(), rsbac_auth_get_f_caplist(), rsbac_auth_get_p_caplist(), rsbac_list_lol_get_all_subdesc(), rsbac_list_lol_get_all_subdesc_ttl(), rsbac_mac_get_f_trulist(), rsbac_mac_get_p_trulist(), rsbac_rc_copy_role(), rsbac_rc_get_list(), and rsbac_um_get_gm_list().

09677   {
09678     struct rsbac_list_lol_reg_item_t * list;
09679     struct rsbac_list_lol_item_t     * sublist;
09680     struct rsbac_list_item_t         * item_p;
09681            char                      * buffer;
09682            rsbac_time_t              * ttl_p = NULL;
09683     u_long lock_flags, rlock_flags;
09684     u_long offset = 0;
09685     long result = 0;
09686     u_int item_size;
09687 
09688     if(!handle)
09689       return -RSBAC_EINVALIDVALUE;
09690     if(!array_p)
09691       return -RSBAC_EINVALIDVALUE;
09692     if(!list_initialized)
09693       return -RSBAC_ENOTINITIALIZED;
09694 
09695     list = (struct rsbac_list_lol_reg_item_t *) handle;
09696     if(list->self != list)
09697       return -RSBAC_EINVALIDVALUE;
09698     *array_p = NULL;
09699 
09700 #ifdef CONFIG_RSBAC_LIST_TRANS
09701     if(ta_number)
09702       {
09703         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09704           return -RSBAC_EINVALIDTRANSACTION;
09705       }
09706 #endif
09707 
09708     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09709 /*
09710 #ifdef CONFIG_RSBAC_DEBUG
09711     if(rsbac_debug_lists)
09712       rsbac_printk(KERN_DEBUG "rsbac_list_lol_get_all_desc: list %s.\n",
09713              list->name);
09714 #endif
09715 */
09716     rsbac_read_lock(&list->lock, &lock_flags);
09717 #ifdef CONFIG_RSBAC_LIST_TRANS
09718     if(ta_number && (list->ta_copied == ta_number))
09719       sublist = ta_lookup_lol_item(ta_number, list, desc);
09720     else
09721 #endif
09722     sublist = lookup_lol_item(list, desc);
09723     if(sublist && sublist->count)
09724       {
09725         item_size = list->info.subdesc_size;
09726         buffer = rsbac_vmalloc(item_size * sublist->count);
09727         if(buffer)
09728           {
09729             if(ttl_array_p)
09730               ttl_p = rsbac_vmalloc(sizeof(**ttl_array_p) * sublist->count);
09731             item_p = sublist->head;
09732             while(item_p)
09733               {
09734                 if(   !item_p->max_age
09735                    || (item_p->max_age > RSBAC_CURRENT_TIME)
09736                   )
09737                   {
09738                     memcpy(buffer + offset,
09739                            ((char *) item_p) + sizeof(*item_p),
09740                            item_size);
09741                     if(ttl_p)
09742                       {
09743                         if(item_p->max_age)
09744                           ttl_p[result] = item_p->max_age - RSBAC_CURRENT_TIME;
09745                         else
09746                           ttl_p[result] = 0;
09747                       }
09748                     offset += item_size;
09749                     result++;
09750                   }
09751                 item_p = item_p->next;
09752               }
09753             *array_p = buffer;
09754             if(ttl_array_p)
09755               *ttl_array_p = ttl_p;
09756           }
09757         else
09758           {
09759             result = -RSBAC_ENOMEM;
09760           }
09761       }
09762     rsbac_read_unlock(&list->lock, &lock_flags);
09763     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09764     return result;
09765   }

long rsbac_ta_list_lol_get_all_subitems_ttl rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc,
void **  array_p,
rsbac_time_t **  ttl_array_p
 

Definition at line 10504 of file gen_lists.c.

References rsbac_list_lol_item_t::count, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_item(), rsbac_list_item_t::max_age, rsbac_list_item_t::next, NULL, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_vmalloc, rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size.

Referenced by rsbac_acl_get_tlist(), rsbac_list_lol_get_all_subitems(), rsbac_list_lol_get_all_subitems_ttl(), and rsbac_rc_copy_role().

10510   {
10511     struct rsbac_list_lol_reg_item_t * list;
10512     struct rsbac_list_lol_item_t     * sublist;
10513     struct rsbac_list_item_t         * item_p;
10514            char                      * buffer;
10515            rsbac_time_t              * ttl_p = NULL;
10516     u_long lock_flags, rlock_flags;
10517     u_long offset = 0;
10518     long result = 0;
10519     u_int item_size;
10520 
10521     if(!handle)
10522       return -RSBAC_EINVALIDVALUE;
10523     if(!array_p)
10524       return -RSBAC_EINVALIDVALUE;
10525     if(!list_initialized)
10526       return -RSBAC_ENOTINITIALIZED;
10527 
10528     list = (struct rsbac_list_lol_reg_item_t *) handle;
10529     if(list->self != list)
10530       return -RSBAC_EINVALIDVALUE;
10531     *array_p = NULL;
10532 
10533 #ifdef CONFIG_RSBAC_LIST_TRANS
10534     if(ta_number)
10535       {
10536         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
10537           return -RSBAC_EINVALIDTRANSACTION;
10538       }
10539 #endif
10540 
10541     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
10542 /*
10543 #ifdef CONFIG_RSBAC_DEBUG
10544     if(rsbac_debug_lists)
10545       rsbac_printk(KERN_DEBUG "rsbac_list_lol_get_all_subitems: list %s.\n",
10546              list->name);
10547 #endif
10548 */
10549     rsbac_read_lock(&list->lock, &lock_flags);
10550 #ifdef CONFIG_RSBAC_LIST_TRANS
10551     if(ta_number && (list->ta_copied == ta_number))
10552       sublist = ta_lookup_lol_item(ta_number, list, desc);
10553     else
10554 #endif
10555     sublist = lookup_lol_item(list, desc);
10556     if(sublist && sublist->count)
10557       {
10558         item_size = list->info.subdesc_size + list->info.subdata_size;
10559         buffer = rsbac_vmalloc(item_size * sublist->count);
10560         if(buffer)
10561           {
10562             if(ttl_array_p)
10563               ttl_p = rsbac_vmalloc(sizeof(**ttl_array_p) * sublist->count);
10564             item_p = sublist->head;
10565             while(item_p)
10566               {
10567                 if(   !item_p->max_age
10568                    || (item_p->max_age > RSBAC_CURRENT_TIME)
10569                   )
10570                   {
10571                     memcpy(buffer + offset,
10572                            ((char *) item_p) + sizeof(*item_p),
10573                            item_size);
10574                     if(ttl_p)
10575                       {
10576                         if(item_p->max_age)
10577                           ttl_p[result] = item_p->max_age - RSBAC_CURRENT_TIME;
10578                         else
10579                           ttl_p[result] = 0;
10580                       }
10581                     offset += item_size;
10582                     result++;
10583                   }
10584                 item_p = item_p->next;
10585               }
10586             *array_p = buffer;
10587             if(ttl_array_p)
10588               *ttl_array_p = ttl_p;
10589           }
10590         else
10591           {
10592             result = -RSBAC_ENOMEM;
10593           }
10594       }
10595     rsbac_read_unlock(&list->lock, &lock_flags);
10596     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
10597     return result;
10598   }

int rsbac_ta_list_lol_get_data_ttl rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
rsbac_time_t ttl_p,
void *  desc,
void *  data
 

Definition at line 8469 of file gen_lists.c.

References rsbac_list_lol_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_item(), rsbac_list_lol_item_t::max_age, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_acl_get_mask(), rsbac_acl_get_rights(), rsbac_acl_get_single_right(), rsbac_acl_remove_acl_entry(), rsbac_list_lol_get_data(), rsbac_list_lol_get_data_ttl(), rsbac_um_check_account(), rsbac_um_check_pass(), rsbac_um_get_user_entry(), rsbac_um_get_user_item(), rsbac_um_mod_user(), and rsbac_um_set_pass().

08475   {
08476     struct rsbac_list_lol_reg_item_t * list;
08477     struct rsbac_list_lol_item_t     * item_p;
08478     u_long lock_flags, rlock_flags;
08479     int err = 0;
08480 
08481     if(!handle || !desc)
08482       return -RSBAC_EINVALIDVALUE;
08483     if(!list_initialized)
08484       return -RSBAC_ENOTINITIALIZED;
08485 
08486     list = (struct rsbac_list_lol_reg_item_t *) handle;
08487     if(list->self != list)
08488       return -RSBAC_EINVALIDVALUE;
08489 
08490 #ifdef CONFIG_RSBAC_LIST_TRANS
08491     if(ta_number)
08492       {
08493         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08494           return -RSBAC_EINVALIDTRANSACTION;
08495       }
08496 #endif
08497 
08498     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08499 /*
08500 #ifdef CONFIG_RSBAC_DEBUG
08501     if(rsbac_debug_lists)
08502       rsbac_printk(KERN_DEBUG "rsbac_list_lol_get_data: getting data from list %s.\n",
08503              list->name);
08504 #endif
08505 */
08506     if(data && !list->info.data_size)
08507       {
08508         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08509         return -RSBAC_EINVALIDREQUEST;
08510       }
08511 
08512     rsbac_read_lock(&list->lock, &lock_flags);
08513 
08514 #ifdef CONFIG_RSBAC_LIST_TRANS
08515     if(ta_number && (list->ta_copied == ta_number))
08516       item_p = ta_lookup_lol_item(ta_number, list, desc);
08517     else
08518 #endif
08519     item_p = lookup_lol_item(list, desc);
08520     if(   item_p
08521        && (   !item_p->max_age
08522            || (item_p->max_age > RSBAC_CURRENT_TIME)
08523           )
08524       )
08525       { /* exists -> copy data, if any */
08526         if(ttl_p)
08527           {
08528             if(item_p->max_age)
08529               *ttl_p = item_p->max_age - RSBAC_CURRENT_TIME;
08530             else
08531               *ttl_p = 0;
08532           }
08533         if(data)
08534           {
08535             memcpy(data,
08536                    ((char *) item_p) + sizeof(*item_p) + list->info.desc_size,
08537                    list->info.data_size);
08538           }
08539       }
08540     else
08541       {
08542         if(!list->def_data)
08543           err = -RSBAC_ENOTFOUND;
08544         else
08545           {
08546             if(ttl_p)
08547               *ttl_p = 0;
08548             if(data)
08549               memcpy(data,
08550                      list->def_data,
08551                      list->info.data_size);
08552           }
08553       }
08554     rsbac_read_unlock(&list->lock, &lock_flags);
08555     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08556     return err;
08557   }

int rsbac_ta_list_lol_get_desc rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc,
void *  data,
rsbac_list_data_compare_function_t  compare
 

Definition at line 8915 of file gen_lists.c.

References rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_item_data(), RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_list_lol_get_desc(), and rsbac_um_get_uid().

08921   {
08922     struct rsbac_list_lol_reg_item_t * list;
08923     struct rsbac_list_lol_item_t     * item_p;
08924     u_long lock_flags, rlock_flags;
08925     int err = 0;
08926 
08927     if(!handle || !desc || !data)
08928       return -RSBAC_EINVALIDVALUE;
08929     if(!list_initialized)
08930       return -RSBAC_ENOTINITIALIZED;
08931 
08932     list = (struct rsbac_list_lol_reg_item_t *) handle;
08933     if(list->self != list)
08934       return -RSBAC_EINVALIDVALUE;
08935 
08936 #ifdef CONFIG_RSBAC_LIST_TRANS
08937     if(ta_number)
08938       {
08939         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08940           return -RSBAC_EINVALIDTRANSACTION;
08941       }
08942 #endif
08943 
08944     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08945 /*
08946 #ifdef CONFIG_RSBAC_DEBUG
08947     if(rsbac_debug_lists)
08948       rsbac_printk(KERN_DEBUG "rsbac_list_lol_get_desc: getting desc from list %s.\n",
08949              list->name);
08950 #endif
08951 */
08952     if(!list->info.data_size)
08953       {
08954         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08955         return -RSBAC_EINVALIDREQUEST;
08956       }
08957 
08958     rsbac_read_lock(&list->lock, &lock_flags);
08959 
08960 #ifdef CONFIG_RSBAC_LIST_TRANS
08961     if(ta_number && (list->ta_copied == ta_number))
08962       item_p = ta_lookup_lol_item_data(ta_number, list, data, compare);
08963     else
08964 #endif
08965     item_p = lookup_lol_item_data(list, data, compare);
08966     if(item_p)
08967       { /* exists -> copy desc */
08968         memcpy(desc,
08969                ((char *) item_p) + sizeof(*item_p),
08970                list->info.desc_size);
08971       }
08972     else
08973       {
08974         err = -RSBAC_ENOTFOUND;
08975       }
08976     rsbac_read_unlock(&list->lock, &lock_flags);
08977     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08978     return err;
08979   }

int rsbac_ta_list_lol_get_next_desc rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  old_desc,
void *  next_desc
 

Definition at line 8738 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::curr, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_item_t::next, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_list_lol_get_next_desc(), and rsbac_um_get_next_user().

08743   {
08744     struct rsbac_list_lol_reg_item_t * list;
08745     struct rsbac_list_lol_item_t * item_p;
08746     u_long lock_flags, rlock_flags;
08747 
08748     if(!handle)
08749       return -RSBAC_EINVALIDVALUE;
08750     if(!list_initialized)
08751       return -RSBAC_ENOTINITIALIZED;
08752     if(!next_desc)
08753       return -RSBAC_EINVALIDPOINTER;
08754 
08755     list = (struct rsbac_list_lol_reg_item_t *) handle;
08756     if(list->self != list)
08757       return -RSBAC_EINVALIDVALUE;
08758 
08759 #ifdef CONFIG_RSBAC_LIST_TRANS
08760     if(ta_number)
08761       {
08762         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08763           return -RSBAC_EINVALIDTRANSACTION;
08764       }
08765 #endif
08766 
08767     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08768 /*
08769 #ifdef CONFIG_RSBAC_DEBUG
08770     if(rsbac_debug_lists)
08771       rsbac_printk(KERN_DEBUG "rsbac_list_lol_get_next_desc: list %s.\n",
08772              list->name);
08773 #endif
08774 */
08775     rsbac_read_lock(&list->lock, &lock_flags);
08776     if(old_desc)
08777       {
08778 #ifdef CONFIG_RSBAC_LIST_TRANS
08779         if(ta_number && (list->ta_copied == ta_number))
08780           item_p = ta_lookup_lol_item(ta_number, list, old_desc);
08781         else
08782 #endif
08783         item_p = lookup_lol_item(list, old_desc);
08784         if(item_p)
08785           item_p = item_p->next;
08786       }
08787     else
08788 #ifdef CONFIG_RSBAC_LIST_TRANS
08789       if(ta_number && (list->ta_copied == ta_number))
08790         item_p = list->ta_head;
08791       else
08792 #endif
08793       item_p = list->head;
08794     while(   item_p
08795           && item_p->max_age
08796           && (item_p->max_age > RSBAC_CURRENT_TIME)
08797          )
08798       item_p = item_p->next;
08799     if(item_p)
08800       {
08801         memcpy(next_desc, (char *)item_p + sizeof(*item_p), list->info.desc_size);
08802         list->curr = item_p;
08803       }
08804     rsbac_read_unlock(&list->lock, &lock_flags);
08805     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08806     if(item_p)
08807       return 0;
08808     else
08809       return -RSBAC_ENOTFOUND;
08810   }

int rsbac_ta_list_lol_get_subdata_ttl rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
rsbac_time_t ttl_p,
void *  desc,
void *  subdesc,
void *  subdata
 

Definition at line 8330 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::def_subdata, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_item_t::max_age, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size.

Referenced by rsbac_acl_add_to_acl_entry(), rsbac_acl_get_group_members(), rsbac_acl_get_rights(), rsbac_acl_get_single_right(), rsbac_acl_remove_from_acl_entry(), rsbac_list_lol_get_subdata(), rsbac_list_lol_get_subdata_ttl(), rsbac_rc_copy_type(), and rsbac_rc_get_item().

08337   {
08338     struct rsbac_list_lol_reg_item_t * list;
08339     struct rsbac_list_lol_item_t     * sublist;
08340     struct rsbac_list_item_t         * item_p;
08341     u_long lock_flags, rlock_flags;
08342     int err = 0;
08343 
08344     if(!handle || !desc || !subdesc)
08345       return -RSBAC_EINVALIDVALUE;
08346     if(!list_initialized)
08347       return -RSBAC_ENOTINITIALIZED;
08348 
08349     list = (struct rsbac_list_lol_reg_item_t *) handle;
08350     if(list->self != list)
08351       return -RSBAC_EINVALIDVALUE;
08352 
08353 #ifdef CONFIG_RSBAC_LIST_TRANS
08354     if(ta_number)
08355       {
08356         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08357           return -RSBAC_EINVALIDTRANSACTION;
08358       }
08359 #endif
08360 
08361     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08362 /*
08363 #ifdef CONFIG_RSBAC_DEBUG
08364     if(rsbac_debug_lists)
08365       rsbac_printk(KERN_DEBUG "rsbac_list_lol_get_subdata: getting data from list %s.\n",
08366              list->name);
08367 #endif
08368 */
08369     if(subdata && !list->info.subdata_size)
08370       {
08371         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08372         return -RSBAC_EINVALIDREQUEST;
08373       }
08374 
08375     rsbac_read_lock(&list->lock, &lock_flags);
08376 
08377 #ifdef CONFIG_RSBAC_LIST_TRANS
08378     if(ta_number && (list->ta_copied == ta_number))
08379       sublist = ta_lookup_lol_item(ta_number, list, desc);
08380     else
08381 #endif
08382     sublist = lookup_lol_item(list, desc);
08383     if(sublist)
08384       { /* exists -> lookup subitem */
08385         item_p = lookup_lol_subitem(list, sublist, subdesc);
08386         if(   item_p
08387            && (   !item_p->max_age
08388                || (item_p->max_age > RSBAC_CURRENT_TIME)
08389               )
08390           )
08391           { /* exists -> copy data, if any */
08392             if(ttl_p)
08393               {
08394                 if(item_p->max_age)
08395                   *ttl_p = item_p->max_age - RSBAC_CURRENT_TIME;
08396                 else
08397                   *ttl_p = 0;
08398               }
08399             if(subdata)
08400               {
08401                 memcpy(subdata,
08402                        ((char *) item_p) + sizeof(*item_p) + list->info.subdesc_size,
08403                        list->info.subdata_size);
08404               }
08405           }
08406         else
08407           {
08408             if(!list->def_subdata)
08409               err = -RSBAC_ENOTFOUND;
08410             else
08411               {
08412                 if(ttl_p)
08413                   *ttl_p = 0;
08414                 if(subdata)
08415                   memcpy(subdata,
08416                          list->def_subdata,
08417                          list->info.subdata_size);
08418               }
08419           }
08420       }
08421     else
08422       {
08423         if(!list->def_subdata)
08424           err = -RSBAC_ENOTFOUND;
08425         else
08426           {
08427             if(ttl_p)
08428               *ttl_p = 0;
08429             if(subdata)
08430               memcpy(subdata,
08431                      list->def_subdata,
08432                      list->info.subdata_size);
08433           }
08434       }
08435     rsbac_read_unlock(&list->lock, &lock_flags);
08436     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08437     return err;
08438   }

int rsbac_ta_list_lol_remove rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 8032 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::dirty, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_touch, lookup_lol_item(), remove_lol_item(), RSBAC_EBUSY, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.

Referenced by rsbac_acl_remove_acl(), rsbac_acl_remove_acl_entry(), rsbac_acl_remove_group_member(), rsbac_acl_remove_user(), rsbac_auth_clear_f_capset(), rsbac_auth_clear_p_capset(), rsbac_list_lol_remove(), rsbac_mac_clear_f_truset(), rsbac_mac_clear_p_truset(), rsbac_pm_exists(), rsbac_pm_remove_set(), rsbac_pm_remove_target(), rsbac_rc_copy_role(), rsbac_rc_set_item(), and rsbac_um_remove_user().

08036   {
08037     struct rsbac_list_lol_reg_item_t * list;
08038     u_long lock_flags, rlock_flags;
08039 
08040     if(!handle || !desc)
08041       return -RSBAC_EINVALIDVALUE;
08042     if(!list_initialized)
08043       return -RSBAC_ENOTINITIALIZED;
08044 
08045     list = (struct rsbac_list_lol_reg_item_t *) handle;
08046     if(list->self != list)
08047       return -RSBAC_EINVALIDVALUE;
08048 
08049 #ifdef CONFIG_RSBAC_LIST_TRANS
08050     if(ta_number)
08051       {
08052         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08053           return -RSBAC_EINVALIDTRANSACTION;
08054       }
08055 #endif
08056 
08057     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08058 /*
08059 #ifdef CONFIG_RSBAC_DEBUG
08060     if(rsbac_debug_lists)
08061       rsbac_printk(KERN_DEBUG "rsbac_list_lol_remove: removing from list of lists %s.\n",
08062              list->name);
08063 #endif
08064 */
08065     rsbac_write_lock(&list->lock, &lock_flags);
08066 #ifdef CONFIG_RSBAC_LIST_TRANS
08067     if(list->ta_copied)
08068       {
08069         if(ta_number)
08070           {
08071             if(ta_lookup_lol_item(list->ta_copied, list, desc))
08072               {
08073                 if(list->ta_copied != ta_number)
08074                   {
08075                     rsbac_write_unlock(&list->lock, &lock_flags);
08076                     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08077                     return -RSBAC_EBUSY;
08078                   }
08079                 else
08080                   ta_remove_lol_item(ta_number, list, desc);
08081               }
08082           }
08083         else
08084           ta_remove_lol_item(list->ta_copied, list, desc);
08085       }
08086     else
08087       {
08088         if(ta_number && lookup_lol_item(list, desc))
08089           {
08090             ta_lol_copy(ta_number, list);
08091             ta_remove_lol_item(ta_number, list, desc);
08092           }
08093       }
08094     if(!ta_number)
08095 #endif
08096       {
08097         if(lookup_lol_item(list, desc))
08098           { /* exists -> remove */
08099             remove_lol_item(list, desc);
08100             lol_touch(list);
08101             list->dirty = TRUE;
08102           }
08103       }
08104     rsbac_write_unlock(&list->lock, &lock_flags);
08105     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08106     return 0;
08107   }

int rsbac_ta_list_lol_remove_all rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle
 

Definition at line 8123 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::dirty, rsbac_list_lol_reg_item_t::head, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_touch, NULL, remove_all_lol_items(), RSBAC_EBUSY, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.

Referenced by rsbac_list_lol_remove_all().

08124   {
08125     struct rsbac_list_lol_reg_item_t * list;
08126     u_long lock_flags, rlock_flags;
08127 
08128     if(!handle)
08129       return -RSBAC_EINVALIDVALUE;
08130     if(!list_initialized)
08131       return -RSBAC_ENOTINITIALIZED;
08132 
08133     list = (struct rsbac_list_lol_reg_item_t *) handle;
08134     if(list->self != list)
08135       return -RSBAC_EINVALIDVALUE;
08136 
08137 #ifdef CONFIG_RSBAC_LIST_TRANS
08138     if(ta_number)
08139       {
08140         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08141           return -RSBAC_EINVALIDTRANSACTION;
08142       }
08143 #endif
08144 
08145     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08146 /*
08147 #ifdef CONFIG_RSBAC_DEBUG
08148     if(rsbac_debug_lists)
08149       rsbac_printk(KERN_DEBUG "rsbac_list_lol_remove_all: removing all items from list of lists %s.\n",
08150              list->name);
08151 #endif
08152 */
08153     rsbac_write_lock(&list->lock, &lock_flags);
08154 #ifdef CONFIG_RSBAC_LIST_TRANS
08155     if(list->ta_copied)
08156       {
08157         if(ta_number)
08158           {
08159             if(list->ta_copied == ta_number)
08160               {
08161                 ta_remove_all_lol_items(list);
08162                 if(!list->head)
08163                   {
08164                     list->ta_copied = 0;
08165                   }
08166               }
08167             else
08168               {
08169                 rsbac_write_unlock(&list->lock, &lock_flags);
08170                 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08171                 return -RSBAC_EBUSY;
08172               }
08173           }
08174         else
08175           ta_remove_all_lol_items(list);
08176       }
08177     else
08178       {
08179         if(ta_number)
08180           {
08181             if(list->head)
08182               {
08183                 list->ta_head = NULL;
08184                 list->ta_tail = NULL;
08185                 list->ta_curr = NULL;
08186                 list->ta_count = 0;
08187                 list->ta_copied = ta_number;
08188               }
08189           }
08190       }
08191 
08192     if(!ta_number)
08193 #endif
08194       if(list->head)
08195         {
08196           remove_all_lol_items(list);
08197           lol_touch(list);
08198           list->dirty = TRUE;
08199         }
08200     rsbac_write_unlock(&list->lock, &lock_flags);
08201     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08202     return 0;
08203   }

int rsbac_ta_list_lol_subadd_ttl rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
rsbac_time_t  ttl,
void *  desc,
void *  subdesc,
void *  subdata
 

Definition at line 7114 of file gen_lists.c.

References add_lol_item(), add_lol_subitem(), rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_reg_item_t::def_subdata, rsbac_list_lol_reg_item_t::dirty, do_remove_lol_subitem(), rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_touch, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_item_t::max_age, rsbac_list_lol_item_t::max_age, remove_lol_item(), RSBAC_EBUSY, RSBAC_EINVALIDTARGET, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, RSBAC_LIST_MAX_AGE_LIMIT, RSBAC_LIST_TTL_KEEP, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, rsbac_list_lol_info_t::subdesc_size, and TRUE.

Referenced by rsbac_acl_add_group_member(), rsbac_acl_add_to_acl_entry(), rsbac_acl_remove_from_acl_entry(), rsbac_acl_set_acl_entry(), rsbac_auth_add_to_f_capset(), rsbac_auth_add_to_p_capset(), rsbac_list_lol_subadd(), rsbac_list_lol_subadd_ttl(), rsbac_mac_add_to_f_truset(), rsbac_mac_add_to_p_truset(), rsbac_pm_add_to_set(), rsbac_rc_copy_role(), rsbac_rc_copy_type(), rsbac_rc_set_item(), and rsbac_um_add_gm().

07121   {
07122     struct rsbac_list_lol_reg_item_t * list;
07123     struct rsbac_list_lol_item_t     * sublist;
07124     struct rsbac_list_item_t     * item_p;
07125     u_long lock_flags, rlock_flags;
07126     int err = 0;
07127 
07128     if(!handle || !desc || !subdesc)
07129       return -RSBAC_EINVALIDVALUE;
07130     if(!list_initialized)
07131       return -RSBAC_ENOTINITIALIZED;
07132 
07133     list = (struct rsbac_list_lol_reg_item_t *) handle;
07134     if(!list || (list->self != list))
07135       return -RSBAC_EINVALIDVALUE;
07136 
07137 #ifdef CONFIG_RSBAC_LIST_TRANS
07138     if(ta_number && !rsbac_ta_list_exist(0, ta_handle, &ta_number))
07139       return -RSBAC_EINVALIDTRANSACTION;
07140 #endif
07141 
07142     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07143     if(list->info.subdata_size && !subdata)
07144       {
07145         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07146         return -RSBAC_EINVALIDVALUE;
07147       }
07148 
07149 /*
07150 #ifdef CONFIG_RSBAC_DEBUG
07151     if(rsbac_debug_lists)
07152       rsbac_printk(KERN_DEBUG "rsbac_list_lol_subadd: adding to list %s.\n",
07153              list->name);
07154 #endif
07155 */
07156     rsbac_write_lock(&list->lock, &lock_flags);
07157 
07158 #ifdef CONFIG_RSBAC_LIST_TRANS
07159     if(!ta_number)
07160 #endif
07161       {
07162         sublist = lookup_lol_item(list, desc);
07163         if(   !sublist
07164            && (list->flags & RSBAC_LIST_DEF_DATA)
07165           )
07166           sublist = add_lol_item(list, 0, desc, list->def_data);
07167         if(sublist)
07168           {
07169             if(   sublist->max_age
07170                && (sublist->max_age <= RSBAC_CURRENT_TIME)
07171               )
07172               {
07173                 remove_lol_item(list, desc);
07174                 err = -RSBAC_EINVALIDTARGET;
07175               }
07176             else
07177               {
07178                 /* exists -> lookup subitem */
07179                 if(ttl && (ttl != RSBAC_LIST_TTL_KEEP))
07180                   {
07181                     if(ttl > RSBAC_LIST_MAX_AGE_LIMIT)
07182                       ttl = RSBAC_LIST_MAX_AGE_LIMIT;
07183                     ttl += RSBAC_CURRENT_TIME;
07184                   }
07185                 item_p = lookup_lol_subitem(list, sublist, subdesc);
07186                 if(item_p)
07187                   { /* exists -> update data, if any */
07188                     if(ttl != RSBAC_LIST_TTL_KEEP)
07189                       item_p->max_age = ttl;
07190                     if(subdata && list->info.subdata_size)
07191                       {
07192                         if(   list->def_subdata
07193                            && !item_p->max_age
07194                            && !memcmp(list->def_subdata, subdata, list->info.subdata_size)
07195                           )
07196                           do_remove_lol_subitem(sublist, item_p);
07197                         else
07198                           memcpy(((char *) item_p) + sizeof(*item_p) + list->info.subdesc_size,
07199                                  subdata,
07200                                  list->info.subdata_size);
07201                       }
07202                   }
07203                 else
07204                   {
07205                     if(ttl == RSBAC_LIST_TTL_KEEP)
07206                       ttl = 0;
07207                     if(   !list->def_subdata
07208                        || memcmp(list->def_subdata, subdata, list->info.subdata_size)
07209                       )
07210                       add_lol_subitem(list, sublist, ttl, subdesc, subdata);
07211                   }
07212                 lol_touch(list);
07213                 list->dirty = TRUE;
07214               }
07215           }
07216         else
07217           {
07218             err = -RSBAC_EINVALIDTARGET;
07219             goto out_unlock;
07220           }
07221       }
07222 #ifdef CONFIG_RSBAC_LIST_TRANS
07223     if(list->ta_copied || ta_number)
07224       {
07225         if(!list->ta_copied)
07226           {
07227             if((err = ta_lol_copy(ta_number,list)))
07228               goto out_unlock;
07229           }
07230         else
07231           if(ta_number)
07232             {
07233               if(list->ta_copied != ta_number)
07234                 {
07235                   err = -RSBAC_EBUSY;
07236                   goto out_unlock;
07237                 }
07238             }
07239           else
07240             ta_number = list->ta_copied;
07241         sublist = ta_lookup_lol_item(ta_number, list, desc);
07242         if(   !sublist
07243            && (list->flags & RSBAC_LIST_DEF_DATA)
07244           )
07245           sublist = ta_add_lol_item(ta_number, list, 0, desc, list->def_data);
07246         if(sublist)
07247           {
07248             if(   sublist->max_age
07249                && (sublist->max_age <= RSBAC_CURRENT_TIME)
07250               )
07251               {
07252                 ta_remove_lol_item(ta_number, list, desc);
07253                 err = -RSBAC_EINVALIDTARGET;
07254               }
07255             else
07256               {
07257                 /* exists -> lookup subitem */
07258                 if(ttl && (ttl != RSBAC_LIST_TTL_KEEP))
07259                   {
07260                     if(ttl > RSBAC_LIST_MAX_AGE_LIMIT)
07261                       ttl = RSBAC_LIST_MAX_AGE_LIMIT;
07262                     ttl += RSBAC_CURRENT_TIME;
07263                   }
07264                 item_p = lookup_lol_subitem(list, sublist, subdesc);
07265                 if(item_p)
07266                   { /* exists -> update data, if any */
07267                     if(ttl != RSBAC_LIST_TTL_KEEP)
07268                       item_p->max_age = ttl;
07269                     if(subdata && list->info.subdata_size)
07270                       {
07271                         if(   list->def_subdata
07272                            && !item_p->max_age
07273                            && !memcmp(list->def_subdata, subdata, list->info.subdata_size)
07274                           )
07275                           do_remove_lol_subitem(sublist, item_p);
07276                         else
07277                           memcpy(((char *) item_p) + sizeof(*item_p) + list->info.subdesc_size,
07278                                  subdata,
07279                                  list->info.subdata_size);
07280                       }
07281                   }
07282                 else
07283                   {
07284                     if(ttl == RSBAC_LIST_TTL_KEEP)
07285                       ttl = 0;
07286                     if(   !list->def_subdata
07287                        || memcmp(list->def_subdata, subdata, list->info.subdata_size)
07288                       )
07289                       add_lol_subitem(list, sublist, ttl, subdesc, subdata);
07290                   }
07291               }
07292           }
07293         else
07294           {
07295             err = -RSBAC_EINVALIDTARGET;
07296           }
07297       }
07298 #endif
07299 
07300 out_unlock:
07301     rsbac_write_unlock(&list->lock, &lock_flags);
07302     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07303     return err;
07304   }

long rsbac_ta_list_lol_subcount rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 9320 of file gen_lists.c.

References rsbac_list_lol_item_t::count, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_item(), RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_acl_remove_acl_entry(), rsbac_acl_remove_group_member(), rsbac_list_lol_subcount(), rsbac_rc_get_list(), and rsbac_um_get_gm_list().

09324   {
09325     struct rsbac_list_lol_reg_item_t * list;
09326     struct rsbac_list_lol_item_t     * sublist;
09327     u_long lock_flags, rlock_flags;
09328     long result;
09329 
09330     if(!handle)
09331       return -RSBAC_EINVALIDVALUE;
09332     if(!list_initialized)
09333       return -RSBAC_ENOTINITIALIZED;
09334 
09335     list = (struct rsbac_list_lol_reg_item_t *) handle;
09336     if(list->self != list)
09337       return -RSBAC_EINVALIDVALUE;
09338 
09339 #ifdef CONFIG_RSBAC_LIST_TRANS
09340     if(ta_number)
09341       {
09342         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09343           return -RSBAC_EINVALIDTRANSACTION;
09344       }
09345 #endif
09346 
09347     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09348 /*
09349 #ifdef CONFIG_RSBAC_DEBUG
09350     if(rsbac_debug_lists)
09351       rsbac_printk(KERN_DEBUG "rsbac_list_lol_subcount: list %s.\n",
09352              list->name);
09353 #endif
09354 */
09355     rsbac_read_lock(&list->lock, &lock_flags);
09356 
09357 #ifdef CONFIG_RSBAC_LIST_TRANS
09358     if(ta_number && (list->ta_copied == ta_number))
09359       sublist = ta_lookup_lol_item(ta_number, list, desc);
09360     else
09361 #endif
09362     sublist = lookup_lol_item(list, desc);
09363     if(sublist)
09364       {
09365         result = sublist->count;
09366       }
09367     else
09368       {
09369         result = -RSBAC_ENOTFOUND;
09370       }
09371     rsbac_read_unlock(&list->lock, &lock_flags);
09372     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09373     return result;
09374   }

int rsbac_ta_list_lol_subexist rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc
 

Definition at line 9071 of file gen_lists.c.

References FALSE, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_item_t::max_age, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.

Referenced by rsbac_acl_group_member(), rsbac_list_lol_subexist(), rsbac_pm_set_member(), and rsbac_um_get_gm_user_list().

09076   {
09077     struct rsbac_list_lol_reg_item_t * list;
09078     struct rsbac_list_lol_item_t     * sublist;
09079     u_long lock_flags, rlock_flags;
09080     struct rsbac_list_item_t     * item_p;
09081     int result;
09082 
09083     if(!handle || !desc || !subdesc)
09084       return FALSE;
09085     if(!list_initialized)
09086       return FALSE;
09087 
09088     list = (struct rsbac_list_lol_reg_item_t *) handle;
09089     if(list->self != list)
09090       return -RSBAC_EINVALIDVALUE;
09091 
09092 #ifdef CONFIG_RSBAC_LIST_TRANS
09093     if(ta_number)
09094       {
09095         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09096           return -RSBAC_EINVALIDTRANSACTION;
09097       }
09098 #endif
09099 
09100     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09101 /*
09102 #ifdef CONFIG_RSBAC_DEBUG
09103     if(rsbac_debug_lists)
09104       rsbac_printk(KERN_DEBUG "rsbac_list_lol_subexist: testing on list %s.\n",
09105              list->name);
09106 #endif
09107 */
09108     rsbac_read_lock(&list->lock, &lock_flags);
09109 
09110 #ifdef CONFIG_RSBAC_LIST_TRANS
09111     if(ta_number && (list->ta_copied == ta_number))
09112       sublist = ta_lookup_lol_item(ta_number, list, desc);
09113     else
09114 #endif
09115     sublist = lookup_lol_item(list, desc);
09116     if(sublist)
09117       { /* exists -> lookup subitem */
09118         item_p = lookup_lol_subitem(list, sublist, subdesc);
09119         if(   item_p
09120            && (   !item_p->max_age
09121                || (item_p->max_age > RSBAC_CURRENT_TIME)
09122               )
09123           )
09124           { /* exists -> TRUE */
09125             result = TRUE;
09126           }
09127         else
09128           {
09129             result = FALSE;
09130           }
09131       }
09132     else
09133       {
09134         result = FALSE;
09135       }
09136     rsbac_read_unlock(&list->lock, &lock_flags);
09137     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09138     return result;
09139   }

int rsbac_ta_list_lol_subexist_compare rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc,
rsbac_list_compare_function_t  compare
 

Definition at line 9155 of file gen_lists.c.

References FALSE, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lookup_lol_item(), lookup_lol_subitem_user_compare(), rsbac_list_item_t::max_age, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, rsbac_list_lol_subexist(), rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.

Referenced by rsbac_list_lol_subexist_compare().

09161   {
09162     struct rsbac_list_lol_reg_item_t * list;
09163     struct rsbac_list_lol_item_t     * sublist;
09164     u_long lock_flags, rlock_flags;
09165     struct rsbac_list_item_t     * item_p;
09166     int result;
09167 
09168     if(!handle || !desc || !subdesc)
09169       return FALSE;
09170     if(!list_initialized)
09171       return FALSE;
09172     /* Use standard function, if compare is not provided. */
09173     if(!compare)
09174       return rsbac_list_lol_subexist(handle, desc, subdesc);
09175 
09176     list = (struct rsbac_list_lol_reg_item_t *) handle;
09177     if(list->self != list)
09178       return -RSBAC_EINVALIDVALUE;
09179 
09180 #ifdef CONFIG_RSBAC_LIST_TRANS
09181     if(ta_number)
09182       {
09183         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09184           return -RSBAC_EINVALIDTRANSACTION;
09185       }
09186 #endif
09187 
09188     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09189 /*
09190 #ifdef CONFIG_RSBAC_DEBUG
09191     if(rsbac_debug_lists)
09192       rsbac_printk(KERN_DEBUG "rsbac_list_lol_subexist_compare: testing on list %s.\n",
09193              list->name);
09194 #endif
09195 */
09196     rsbac_read_lock(&list->lock, &lock_flags);
09197 
09198 #ifdef CONFIG_RSBAC_LIST_TRANS
09199     if(ta_number && (list->ta_copied == ta_number))
09200       sublist = ta_lookup_lol_item(ta_number, list, desc);
09201     else
09202 #endif
09203     sublist = lookup_lol_item(list, desc);
09204     if(sublist)
09205       { /* exists -> lookup subitem */
09206         item_p = lookup_lol_subitem_user_compare(list, sublist, subdesc, compare);
09207         if(   item_p
09208            && (   !item_p->max_age
09209                || (item_p->max_age > RSBAC_CURRENT_TIME)
09210               )
09211           )
09212           { /* exists -> TRUE */
09213             result = TRUE;
09214           }
09215         else
09216           {
09217             result = FALSE;
09218           }
09219       }
09220     else
09221       {
09222         result = FALSE;
09223       }
09224     rsbac_read_unlock(&list->lock, &lock_flags);
09225     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09226     return result;
09227   }

int rsbac_ta_list_lol_subremove rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc
 

Definition at line 7680 of file gen_lists.c.

References rsbac_list_lol_item_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::dirty, do_remove_lol_item(), rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_touch, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_lol_item_t::max_age, remove_lol_subitem(), RSBAC_EBUSY, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.

Referenced by rsbac_acl_remove_acl_entry(), rsbac_acl_remove_group_member(), rsbac_auth_remove_from_f_capset(), rsbac_auth_remove_from_p_capset(), rsbac_list_lol_subremove(), rsbac_mac_remove_from_f_truset(), rsbac_mac_remove_from_p_truset(), rsbac_pm_remove_from_set(), rsbac_rc_set_item(), and rsbac_um_remove_gm().

07685   {
07686     struct rsbac_list_lol_reg_item_t * list;
07687     struct rsbac_list_lol_item_t     * sublist;
07688     u_long lock_flags, rlock_flags;
07689 
07690     if(!handle || !desc || !subdesc)
07691       return -RSBAC_EINVALIDVALUE;
07692     if(!list_initialized)
07693       return -RSBAC_ENOTINITIALIZED;
07694 
07695     list = (struct rsbac_list_lol_reg_item_t *) handle;
07696     if(list->self != list)
07697       return -RSBAC_EINVALIDVALUE;
07698 
07699 #ifdef CONFIG_RSBAC_LIST_TRANS
07700     if(ta_number)
07701       {
07702         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07703           return -RSBAC_EINVALIDTRANSACTION;
07704       }
07705 #endif
07706 
07707     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07708 /*
07709 #ifdef CONFIG_RSBAC_DEBUG
07710     if(rsbac_debug_lists)
07711       rsbac_printk(KERN_DEBUG "rsbac_ta_list_lol_subremove: removing from list of lists %s, device %02u:%02u.\n",
07712              list->name,
07713              RSBAC_MAJOR(list->device), RSBAC_MINOR(list->device));
07714 #endif
07715 */
07716     rsbac_write_lock(&list->lock, &lock_flags);
07717 #ifdef CONFIG_RSBAC_LIST_TRANS
07718     if(list->ta_copied)
07719       {
07720         sublist = ta_lookup_lol_item(list->ta_copied, list, desc);
07721         if(sublist)
07722           {
07723             if(   sublist->max_age
07724                && (sublist->max_age <= RSBAC_CURRENT_TIME)
07725               )
07726               {
07727                 ta_do_remove_lol_item(list, sublist);
07728               }
07729             else
07730               {
07731                 if(ta_number && (list->ta_copied != ta_number))
07732                   {
07733                     rsbac_write_unlock(&list->lock, &lock_flags);
07734                     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07735                     return -RSBAC_EBUSY;
07736                   }
07737                 if(lookup_lol_subitem(list, sublist, subdesc))
07738                   remove_lol_subitem(list, sublist, subdesc);
07739                 if(   !sublist->count
07740                    && (   (   list->def_data
07741                            && !memcmp(((char *) sublist) + sizeof(*sublist) + list->info.desc_size,
07742                                       list->def_data,
07743                                       list->info.data_size)
07744                           )
07745                        || (   !list->info.data_size
07746                            && (list->flags & RSBAC_LIST_DEF_DATA)
07747                           )
07748                       )
07749                       )
07750                   {
07751                     ta_do_remove_lol_item(list, sublist);
07752                   }
07753               }
07754           }
07755       }
07756     else
07757       {
07758         if(ta_number && lookup_lol_item(list, desc))
07759           {
07760             ta_lol_copy(ta_number, list);
07761             ta_remove_lol_item(ta_number, list, desc);
07762           }
07763       }
07764     if(!ta_number)
07765 #endif
07766       {
07767         sublist = lookup_lol_item(list, desc);
07768         if(sublist)
07769           {
07770             if(   sublist->max_age
07771                && (sublist->max_age <= RSBAC_CURRENT_TIME)
07772               )
07773               {
07774                 do_remove_lol_item(list, sublist);
07775                 lol_touch(list);
07776                 list->dirty = TRUE;
07777               }
07778             else
07779               {
07780                 if(lookup_lol_subitem(list, sublist, subdesc))
07781                   { /* exists -> remove and set dirty */
07782                     remove_lol_subitem(list, sublist, subdesc);
07783                     lol_touch(list);
07784                     list->dirty = TRUE;
07785                   }
07786                 if(   !sublist->count
07787                    && (   (   list->def_data
07788                            && !memcmp(((char *) sublist) + sizeof(*sublist) + list->info.desc_size,
07789                                       list->def_data,
07790                                       list->info.data_size)
07791                           )
07792                        || (   !list->info.data_size
07793                            && (list->flags & RSBAC_LIST_DEF_DATA)
07794                           )
07795                       )
07796                   )
07797                   {
07798                     do_remove_lol_item(list, sublist);
07799                     lol_touch(list);
07800                     list->dirty = TRUE;
07801                   }
07802               }
07803           }
07804       }
07805     rsbac_write_unlock(&list->lock, &lock_flags);
07806     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07807     return 0;
07808   }

int rsbac_ta_list_lol_subremove_all rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 7923 of file gen_lists.c.

References rsbac_list_lol_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::dirty, rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_touch, lookup_lol_item(), rsbac_list_lol_item_t::max_age, remove_all_lol_subitems(), RSBAC_EBUSY, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.

Referenced by rsbac_list_lol_subremove_all(), and rsbac_pm_clear_set().

07927   {
07928     struct rsbac_list_lol_reg_item_t * list;
07929     struct rsbac_list_lol_item_t     * sublist;
07930     u_long lock_flags, rlock_flags;
07931 
07932     if(!handle)
07933       return -RSBAC_EINVALIDVALUE;
07934     if(!list_initialized)
07935       return -RSBAC_ENOTINITIALIZED;
07936 
07937     list = (struct rsbac_list_lol_reg_item_t *) handle;
07938     if(list->self != list)
07939       return -RSBAC_EINVALIDVALUE;
07940 
07941 #ifdef CONFIG_RSBAC_LIST_TRANS
07942     if(ta_number)
07943       {
07944         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07945           return -RSBAC_EINVALIDTRANSACTION;
07946       }
07947 #endif
07948 
07949     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07950 /*
07951 #ifdef CONFIG_RSBAC_DEBUG
07952     if(rsbac_debug_lists)
07953       rsbac_printk(KERN_DEBUG "rsbac_list_lol_subremove_all: removing all subitems from list of lists %s.\n",
07954              list->name);
07955 #endif
07956 */
07957     rsbac_write_lock(&list->lock, &lock_flags);
07958 #ifdef CONFIG_RSBAC_LIST_TRANS
07959     if(list->ta_copied)
07960       {
07961         sublist = ta_lookup_lol_item(list->ta_copied, list, desc);
07962         if(sublist)
07963           {
07964             if(   sublist->max_age
07965                && (sublist->max_age <= RSBAC_CURRENT_TIME)
07966               )
07967               {
07968                 ta_do_remove_lol_item(list, sublist);
07969               }
07970             else
07971               {
07972                 if(ta_number && (list->ta_copied != ta_number))
07973                   {
07974                     rsbac_write_unlock(&list->lock, &lock_flags);
07975                     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07976                     return -RSBAC_EBUSY;
07977                   }
07978                 remove_all_lol_subitems(sublist);
07979                 if(   (   list->def_data
07980                        && !memcmp(((char *) sublist) + sizeof(*sublist) + list->info.desc_size,
07981                                   list->def_data,
07982                                   list->info.data_size)
07983                       )
07984                    || (   !list->info.data_size
07985                        && (list->flags & RSBAC_LIST_DEF_DATA)
07986                       )
07987                    
07988                   )
07989                   {
07990                     ta_do_remove_lol_item(list, sublist);
07991                   }
07992               }
07993           }
07994       }
07995     else
07996       {
07997         if(ta_number && lookup_lol_item(list, desc))
07998           {
07999             ta_lol_copy(ta_number, list);
08000             sublist = ta_lookup_lol_item(ta_number, list, desc);
08001             if(sublist)
08002               remove_all_lol_subitems(sublist);
08003           }
08004       }
08005     if(!ta_number)
08006 #endif
08007       {
08008         sublist = lookup_lol_item(list, desc);
08009         if(sublist && sublist->head)
08010           {
08011             remove_all_lol_subitems(sublist);
08012             lol_touch(list);
08013             list->dirty = TRUE;
08014           }
08015       }
08016     rsbac_write_unlock(&list->lock, &lock_flags);
08017     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08018     return 0;
08019   }

int rsbac_ta_list_lol_subremove_from_all rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  subdesc
 

Definition at line 7825 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::dirty, rsbac_list_lol_reg_item_t::head, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_touch, lookup_lol_subitem(), rsbac_list_lol_item_t::next, remove_lol_subitem(), RSBAC_EBUSY, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.

Referenced by rsbac_acl_remove_group(), rsbac_acl_remove_subject(), rsbac_acl_remove_user(), rsbac_list_lol_subremove_from_all(), rsbac_rc_copy_type(), rsbac_rc_set_item(), and rsbac_um_remove_group().

07829   {
07830     struct rsbac_list_lol_reg_item_t * list;
07831     struct rsbac_list_lol_item_t     * sublist;
07832     u_long lock_flags, rlock_flags;
07833 
07834     if(!handle || !subdesc)
07835       return -RSBAC_EINVALIDVALUE;
07836     if(!list_initialized)
07837       return -RSBAC_ENOTINITIALIZED;
07838 
07839     list = (struct rsbac_list_lol_reg_item_t *) handle;
07840     if(list->self != list)
07841       return -RSBAC_EINVALIDVALUE;
07842 
07843 #ifdef CONFIG_RSBAC_LIST_TRANS
07844     if(ta_number)
07845       {
07846         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07847           return -RSBAC_EINVALIDTRANSACTION;
07848       }
07849 #endif
07850 
07851     rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07852 /*
07853 #ifdef CONFIG_RSBAC_DEBUG
07854     if(rsbac_debug_lists)
07855       rsbac_printk(KERN_DEBUG "rsbac_list_lol_subremove_from_all: removing from list of lists %s.\n",
07856              list->name);
07857 #endif
07858 */
07859     rsbac_write_lock(&list->lock, &lock_flags);
07860 #ifdef CONFIG_RSBAC_LIST_TRANS
07861     if(list->ta_copied)
07862       {
07863         if(ta_number && (list->ta_copied != ta_number))
07864           {
07865             rsbac_write_unlock(&list->lock, &lock_flags);
07866             rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07867             return -RSBAC_EBUSY;
07868           }
07869         sublist = list->head;
07870         while(sublist)
07871           {
07872             remove_lol_subitem(list, sublist, subdesc);
07873             sublist = sublist->next;
07874           }
07875       }
07876     else
07877       {
07878         if(ta_number)
07879           {
07880             ta_lol_copy(ta_number, list);
07881             sublist = list->head;
07882             while(sublist)
07883               {
07884                 remove_lol_subitem(list, sublist, subdesc);
07885                 sublist = sublist->next;
07886               }
07887           }
07888       }
07889     if(!ta_number)
07890 #endif
07891       {
07892         sublist = list->head;
07893         while(sublist)
07894           {
07895             if(lookup_lol_subitem(list, sublist, subdesc))
07896               { /* exists -> remove and set dirty */
07897                 remove_lol_subitem(list, sublist, subdesc);
07898                 lol_touch(list);
07899                 list->dirty = TRUE;
07900               }
07901             sublist = sublist->next;
07902           }
07903       }
07904     rsbac_write_unlock(&list->lock, &lock_flags);
07905     rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07906     return 0;
07907   }

int rsbac_ta_list_remove rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc
 

Definition at line 7496 of file gen_lists.c.

References rsbac_list_reg_item_t::dirty, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, lookup_item(), remove_item(), RSBAC_EBUSY, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_reg_item_t::self, touch, and TRUE.

Referenced by rsbac_acl_remove_acl_entry(), rsbac_acl_remove_group(), rsbac_acl_remove_subject(), rsbac_acl_remove_user(), rsbac_list_remove(), rsbac_pm_exists(), rsbac_pm_remove_target(), rsbac_rc_set_item(), rsbac_ta_remove_target(), rsbac_um_remove_group(), set_attr_fd(), and set_attr_user().

07500   {
07501     struct rsbac_list_reg_item_t * list;
07502     u_long lock_flags, rlock_flags;
07503 
07504     if(!handle || !desc)
07505       return -RSBAC_EINVALIDVALUE;
07506     if(!list_initialized)
07507       return -RSBAC_ENOTINITIALIZED;
07508 
07509     list = (struct rsbac_list_reg_item_t *) handle;
07510     if(!list || (list->self != list))
07511       return -RSBAC_EINVALIDVALUE;
07512 
07513 #ifdef CONFIG_RSBAC_LIST_TRANS
07514     if(ta_number)
07515       {
07516         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07517           return -RSBAC_EINVALIDTRANSACTION;
07518       }
07519 #endif
07520 
07521     rsbac_read_lock(&reg_head.lock, &rlock_flags);
07522 /*
07523 #ifdef CONFIG_RSBAC_DEBUG
07524     if(rsbac_debug_lists)
07525       rsbac_printk(KERN_DEBUG "rsbac_list_ta_remove: removing from list %s.\n",
07526              list->name);
07527 #endif
07528 */
07529     rsbac_write_lock(&list->lock, &lock_flags);
07530 #ifdef CONFIG_RSBAC_LIST_TRANS
07531     if(list->ta_copied)
07532       {
07533         if(ta_number)
07534           {
07535             if(ta_lookup_item(list->ta_copied, list, desc))
07536               {
07537                 if(list->ta_copied != ta_number)
07538                   {
07539                     rsbac_write_unlock(&list->lock, &lock_flags);
07540                     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
07541                     return -RSBAC_EBUSY;
07542                   }
07543                 else
07544                   ta_remove_item(ta_number, list, desc);
07545               }
07546           }
07547         else
07548           ta_remove_item(list->ta_copied, list, desc);
07549       }
07550     else
07551       {
07552         if(ta_number && lookup_item(list, desc))
07553           {
07554             ta_copy(ta_number, list);
07555             ta_remove_item(ta_number, list, desc);
07556           }
07557       }
07558     if(!ta_number)
07559 #endif
07560       {
07561         if(lookup_item(list, desc))
07562           { /* exists -> remove */
07563             remove_item(list, desc);
07564             touch(list);
07565             list->dirty = TRUE;
07566           }
07567       }
07568     rsbac_write_unlock(&list->lock, &lock_flags);
07569     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
07570     return 0;
07571   }

int rsbac_ta_list_remove_all rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle
 

Definition at line 7587 of file gen_lists.c.

References rsbac_list_reg_item_t::dirty, rsbac_list_reg_item_t::head, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, NULL, remove_all_items(), RSBAC_EBUSY, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_reg_item_t::self, touch, and TRUE.

Referenced by rsbac_list_remove_all().

07588   {
07589     struct rsbac_list_reg_item_t * list;
07590     u_long lock_flags, rlock_flags;
07591 
07592     if(!handle)
07593       return -RSBAC_EINVALIDVALUE;
07594     if(!list_initialized)
07595       return -RSBAC_ENOTINITIALIZED;
07596 
07597     list = (struct rsbac_list_reg_item_t *) handle;
07598     if(list->self != list)
07599       return -RSBAC_EINVALIDVALUE;
07600 
07601 #ifdef CONFIG_RSBAC_LIST_TRANS
07602     if(ta_number)
07603       {
07604         if(!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07605           return -RSBAC_EINVALIDTRANSACTION;
07606       }
07607 #endif
07608 
07609     rsbac_read_lock(&reg_head.lock, &rlock_flags);
07610 /*
07611 #ifdef CONFIG_RSBAC_DEBUG
07612     if(rsbac_debug_lists)
07613       rsbac_printk(KERN_DEBUG "rsbac_ta_list_remove_all: removing all items from list %s.\n",
07614              list->name);
07615 #endif
07616 */
07617     rsbac_write_lock(&list->lock, &lock_flags);
07618 #ifdef CONFIG_RSBAC_LIST_TRANS
07619     if(list->ta_copied)
07620       {
07621         if(ta_number)
07622           {
07623             if(list->ta_copied == ta_number)
07624               {
07625                 ta_remove_all_items(list);
07626                 if(!list->head)
07627                   {
07628                     list->ta_copied = 0;
07629                   }
07630               }
07631             else
07632               {
07633                 rsbac_write_unlock(&list->lock, &lock_flags);
07634                 rsbac_read_unlock(&reg_head.lock, &rlock_flags);
07635                 return -RSBAC_EBUSY;
07636               }
07637           }
07638         else
07639           ta_remove_all_items(list);
07640       }
07641     else
07642       {
07643         if(ta_number)
07644           {
07645             if(list->head)
07646               {
07647                 list->ta_head = NULL;
07648                 list->ta_tail = NULL;
07649                 list->ta_curr = NULL;
07650                 list->ta_count = 0;
07651                 list->ta_copied = ta_number;
07652               }
07653           }
07654       }
07655 
07656     if(!ta_number)
07657 #endif
07658       if(list->head)
07659         {
07660           remove_all_items(list);
07661           touch(list);
07662           list->dirty = TRUE;
07663         }
07664     rsbac_write_unlock(&list->lock, &lock_flags);
07665     rsbac_read_unlock(&reg_head.lock, &rlock_flags);
07666     return 0;
07667   }


Generated on Sun May 21 14:30:58 2006 for RSBAC by  doxygen 1.4.2