/linux-2.6.21.1-rsbac-1.3.4/include/rsbac/lists.h File Reference

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

Go to the source code of this file.

Data Structures

struct  rsbac_list_info_t
struct  rsbac_list_lol_info_t

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   (8192 - 64)
#define RSBAC_LIST_MIN_MAX_HASHES   8
#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
#define RSBAC_LIST_REPLICATE   128
#define RSBAC_LIST_AUTO_HASH_RESIZE   256
#define RSBAC_LIST_NO_MAX   512
#define RSBAC_LIST_NO_MAX_WARN   1024

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)
typedef u_int rsbac_list_hash_function_t (void *desc, __u32 nr_hashes)

Functions

u_int rsbac_list_hash_u32 (void *desc, __u32 nr_hashes)
u_int rsbac_list_hash_fd (void *desc, __u32 nr_hashes)
u_int rsbac_list_hash_pid (void *desc, __u32 nr_hashes)
u_int rsbac_list_hash_uid (void *desc, __u32 nr_hashes)
u_int rsbac_list_hash_gid (void *desc, __u32 nr_hashes)
u_int rsbac_list_hash_ipc (void *desc, __u32 nr_hashes)
u_int rsbac_list_hash_dev (void *desc, __u32 nr_hashes)
u_int rsbac_list_hash_nettemp (void *desc, __u32 nr_hashes)
u_int rsbac_list_hash_netobj (void *desc, __u32 nr_hashes)
int rsbac_list_compare_u32 (void *desc1, void *desc2)
rsbac_version_t rsbac_list_version (void)
int rsbac_list_register_hashed (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, u_int nr_hashes, rsbac_list_hash_function_t hash_function, char *old_base_name)
int rsbac_list_lol_register_hashed (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, u_int nr_hashes, rsbac_list_hash_function_t hash_function, char *old_base_name)
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_max_items (rsbac_list_handle_t handle, rsbac_list_key_t key, u_int max_items)
int rsbac_list_lol_max_items (rsbac_list_handle_t handle, rsbac_list_key_t key, u_int max_items, u_int max_subitems)
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_ta_list_add_ttl (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, rsbac_time_t ttl, void *desc, void *data)
static int rsbac_list_add_ttl (rsbac_list_handle_t handle, rsbac_time_t ttl, void *desc, void *data)
static int rsbac_list_add (rsbac_list_handle_t handle, 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)
static int rsbac_list_lol_subadd_ttl (rsbac_list_handle_t handle, rsbac_time_t ttl, void *desc, void *subdesc, void *subdata)
static int rsbac_list_lol_subadd (rsbac_list_handle_t handle, void *desc, void *subdesc, void *subdata)
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)
static int rsbac_list_lol_add_ttl (rsbac_list_handle_t handle, rsbac_time_t ttl, void *desc, void *data)
static int rsbac_list_lol_add (rsbac_list_handle_t handle, void *desc, void *data)
int rsbac_ta_list_remove (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc)
static 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)
static 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)
static int rsbac_list_lol_subremove (rsbac_list_handle_t handle, void *desc, void *subdesc)
int rsbac_ta_list_lol_subremove_count (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc, u_long count)
int rsbac_ta_list_lol_subremove_from_all (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *subdesc)
static 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)
static 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)
static 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)
static int rsbac_list_lol_remove_all (rsbac_list_handle_t handle)
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)
static int rsbac_list_get_data_ttl (rsbac_list_handle_t handle, rsbac_time_t *ttl_p, void *desc, void *data)
static int rsbac_list_get_data (rsbac_list_handle_t handle, void *desc, void *data)
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)
static int rsbac_list_lol_get_subdata_ttl (rsbac_list_handle_t handle, rsbac_time_t *ttl_p, void *desc, void *subdesc, void *subdata)
static int rsbac_list_lol_get_subdata (rsbac_list_handle_t handle, void *desc, void *subdesc, void *subdata)
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)
static int rsbac_list_lol_get_data_ttl (rsbac_list_handle_t handle, rsbac_time_t *ttl_p, void *desc, void *data)
static int rsbac_list_lol_get_data (rsbac_list_handle_t handle, 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)
static 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)
static 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)
static int rsbac_list_get_max_desc (rsbac_list_handle_t handle, void *desc)
int rsbac_ta_list_lol_get_max_subdesc (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t handle, void *desc, void *subdesc)
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)
static 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)
static 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)
static 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)
static 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)
static 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)
static 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)
static 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)
static 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)
static 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)
static 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)
static long rsbac_list_get_all_desc (rsbac_list_handle_t handle, 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)
static long rsbac_list_lol_get_all_subdesc (rsbac_list_handle_t handle, void *desc, void **array_p)
static 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)
static 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)
static 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)
static 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)
static 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_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)
static long rsbac_list_get_all_items_ttl (rsbac_list_handle_t handle, void **array_p, rsbac_time_t **ttl_array_p)
static long rsbac_list_get_all_items (rsbac_list_handle_t handle, 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)
static long rsbac_list_lol_get_all_subitems_ttl (rsbac_list_handle_t handle, void *desc, void **array_p, rsbac_time_t **ttl_array_p)
static long rsbac_list_lol_get_all_subitems (rsbac_list_handle_t handle, void *desc, void **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)
static long rsbac_list_lol_get_all_items (rsbac_list_handle_t handle, void **array_p)
long rsbac_list_copy (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t from_handle, rsbac_list_handle_t to_handle)
long rsbac_list_lol_copy (rsbac_list_ta_number_t ta_number, rsbac_list_handle_t from_handle, rsbac_list_handle_t to_handle)
long rsbac_list_get_nr_hashes (rsbac_list_handle_t handle)
long rsbac_list_lol_get_nr_hashes (rsbac_list_handle_t handle)


Define Documentation

#define RSBAC_LIST_AUTO_HASH_RESIZE   256

Definition at line 83 of file lists.h.

Referenced by acl_register_fd_lists(), auth_register_fd_lists(), register_dev_lists(), register_fd_lists(), register_ipc_lists(), register_process_lists(), register_user_lists1(), register_user_lists2(), rsbac_init_acl(), rsbac_init_auth(), rsbac_init_rc(), rsbac_init_um(), rsbac_list_auto_rehash(), rsbac_list_lol_register_hashed(), and rsbac_list_register_hashed().

#define RSBAC_LIST_BACKUP   16

Definition at line 64 of file lists.h.

Referenced by init_module(), register_dev_lists(), register_user_lists1(), register_user_lists2(), 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_hashed(), and rsbac_list_register_hashed().

#define RSBAC_LIST_DEF_DATA   32

Definition at line 70 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_lists1(), register_user_lists2(), rsbac_init_acl(), rsbac_init_auth(), rsbac_init_debug(), rsbac_init_mac(), rsbac_init_rc(), rsbac_init_um(), rsbac_list_lol_check(), rsbac_ta_list_lol_get_max_subdesc(), rsbac_ta_list_lol_subadd_ttl(), rsbac_ta_list_lol_subremove(), rsbac_ta_list_lol_subremove_all(), and rsbac_ta_list_lol_subremove_count().

#define RSBAC_LIST_DEF_SUBDATA   64

Definition at line 75 of file lists.h.

Referenced by create_lol_reg(), and rsbac_init_rc().

#define RSBAC_LIST_IGNORE_OLD   2

Definition at line 52 of file lists.h.

Referenced by do_read_list(), and do_read_lol_list().

#define RSBAC_LIST_IGNORE_UNSUPP_VERSION   4

Definition at line 58 of file lists.h.

Referenced by do_read_list(), and do_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_hashed(), rsbac_list_register_hashed(), 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   (8192 - 64)

Definition at line 30 of file lists.h.

Referenced by rsbac_list_lol_register_hashed(), and rsbac_list_register_hashed().

#define RSBAC_LIST_MIN_MAX_HASHES   8

Definition at line 32 of file lists.h.

Referenced by register_process_lists(), rsbac_init_auth(), and rsbac_list_init().

#define RSBAC_LIST_NO_MAX   512

Definition at line 86 of file lists.h.

Referenced by create_lol_reg(), create_reg(), read_list(), read_lol_list(), and register_fd_lists().

#define RSBAC_LIST_NO_MAX_WARN   1024

Definition at line 89 of file lists.h.

Referenced by add_item(), add_lol_item(), and add_lol_subitem().

#define RSBAC_LIST_NO_WRITE   8

Definition at line 61 of file lists.h.

Referenced by create_lol_reg(), and create_reg().

#define RSBAC_LIST_PERSIST   1

Definition at line 49 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_lists1(), register_user_lists2(), rsbac_init_acl(), rsbac_init_debug(), rsbac_init_pm(), rsbac_init_rc(), and rsbac_init_um().

#define RSBAC_LIST_REPLICATE   128

Definition at line 79 of file lists.h.

Referenced by rsbac_init_rc(), and rsbac_init_um().

#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_lists1(), register_user_lists2(), 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_hashed(), rsbac_list_register_hashed(), and rsbac_list_version().


Typedef Documentation

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

Definition at line 100 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 115 of file lists.h.

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

Definition at line 110 of file lists.h.

typedef rsbac_list_conv_function_t* rsbac_list_get_conv_t(rsbac_version_t old_version)

Definition at line 122 of file lists.h.

typedef void* rsbac_list_handle_t

Definition at line 20 of file lists.h.

typedef u_int rsbac_list_hash_function_t(void *desc, __u32 nr_hashes)

Definition at line 126 of file lists.h.

typedef __u32 rsbac_list_key_t

Definition at line 21 of file lists.h.


Function Documentation

static int rsbac_list_add ( rsbac_list_handle_t  handle,
void *  desc,
void *  data 
) [inline, static]

Definition at line 324 of file lists.h.

References RSBAC_LIST_TTL_KEEP, and rsbac_ta_list_add_ttl().

Referenced by acl_create_def(), acl_create_def2(), create_def_roles(), create_def_roles2(), need_overwrite_func(), register_user_lists1(), register_user_lists2(), request_func(), rsbac_adf_log_switch(), rsbac_do_init(), rsbac_init(), rsbac_init_rc(), rsbac_kthread_notify(), set_attr_func(), syscall_func(), and write_func().

00325 {
00326         return rsbac_ta_list_add_ttl(0, handle, RSBAC_LIST_TTL_KEEP, desc,
00327                                      data);
00328 }

static int rsbac_list_add_ttl ( rsbac_list_handle_t  handle,
rsbac_time_t  ttl,
void *  desc,
void *  data 
) [inline, static]

Definition at line 318 of file lists.h.

References rsbac_ta_list_add_ttl().

Referenced by set_attr_fd().

00320 {
00321         return rsbac_ta_list_add_ttl(0, handle, ttl, desc, data);
00322 }

int rsbac_list_check ( rsbac_list_handle_t  handle,
int  correct 
)

Definition at line 5477 of file gen_lists.c.

References rsbac_list_hashed_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::hashed, rsbac_list_hashed_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_list_reg_item_t::nr_hashes, reg_head, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, rsbac_pr_debug, rsbac_printk(), rsbac_list_reg_item_t::self, and TRUE.

05478 {
05479         struct rsbac_list_reg_item_t *list;
05480         struct rsbac_list_item_t *item_p;
05481         struct rsbac_list_item_t *next_item_p;
05482         u_long lock_flags;
05483         u_long rlock_flags;
05484         u_long tmp_count;
05485         int i;
05486 
05487         if (!handle)
05488                 return -RSBAC_EINVALIDLIST;
05489         if (!list_initialized)
05490                 return -RSBAC_ENOTINITIALIZED;
05491 
05492         list = (struct rsbac_list_reg_item_t *) handle;
05493         if (!list || (list->self != list))
05494                 return -RSBAC_EINVALIDLIST;
05495 
05496         rsbac_read_lock(&reg_head.lock, &rlock_flags);
05497         rsbac_pr_debug(lists, "checking list %s.\n", list->name);
05498         rsbac_write_lock(&list->lock, &lock_flags);
05499         for (i=0; i<list->nr_hashes; i++) {
05500                 tmp_count = 0;
05501                 item_p = list->hashed[i].head;
05502                 while (item_p) {
05503                         if ((item_p->max_age
05504                              && (item_p->max_age <= RSBAC_CURRENT_TIME)
05505                             )
05506                             || (list->def_data
05507                                 && !memcmp(((char *) item_p) + sizeof(*item_p) +
05508                                            list->info.desc_size, list->def_data,
05509                                            list->info.data_size)
05510                             )
05511                             ) {
05512                                 next_item_p = item_p->next;
05513                                 do_remove_item(list, item_p, i);
05514                                 item_p = next_item_p;
05515                                 list->dirty = TRUE;
05516                         } else {
05517                                 tmp_count++;
05518                                 item_p = item_p->next;
05519                         }
05520                 }
05521                 if (tmp_count != list->hashed[i].count) {
05522                         if (correct) {
05523                                 rsbac_printk(KERN_WARNING "rsbac_list_check(): correcting count mismatch for list %s hash %u on device %02u:%02u - was %u, counted %lu!\n",
05524                                              list->name, i, RSBAC_MAJOR(list->device),
05525                                              RSBAC_MINOR(list->device),
05526                                              list->hashed[i].count, tmp_count);
05527                                 list->hashed[i].count = tmp_count;
05528                                 list->dirty = TRUE;
05529                         } else {
05530                                 rsbac_printk(KERN_WARNING "rsbac_list_check(): count mismatch for list %s hash %u on device %02u:%02u - is %u, counted %lu!\n",
05531                                              list->name, i, RSBAC_MAJOR(list->device),
05532                                              RSBAC_MINOR(list->device),
05533                                              list->hashed[i].count, tmp_count);
05534                         }
05535                 }
05536         }
05537         rsbac_write_unlock(&list->lock, &lock_flags);
05538         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
05539         return 0;
05540 }

int rsbac_list_compare_u32 ( void *  desc1,
void *  desc2 
)

Definition at line 4956 of file gen_lists.c.

04957   {
04958     if( *((__u32*) desc1) < *((__u32*) desc2))
04959       return -1;
04960     return( *((__u32*) desc1) != *((__u32*) desc2));
04961   }

long rsbac_list_copy ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  from_handle,
rsbac_list_handle_t  to_handle 
)

Definition at line 10185 of file gen_lists.c.

References rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, rsbac_list_reg_item_t::info, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::name, rsbac_list_reg_item_t::nr_hashes, reg_head, RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, rsbac_pr_debug, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.

10188 {
10189         struct rsbac_list_reg_item_t *from_list;
10190         struct rsbac_list_reg_item_t *to_list;
10191         struct rsbac_list_item_t *item_p;
10192         u_long rlock_flags, from_lock_flags, to_lock_flags;
10193         int i;
10194         int err = 0;
10195 
10196         if (!from_handle || !to_handle)
10197                 return -RSBAC_EINVALIDLIST;
10198 
10199         from_list = (struct rsbac_list_reg_item_t *) from_handle;
10200         if (from_list->self != from_list)
10201                 return -RSBAC_EINVALIDLIST;
10202         to_list = (struct rsbac_list_reg_item_t *) to_handle;
10203         if (to_list->self != to_list)
10204                 return -RSBAC_EINVALIDLIST;
10205         if((from_list->info.desc_size != to_list->info.desc_size)
10206                 || (from_list->info.data_size != to_list->info.data_size))
10207                return -RSBAC_EINVALIDVALUE;
10208 
10209 #ifdef CONFIG_RSBAC_LIST_TRANS
10210         if (ta_number) {
10211                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
10212                         return -RSBAC_EINVALIDTRANSACTION;
10213         }
10214 #endif
10215 
10216         rsbac_read_lock(&reg_head.lock, &rlock_flags);
10217         rsbac_pr_debug(lists, "list %s to list %s.\n",
10218                        from_list->name, to_list->name);
10219         rsbac_read_lock(&from_list->lock, &from_lock_flags);
10220         rsbac_write_lock(&to_list->lock, &to_lock_flags);
10221 
10222 #ifdef CONFIG_RSBAC_LIST_TRANS
10223         /* Check for other transactions at the target list */
10224         if(ta_number)
10225                 for (i=0; i<to_list->nr_hashes; i++)
10226                         if(to_list->hashed[i].ta_copied != ta_number) {
10227                                 err = -RSBAC_EBUSY;
10228                                 goto out_unlock;
10229                         }
10230 #endif
10231         for (i=0; i<to_list->nr_hashes; i++) {
10232 #ifdef CONFIG_RSBAC_LIST_TRANS
10233                 if(ta_number && (to_list->hashed[i].ta_copied == ta_number))
10234                         ta_remove_all_items(to_list, i);
10235                 else
10236 #endif
10237                         remove_all_items(to_list, i);
10238         }
10239         for (i=0; i<from_list->nr_hashes; i++) {
10240 #ifdef CONFIG_RSBAC_LIST_TRANS
10241                 if (ta_number) {
10242                         if(from_list->hashed[i].ta_copied == ta_number)
10243                                 item_p = from_list->hashed[i].ta_head;
10244                         else
10245                                 item_p = from_list->hashed[i].head;
10246                         while(item_p) {
10247                                 if (!ta_add_item(ta_number,
10248                                                 to_list,
10249                                                 item_p->max_age,
10250                                                 &item_p[1],
10251                                                 &item_p[1] + from_list->info.desc_size)) {
10252                                         err = -RSBAC_EWRITEFAILED;
10253                                         goto out_unlock;
10254                                 }
10255                                 item_p = item_p->next;
10256                         }
10257                 }
10258                 else
10259 #endif
10260                 {
10261                         item_p = from_list->hashed[i].head;
10262                         while(item_p) {
10263                                 if (!add_item(to_list,
10264                                                 item_p->max_age,
10265                                                 &item_p[1],
10266                                                 &item_p[1] + from_list->info.desc_size)) {
10267                                         err = -RSBAC_EWRITEFAILED;
10268                                         goto out_unlock;
10269                                 }
10270                                 item_p = item_p->next;
10271                         }
10272                 }
10273         }
10274 
10275 out_unlock:
10276         rsbac_write_unlock(&to_list->lock, &to_lock_flags);
10277         rsbac_read_unlock(&from_list->lock, &from_lock_flags);
10278         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
10279         return err;
10280 }

static long rsbac_list_count ( rsbac_list_handle_t  handle  )  [inline, static]

Definition at line 634 of file lists.h.

References rsbac_ta_list_count().

Referenced by acl_create_def(), acl_create_def2(), register_user_lists1(), register_user_lists2(), rsbac_check_acl(), rsbac_init_rc(), rsbac_stats(), rsbac_stats_acl(), rsbac_stats_pm(), rsbac_stats_rc(), and rsbac_stats_um().

00635 {
00636         return rsbac_ta_list_count(0, handle);
00637 }

int rsbac_list_destroy ( rsbac_list_handle_t handle_p,
rsbac_list_key_t  key 
)

Definition at line 6106 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, reg_head, remove_reg(), RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_ENOTINITIALIZED, RSBAC_LIST_BACKUP, rsbac_pr_debug, and rsbac_printk().

06108 {
06109         struct rsbac_list_reg_item_t *reg_item_p;
06110         u_long lock_flags;
06111         int err = 0;
06112 
06113         if (!handle_p)
06114                 return -RSBAC_EINVALIDPOINTER;
06115         if (!*handle_p)
06116                 return -RSBAC_EINVALIDLIST;
06117         if (!list_initialized)
06118                 return -RSBAC_ENOTINITIALIZED;
06119 
06120         rsbac_write_lock(&reg_head.lock, &lock_flags);
06121         reg_item_p =
06122             lookup_reg((struct rsbac_list_reg_item_t *) *handle_p);
06123         if (!reg_item_p) {
06124                 rsbac_write_unlock(&reg_head.lock, &lock_flags);
06125                 rsbac_printk(KERN_WARNING "rsbac_list_destroy: destroying list failed due to invalid handle!\n");
06126                 return -RSBAC_EINVALIDLIST;
06127         }
06128         if (reg_item_p->info.key != key) {
06129                 rsbac_write_unlock(&reg_head.lock, &lock_flags);
06130                 rsbac_printk(KERN_WARNING "rsbac_list_destroy: destroying list %s denied due to invalid key!\n",
06131                              reg_item_p->name);
06132                 return -EPERM;
06133         }
06134         rsbac_pr_debug(lists, "destroying list %s.\n",
06135                        reg_item_p->name);
06136 #if defined(CONFIG_RSBAC_PROC)
06137         /* delete proc entry, if it exists */
06138         if ((reg_item_p->flags & RSBAC_LIST_BACKUP)
06139             && reg_item_p->proc_entry_p) {
06140                 remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p);
06141                 reg_item_p->proc_entry_p = NULL;
06142         }
06143 #endif
06144 
06145 #if 0
06146         if (reg_item_p->flags & RSBAC_LIST_PERSIST)
06147                 err = unlink_list(reg_item_p);
06148 #endif
06149 
06150         remove_reg(reg_item_p);
06151         *handle_p = NULL;
06152         rsbac_write_unlock(&reg_head.lock, &lock_flags);
06153         return err;
06154 }

int rsbac_list_detach ( rsbac_list_handle_t handle_p,
rsbac_list_key_t  key 
)

Definition at line 6213 of file gen_lists.c.

References 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, reg_head, remove_reg(), RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_ENOTINITIALIZED, RSBAC_ENOTWRITABLE, RSBAC_LIST_BACKUP, rsbac_list_write_buffers(), rsbac_printk(), rsbac_list_write_head_t::tail, and TRUE.

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

06214 {
06215         struct rsbac_list_reg_item_t *reg_item_p;
06216         u_long lock_flags;
06217         int err = 0;
06218 
06219         if (!handle_p)
06220                 return -RSBAC_EINVALIDPOINTER;
06221         if (!*handle_p)
06222                 return -RSBAC_EINVALIDLIST;
06223         if (!list_initialized)
06224                 return -RSBAC_ENOTINITIALIZED;
06225 
06226         rsbac_read_lock(&reg_head.lock, &lock_flags);
06227         reg_item_p =
06228             lookup_reg((struct rsbac_list_reg_item_t *) *handle_p);
06229         if (!reg_item_p) {
06230                 rsbac_read_unlock(&reg_head.lock, &lock_flags);
06231                 rsbac_printk(KERN_WARNING "rsbac_list_detach: detaching list failed due to invalid handle!\n");
06232                 return -RSBAC_EINVALIDLIST;
06233         }
06234         if (reg_item_p->info.key != key) {
06235                 rsbac_read_unlock(&reg_head.lock, &lock_flags);
06236                 rsbac_printk(KERN_WARNING "rsbac_list_detach: detaching list %s denied due to invalid key %u!\n",
06237                              reg_item_p->name, key);
06238                 return -EPERM;
06239         }
06240 #if defined(CONFIG_RSBAC_PROC)
06241         /* delete proc entry, if it exists */
06242         if ((reg_item_p->flags & RSBAC_LIST_BACKUP)
06243             && reg_item_p->proc_entry_p) {
06244                 remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p);
06245                 reg_item_p->proc_entry_p = NULL;
06246         }
06247 #endif
06248 #ifndef CONFIG_RSBAC_NO_WRITE
06249         /* final write, if dirty etc. */
06250         if ((reg_item_p->flags & RSBAC_LIST_PERSIST)
06251             && reg_item_p->dirty && !reg_item_p->no_write) {
06252                 struct rsbac_list_write_head_t write_head;
06253                 struct rsbac_list_write_item_t *write_item_p;
06254 
06255                 reg_item_p->dirty = FALSE;
06256                 err = fill_buffer(reg_item_p, &write_item_p);
06257                 if (!err) {
06258                         write_head.head = write_item_p;
06259                         write_head.tail = write_item_p;
06260                         write_head.count = 1;
06261                         rsbac_read_unlock(&reg_head.lock, &lock_flags);
06262                         rsbac_list_write_buffers(write_head, TRUE);
06263                 } else {
06264                         rsbac_read_unlock(&reg_head.lock, &lock_flags);
06265                         if (err != -RSBAC_ENOTWRITABLE) {
06266                                 rsbac_printk(KERN_WARNING "rsbac_list_detach(): fill_buffer() for list %s returned error %i\n",
06267                                              reg_item_p->name, err);
06268                         }
06269                 }
06270         } else
06271                 rsbac_read_unlock(&reg_head.lock, &lock_flags);
06272 #else
06273         rsbac_read_unlock(&reg_head.lock, &lock_flags);
06274 #endif
06275         /* disable handle */
06276         *handle_p = NULL;
06277         /* too bad that the list might have been changed again - we do not care anymore */
06278         rsbac_write_lock(&reg_head.lock, &lock_flags);
06279         remove_reg(reg_item_p);
06280         rsbac_write_unlock(&reg_head.lock, &lock_flags);
06281         return err;
06282 }

static int rsbac_list_exist ( rsbac_list_handle_t  handle,
void *  desc 
) [inline, static]

Definition at line 584 of file lists.h.

References rsbac_ta_list_exist().

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

00585 {
00586         return rsbac_ta_list_exist(0, handle, desc);
00587 }

static long rsbac_list_get_all_data ( rsbac_list_handle_t  handle,
void **  array_p 
) [inline, static]

Definition at line 723 of file lists.h.

References rsbac_ta_list_get_all_data().

00724 {
00725         return rsbac_ta_list_get_all_data(0, handle, array_p);
00726 }

static long rsbac_list_get_all_desc ( rsbac_list_handle_t  handle,
void **  array_p 
) [inline, static]

Definition at line 674 of file lists.h.

References rsbac_ta_list_get_all_desc().

00675 {
00676         return rsbac_ta_list_get_all_desc(0, handle, array_p);
00677 }

static long rsbac_list_get_all_items ( rsbac_list_handle_t  handle,
void **  array_p 
) [inline, static]

Definition at line 775 of file lists.h.

References NULL, and rsbac_ta_list_get_all_items_ttl().

00776 {
00777         return rsbac_ta_list_get_all_items_ttl(0, handle, array_p, NULL);
00778 }

static long rsbac_list_get_all_items_ttl ( rsbac_list_handle_t  handle,
void **  array_p,
rsbac_time_t **  ttl_array_p 
) [inline, static]

Definition at line 767 of file lists.h.

References rsbac_ta_list_get_all_items_ttl().

00770 {
00771         return rsbac_ta_list_get_all_items_ttl(0, handle, array_p,
00772                                                ttl_array_p);
00773 }

static int rsbac_list_get_data ( rsbac_list_handle_t  handle,
void *  desc,
void *  data 
) [inline, static]

Definition at line 456 of file lists.h.

References NULL, and rsbac_ta_list_get_data_ttl().

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

00457 {
00458         return rsbac_ta_list_get_data_ttl(0, handle, NULL, desc, data);
00459 }

static int rsbac_list_get_data_ttl ( rsbac_list_handle_t  handle,
rsbac_time_t ttl_p,
void *  desc,
void *  data 
) [inline, static]

Definition at line 450 of file lists.h.

References rsbac_ta_list_get_data_ttl().

00452 {
00453         return rsbac_ta_list_get_data_ttl(0, handle, ttl_p, desc, data);
00454 }

static int rsbac_list_get_desc ( rsbac_list_handle_t  handle,
void *  desc,
void *  data,
rsbac_list_data_compare_function_t  compare 
) [inline, static]

Definition at line 522 of file lists.h.

References rsbac_ta_list_get_desc().

Referenced by rsbac_rc_get_boot_role().

00526 {
00527         return rsbac_ta_list_get_desc(0, handle, desc, data, compare);
00528 }

int rsbac_list_get_item_size ( rsbac_list_handle_t  handle  ) 

Definition at line 9737 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_EINVALIDLIST, RSBAC_ENOTINITIALIZED, and rsbac_list_reg_item_t::self.

09738 {
09739         struct rsbac_list_reg_item_t *list;
09740 
09741         if (!handle)
09742                 return -RSBAC_EINVALIDLIST;
09743         if (!list_initialized)
09744                 return -RSBAC_ENOTINITIALIZED;
09745 
09746         list = (struct rsbac_list_reg_item_t *) handle;
09747         if (list->self != list)
09748                 return -RSBAC_EINVALIDLIST;
09749         return list->info.desc_size + list->info.data_size;
09750 }

static int rsbac_list_get_max_desc ( rsbac_list_handle_t  handle,
void *  desc 
) [inline, static]

Definition at line 548 of file lists.h.

References rsbac_ta_list_get_max_desc().

Referenced by acl_create_def2().

00549 {
00550         return rsbac_ta_list_get_max_desc(0, handle, desc);
00551 }

static int rsbac_list_get_next_desc ( rsbac_list_handle_t  handle,
void *  old_desc,
void *  next_desc 
) [inline, static]

Definition at line 562 of file lists.h.

References rsbac_ta_list_get_next_desc().

00564 {
00565         return rsbac_ta_list_get_next_desc(0, handle, old_desc, next_desc);
00566 }

long rsbac_list_get_nr_hashes ( rsbac_list_handle_t  handle  ) 

Definition at line 10616 of file gen_lists.c.

References list_initialized, rsbac_list_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, and rsbac_list_reg_item_t::self.

10617 {
10618         struct rsbac_list_reg_item_t *list;
10619 
10620         if (!handle)
10621                 return -RSBAC_EINVALIDLIST;
10622         if (!list_initialized)
10623                 return -RSBAC_ENOTINITIALIZED;
10624 
10625         list = (struct rsbac_list_reg_item_t *) handle;
10626         if (list->self != list)
10627                 return -RSBAC_EINVALIDLIST;
10628 
10629         return list->nr_hashes;
10630 }

u_int rsbac_list_hash_dev ( void *  desc,
__u32  nr_hashes 
)

Definition at line 10158 of file gen_lists.c.

Referenced by register_dev_lists(), and rsbac_init_acl().

10159 {
10160         return ( (  ((struct rsbac_dev_desc_t *) desc)->major
10161                   + ((struct rsbac_dev_desc_t *) desc)->minor )
10162                 & (nr_hashes - 1));
10163 }

u_int rsbac_list_hash_fd ( void *  desc,
__u32  nr_hashes 
)

Definition at line 10118 of file gen_lists.c.

Referenced by acl_register_fd_lists(), auth_register_fd_lists(), mac_register_fd_lists(), and register_fd_lists().

10119 {
10120         return (*((rsbac_inode_nr_t *) desc) & (nr_hashes - 1));
10121 }

u_int rsbac_list_hash_gid ( void *  desc,
__u32  nr_hashes 
)

Definition at line 10142 of file gen_lists.c.

Referenced by rsbac_init_acl(), and rsbac_init_um().

10143 {
10144         return (*((rsbac_gid_t *) desc) & (nr_hashes - 1));
10145 }

u_int rsbac_list_hash_ipc ( void *  desc,
__u32  nr_hashes 
)

Definition at line 10150 of file gen_lists.c.

Referenced by register_ipc_lists().

10151 {
10152         return (((struct rsbac_ipc_t *) desc)->id.id_nr & (nr_hashes - 1));
10153 }

u_int rsbac_list_hash_netobj ( void *  desc,
__u32  nr_hashes 
)

Definition at line 10176 of file gen_lists.c.

Referenced by rsbac_init_acl().

10177 {
10178         return (*((__u32 *) desc) & (nr_hashes - 1));
10179 }

u_int rsbac_list_hash_nettemp ( void *  desc,
__u32  nr_hashes 
)

Definition at line 10168 of file gen_lists.c.

Referenced by rsbac_init_acl().

10169 {
10170         return (*((rsbac_net_temp_id_t *) desc) & (nr_hashes - 1));
10171 }

u_int rsbac_list_hash_pid ( void *  desc,
__u32  nr_hashes 
)

Definition at line 10126 of file gen_lists.c.

Referenced by register_process_lists(), and rsbac_init_auth().

10127 {
10128         return (*((rsbac_pid_t *) desc) & (nr_hashes - 1));
10129 }

u_int rsbac_list_hash_u32 ( void *  desc,
__u32  nr_hashes 
)

Definition at line 10110 of file gen_lists.c.

10111 {
10112         return (*((__u32 *) desc) & (nr_hashes - 1));
10113 }

u_int rsbac_list_hash_uid ( void *  desc,
__u32  nr_hashes 
)

Definition at line 10134 of file gen_lists.c.

Referenced by register_user_lists1(), register_user_lists2(), rsbac_init_acl(), and rsbac_init_um().

10135 {
10136         return (*((rsbac_uid_t *) desc) & (nr_hashes - 1));
10137 }

static int rsbac_list_lol_add ( rsbac_list_handle_t  handle,
void *  desc,
void *  data 
) [inline, static]

Definition at line 362 of file lists.h.

References RSBAC_LIST_TTL_KEEP, and rsbac_ta_list_lol_add_ttl().

Referenced by acl_create_def(), create_def_roles(), create_def_roles2(), rsbac_pm_pp_intersec(), and rsbac_pm_pp_union().

00363 {
00364         return rsbac_ta_list_lol_add_ttl(0, handle, RSBAC_LIST_TTL_KEEP,
00365                                          desc, data);
00366 }

static int rsbac_list_lol_add_ttl ( rsbac_list_handle_t  handle,
rsbac_time_t  ttl,
void *  desc,
void *  data 
) [inline, static]

Definition at line 356 of file lists.h.

References rsbac_ta_list_lol_add_ttl().

00358 {
00359         return rsbac_ta_list_lol_add_ttl(0, handle, ttl, desc, data);
00360 }

static long rsbac_list_lol_all_subcount ( rsbac_list_handle_t  handle  )  [inline, static]

Definition at line 650 of file lists.h.

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().

00651 {
00652         return rsbac_ta_list_lol_all_subcount(0, handle);
00653 }

int rsbac_list_lol_check ( rsbac_list_handle_t  handle,
int  correct 
)

Definition at line 5545 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_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::hashed, rsbac_list_lol_item_t::head, rsbac_list_lol_hashed_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_reg_head, 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_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, rsbac_pr_debug, rsbac_printk(), and rsbac_list_lol_reg_item_t::self.

05546 {
05547         struct rsbac_list_lol_reg_item_t *lol_list;
05548         struct rsbac_list_lol_item_t *lol_item_p;
05549         struct rsbac_list_lol_item_t *next_lol_item_p;
05550         struct rsbac_list_item_t *lol_subitem_p;
05551         struct rsbac_list_item_t *next_lol_subitem_p;
05552         u_long lock_flags;
05553         u_long rlock_flags;
05554         u_long tmp_count;
05555         u_long tmp_subcount;
05556         int i;
05557 
05558         if (!handle)
05559                 return -RSBAC_EINVALIDLIST;
05560         if (!list_initialized)
05561                 return -RSBAC_ENOTINITIALIZED;
05562 
05563         lol_list = (struct rsbac_list_lol_reg_item_t *) handle;
05564         if (!lol_list || (lol_list->self != lol_list))
05565                 return -RSBAC_EINVALIDLIST;
05566 
05567         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
05568         rsbac_pr_debug(lists, "checking list %s.\n", lol_list->name);
05569         rsbac_write_lock(&lol_list->lock, &lock_flags);
05570         for (i=0; i<lol_list->nr_hashes; i++) {
05571                 tmp_count = 0;
05572                 lol_item_p = lol_list->hashed[i].head;
05573                 while (lol_item_p) {
05574                         if ((lol_item_p->max_age
05575                              && (lol_item_p->max_age <= RSBAC_CURRENT_TIME)
05576                             )
05577                             || (lol_list->def_data
05578                                 && !lol_item_p->count
05579                                 && !memcmp(((char *) lol_item_p) +
05580                                            sizeof(*lol_item_p) +
05581                                            lol_list->info.desc_size,
05582                                            lol_list->def_data,
05583                                            lol_list->info.data_size)
05584                             )
05585                             || (!lol_list->info.data_size
05586                                 && (lol_list->flags & RSBAC_LIST_DEF_DATA)
05587                                 && !lol_item_p->count)
05588                             ) {
05589                                 next_lol_item_p = lol_item_p->next;
05590                                 do_remove_lol_item(lol_list, lol_item_p, i);
05591                                 lol_item_p = next_lol_item_p;
05592                         } else {
05593                                 tmp_count++;
05594                                 tmp_subcount = 0;
05595                                 lol_subitem_p = lol_item_p->head;
05596                                 while (lol_subitem_p) {
05597                                         if ((lol_subitem_p->max_age
05598                                              && (lol_subitem_p->max_age <=
05599                                                  RSBAC_CURRENT_TIME)
05600                                             )
05601                                             || (lol_list->def_subdata
05602                                                 && !memcmp(((char *) lol_subitem_p)
05603                                                            +
05604                                                            sizeof(*lol_subitem_p) +
05605                                                            lol_list->info.
05606                                                            subdesc_size,
05607                                                            lol_list->def_subdata,
05608                                                            lol_list->info.
05609                                                            subdata_size)
05610                                             )
05611                                             ) {
05612                                                 next_lol_subitem_p =
05613                                                     lol_subitem_p->next;
05614                                                 do_remove_lol_subitem(lol_item_p,
05615                                                                       lol_subitem_p);
05616                                                 lol_subitem_p = next_lol_subitem_p;
05617                                         } else {
05618                                                 tmp_subcount++;
05619                                                 lol_subitem_p =
05620                                                     lol_subitem_p->next;
05621                                         }
05622                                 }
05623                                 if (tmp_subcount != lol_item_p->count) {
05624                                         if (correct) {
05625                                                 rsbac_printk(KERN_WARNING "rsbac_list_lol_check(): correcting count mismatch for list of lists %s hash %u sublist on %02u:%02u - was %lu, counted %lu!\n",
05626                                                              lol_list->name, i,
05627                                                              RSBAC_MAJOR(lol_list->
05628                                                                          device),
05629                                                              RSBAC_MINOR(lol_list->
05630                                                                          device),
05631                                                              lol_item_p->count,
05632                                                              tmp_subcount);
05633                                                 lol_item_p->count = tmp_subcount;
05634                                         } else {
05635                                                 rsbac_printk(KERN_WARNING "rsbac_list_lol_check(): count mismatch for list of lists %s hash %u sublist on %02u:%02u - is %lu, counted %lu!\n",
05636                                                              lol_list->name, i,
05637                                                              RSBAC_MAJOR(lol_list->
05638                                                                          device),
05639                                                              RSBAC_MINOR(lol_list->
05640                                                                          device),
05641                                                              lol_item_p->count,
05642                                                              tmp_subcount);
05643                                         }
05644                                 }
05645                                 lol_item_p = lol_item_p->next;
05646                         }
05647                 }
05648                 if (tmp_count != lol_list->hashed[i].count) {
05649                         if (correct) {
05650                                 rsbac_printk(KERN_WARNING "rsbac_list_lol_check(): correcting count mismatch for list of lists %s hash %u on %02u:%02u - was %u, counted %lu!\n",
05651                                              lol_list->name, i,
05652                                              RSBAC_MAJOR(lol_list->device),
05653                                              RSBAC_MINOR(lol_list->device),
05654                                              lol_list->hashed[i].count, tmp_count);
05655                                 lol_list->hashed[i].count = tmp_count;
05656                         } else {
05657                                 rsbac_printk(KERN_WARNING "rsbac_list_lol_check(): count mismatch for list of lists %s hash %u on %02u:%02u - is %u, counted %lu!\n",
05658                                              lol_list->name, i,
05659                                              RSBAC_MAJOR(lol_list->device),
05660                                              RSBAC_MINOR(lol_list->device),
05661                                              lol_list->hashed[i].count, tmp_count);
05662                         }
05663                 }
05664         }
05665         rsbac_write_unlock(&lol_list->lock, &lock_flags);
05666         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
05667         return 0;
05668 }

long rsbac_list_lol_copy ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  from_handle,
rsbac_list_handle_t  to_handle 
)

Definition at line 10285 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::hashed, rsbac_list_lol_reg_item_t::info, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, rsbac_list_lol_reg_item_t::name, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, rsbac_pr_debug, 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.

10288 {
10289         struct rsbac_list_lol_reg_item_t *from_list;
10290         struct rsbac_list_lol_reg_item_t *to_list;
10291         struct rsbac_list_lol_item_t *item_p;
10292         struct rsbac_list_lol_item_t *new_item_p;
10293         struct rsbac_list_item_t *subitem_p;
10294         struct rsbac_list_item_t *new_subitem_p;
10295         u_long rlock_flags, from_lock_flags, to_lock_flags;
10296         u_int subitem_size;
10297         int i;
10298         int err = 0;
10299 
10300         if (!from_handle || !to_handle)
10301                 return -RSBAC_EINVALIDLIST;
10302 
10303         from_list = (struct rsbac_list_lol_reg_item_t *) from_handle;
10304         if (from_list->self != from_list)
10305                 return -RSBAC_EINVALIDLIST;
10306         to_list = (struct rsbac_list_lol_reg_item_t *) to_handle;
10307         if (to_list->self != to_list)
10308                 return -RSBAC_EINVALIDLIST;
10309         if((from_list->info.desc_size != to_list->info.desc_size)
10310                 || (from_list->info.data_size != to_list->info.data_size)
10311                 || (from_list->info.subdesc_size != to_list->info.subdesc_size)
10312                 || (from_list->info.subdata_size != to_list->info.subdata_size))
10313                return -RSBAC_EINVALIDVALUE;
10314 
10315 #ifdef CONFIG_RSBAC_LIST_TRANS
10316         if (ta_number) {
10317                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
10318                         return -RSBAC_EINVALIDTRANSACTION;
10319         }
10320 #endif
10321 
10322         subitem_size = sizeof(*new_subitem_p)
10323             + from_list->info.subdesc_size + from_list->info.subdata_size;
10324 
10325         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
10326         rsbac_pr_debug(lists, "list %s to list %s.\n",
10327                        from_list->name, to_list->name);
10328         rsbac_read_lock(&from_list->lock, &from_lock_flags);
10329         rsbac_write_lock(&to_list->lock, &to_lock_flags);
10330 
10331 #ifdef CONFIG_RSBAC_LIST_TRANS
10332         /* Check for other transactions at the target list */
10333         if(ta_number)
10334                 for (i=0; i<to_list->nr_hashes; i++)
10335                         if(to_list->hashed[i].ta_copied != ta_number) {
10336                                 err = -RSBAC_EBUSY;
10337                                 goto out_unlock;
10338                         }
10339 #endif
10340         for (i=0; i<to_list->nr_hashes; i++) {
10341 #ifdef CONFIG_RSBAC_LIST_TRANS
10342                 if(ta_number && (to_list->hashed[i].ta_copied == ta_number))
10343                         ta_remove_all_lol_items(to_list, i);
10344                 else
10345 #endif
10346                         remove_all_lol_items(to_list, i);
10347         }
10348         for (i=0; i<from_list->nr_hashes; i++) {
10349 #ifdef CONFIG_RSBAC_LIST_TRANS
10350                 if (ta_number) {
10351                         if(from_list->hashed[i].ta_copied == ta_number)
10352                                 item_p = from_list->hashed[i].ta_head;
10353                         else
10354                                 item_p = from_list->hashed[i].head;
10355                         while(item_p) {
10356                                 new_item_p = ta_add_lol_item(ta_number,
10357                                                 to_list,
10358                                                 item_p->max_age,
10359                                                 &item_p[1],
10360                                                 &item_p[1] + from_list->info.desc_size);
10361                                 if(!new_item_p) {
10362                                         err = -RSBAC_EWRITEFAILED;
10363                                         goto out_unlock;
10364                                 }
10365                                 subitem_p = item_p->head;
10366                                 while (subitem_p) {
10367                                         if (!(new_subitem_p = rsbac_kmalloc(subitem_size))) {
10368                                                 err = -RSBAC_ENOMEM;
10369                                                 goto out_unlock;
10370                                         }
10371                                         memcpy(new_subitem_p, subitem_p, subitem_size);
10372                                         new_subitem_p->prev = NULL;
10373                                         new_subitem_p->next = NULL;
10374                                         if (new_item_p->tail) {
10375                                                 new_subitem_p->prev = new_item_p->tail;
10376                                                 new_item_p->tail->next = new_subitem_p;
10377                                                 new_item_p->tail = new_subitem_p;
10378                                                 new_item_p->count++;
10379                                         } else {
10380                                                 new_item_p->head = new_subitem_p;
10381                                                 new_item_p->tail = new_subitem_p;
10382                                                 new_item_p->count = 1;
10383                                                 }
10384                                         subitem_p = subitem_p->next;
10385                                 }
10386                                 item_p = item_p->next;
10387                         }
10388                 }
10389                 else
10390 #endif
10391                 {
10392                         item_p = from_list->hashed[i].head;
10393                         while(item_p) {
10394                                 new_item_p = add_lol_item(to_list,
10395                                                 item_p->max_age,
10396                                                 &item_p[1],
10397                                                 &item_p[1] + from_list->info.desc_size);
10398                                 if(!new_item_p) {
10399                                         err = -RSBAC_EWRITEFAILED;
10400                                         goto out_unlock;
10401                                 }
10402                                 subitem_p = item_p->head;
10403                                 while (subitem_p) {
10404                                         if (!(new_subitem_p = rsbac_kmalloc(subitem_size))) {
10405                                                 err = -RSBAC_ENOMEM;
10406                                                 goto out_unlock;
10407                                         }
10408                                         memcpy(new_subitem_p, subitem_p, subitem_size);
10409                                         new_subitem_p->prev = NULL;
10410                                         new_subitem_p->next = NULL;
10411                                         if (new_item_p->tail) {
10412                                                 new_subitem_p->prev = new_item_p->tail;
10413                                                 new_item_p->tail->next = new_subitem_p;
10414                                                 new_item_p->tail = new_subitem_p;
10415                                                 new_item_p->count++;
10416                                         } else {
10417                                                 new_item_p->head = new_subitem_p;
10418                                                 new_item_p->tail = new_subitem_p;
10419                                                 new_item_p->count = 1;
10420                                                 }
10421                                         subitem_p = subitem_p->next;
10422                                 }
10423                                 item_p = item_p->next;
10424                         }
10425                 }
10426         }
10427 
10428 out_unlock:
10429         rsbac_write_unlock(&to_list->lock, &to_lock_flags);
10430         rsbac_read_unlock(&from_list->lock, &from_lock_flags);
10431         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
10432         return err;
10433 }

static long rsbac_list_lol_count ( rsbac_list_handle_t  handle  )  [inline, static]

Definition at line 658 of file lists.h.

References rsbac_ta_list_lol_count().

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

00659 {
00660         return rsbac_ta_list_lol_count(0, handle);
00661 }

int rsbac_list_lol_destroy ( rsbac_list_handle_t handle_p,
rsbac_list_key_t  key 
)

Definition at line 6159 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, lol_reg_head, lookup_lol_reg(), rsbac_list_lol_reg_item_t::name, NULL, proc_rsbac_backup_p, remove_lol_reg(), RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_ENOTINITIALIZED, RSBAC_LIST_BACKUP, rsbac_pr_debug, and rsbac_printk().

06161 {
06162         struct rsbac_list_lol_reg_item_t *reg_item_p;
06163         u_long lock_flags;
06164         int err = 0;
06165 
06166         if (!handle_p)
06167                 return -RSBAC_EINVALIDPOINTER;
06168         if (!*handle_p)
06169                 return -RSBAC_EINVALIDLIST;
06170         if (!list_initialized)
06171                 return -RSBAC_ENOTINITIALIZED;
06172 
06173         rsbac_write_lock(&lol_reg_head.lock, &lock_flags);
06174         reg_item_p =
06175             lookup_lol_reg((struct rsbac_list_lol_reg_item_t *) *handle_p);
06176         if (!reg_item_p) {
06177                 rsbac_write_unlock(&lol_reg_head.lock, &lock_flags);
06178                 rsbac_printk(KERN_WARNING "rsbac_list_lol_destroy: destroying list failed due to invalid handle!\n");
06179                 return -RSBAC_EINVALIDLIST;
06180         }
06181         if (reg_item_p->info.key != key) {
06182                 rsbac_write_unlock(&lol_reg_head.lock, &lock_flags);
06183                 rsbac_printk(KERN_WARNING "rsbac_list_lol_destroy: destroying list %s denied due to invalid key %u!\n",
06184                              reg_item_p->name, key);
06185                 return -EPERM;
06186         }
06187         rsbac_pr_debug(lists, "destroying list %s.\n",
06188                        reg_item_p->name);
06189 #if defined(CONFIG_RSBAC_PROC)
06190         /* delete proc entry, if it exists */
06191         if ((reg_item_p->flags & RSBAC_LIST_BACKUP)
06192             && reg_item_p->proc_entry_p) {
06193                 remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p);
06194                 reg_item_p->proc_entry_p = NULL;
06195         }
06196 #endif
06197 #if 0
06198         if (reg_item_p->flags & RSBAC_LIST_PERSIST)
06199                 err = unlink_lol_list(reg_item_p);
06200 #endif
06201 
06202         remove_lol_reg(reg_item_p);
06203         *handle_p = NULL;
06204         rsbac_write_unlock(&lol_reg_head.lock, &lock_flags);
06205         return err;
06206 }

int rsbac_list_lol_detach ( rsbac_list_handle_t handle_p,
rsbac_list_key_t  key 
)

Definition at line 6287 of file gen_lists.c.

References 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, lol_reg_head, 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_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_ENOTINITIALIZED, RSBAC_ENOTWRITABLE, RSBAC_LIST_BACKUP, rsbac_list_write_lol_buffers(), rsbac_printk(), rsbac_list_lol_write_head_t::tail, and TRUE.

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

06289 {
06290         struct rsbac_list_lol_reg_item_t *reg_item_p;
06291         u_long lock_flags;
06292         int err = 0;
06293 
06294         if (!handle_p)
06295                 return -RSBAC_EINVALIDPOINTER;
06296         if (!*handle_p)
06297                 return -RSBAC_EINVALIDLIST;
06298         if (!list_initialized)
06299                 return -RSBAC_ENOTINITIALIZED;
06300 
06301         rsbac_read_lock(&lol_reg_head.lock, &lock_flags);
06302         reg_item_p =
06303             lookup_lol_reg((struct rsbac_list_lol_reg_item_t *) *handle_p);
06304         if (!reg_item_p) {
06305                 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06306                 rsbac_printk(KERN_WARNING "rsbac_list_lol_detach: detaching list failed due to invalid handle!\n");
06307                 return -RSBAC_EINVALIDLIST;
06308         }
06309         if (reg_item_p->info.key != key) {
06310                 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06311                 rsbac_printk(KERN_WARNING "rsbac_list_lol_detach: detaching list %s denied due to invalid key %u!\n",
06312                              reg_item_p->name, key);
06313                 return -EPERM;
06314         }
06315 #if defined(CONFIG_RSBAC_PROC)
06316         /* delete proc entry, if it exists */
06317         if ((reg_item_p->flags & RSBAC_LIST_BACKUP)
06318             && reg_item_p->proc_entry_p) {
06319                 remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p);
06320                 reg_item_p->proc_entry_p = NULL;
06321         }
06322 #endif
06323 #ifndef CONFIG_RSBAC_NO_WRITE
06324         /* final write, if dirty etc. */
06325         if ((reg_item_p->flags & RSBAC_LIST_PERSIST)
06326             && reg_item_p->dirty && !reg_item_p->no_write) {
06327                 struct rsbac_list_lol_write_head_t write_head;
06328                 struct rsbac_list_lol_write_item_t *write_item_p;
06329 
06330                 reg_item_p->dirty = FALSE;
06331                 err = fill_lol_buffer(reg_item_p, &write_item_p);
06332                 if (!err) {
06333                         write_head.head = write_item_p;
06334                         write_head.tail = write_item_p;
06335                         write_head.count = 1;
06336                         rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06337                         rsbac_list_write_lol_buffers(write_head, TRUE);
06338                 } else {
06339                         rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06340                         if (err != -RSBAC_ENOTWRITABLE) {
06341                                 rsbac_printk(KERN_WARNING "rsbac_list_lol_detach(): fill_buffer() for list %s returned error %i\n",
06342                                              reg_item_p->name, err);
06343                         }
06344                 }
06345         } else
06346                 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06347 #else
06348         rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06349 #endif
06350         /* disable handle */
06351         *handle_p = NULL;
06352         /* too bad that the list might have been changed again - we do not care anymore */
06353         rsbac_write_lock(&lol_reg_head.lock, &lock_flags);
06354         remove_lol_reg(reg_item_p);
06355         rsbac_write_unlock(&lol_reg_head.lock, &lock_flags);
06356         return err;
06357 }

static int rsbac_list_lol_exist ( rsbac_list_handle_t  handle,
void *  desc 
) [inline, static]

Definition at line 602 of file lists.h.

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().

00603 {
00604         return rsbac_ta_list_lol_exist(0, handle, desc);
00605 }

static long rsbac_list_lol_get_all_data ( rsbac_list_handle_t  handle,
void **  array_p 
) [inline, static]

Definition at line 742 of file lists.h.

References rsbac_ta_list_lol_get_all_data().

00744 {
00745         return rsbac_ta_list_lol_get_all_data(0, handle, array_p);
00746 }

static long rsbac_list_lol_get_all_desc ( rsbac_list_handle_t  handle,
void **  array_p 
) [inline, static]

Definition at line 707 of file lists.h.

References rsbac_ta_list_lol_get_all_desc().

Referenced by rsbac_check_acl(), and rsbac_init_rc().

00709 {
00710         return rsbac_ta_list_lol_get_all_desc(0, handle, array_p);
00711 }

static long rsbac_list_lol_get_all_items ( rsbac_list_handle_t  handle,
void **  array_p 
) [inline, static]

Definition at line 807 of file lists.h.

References rsbac_ta_list_lol_get_all_items().

00809 {
00810         return rsbac_ta_list_lol_get_all_items(0, handle, array_p);
00811 }

static long rsbac_list_lol_get_all_subdata ( rsbac_list_handle_t  handle,
void *  desc,
void **  array_p 
) [inline, static]

Definition at line 732 of file lists.h.

References rsbac_ta_list_lol_get_all_subdata().

00734 {
00735         return rsbac_ta_list_lol_get_all_subdata(0, handle, desc, array_p);
00736 }

static long rsbac_list_lol_get_all_subdesc ( rsbac_list_handle_t  handle,
void *  desc,
void **  array_p 
) [inline, static]

Definition at line 685 of file lists.h.

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().

00687 {
00688         return rsbac_ta_list_lol_get_all_subdesc_ttl(0, handle,
00689                                                      desc, array_p, NULL);
00690 }

static long rsbac_list_lol_get_all_subdesc_ttl ( rsbac_list_handle_t  handle,
void *  desc,
void **  array_p,
rsbac_time_t **  ttl_array_p 
) [inline, static]

Definition at line 692 of file lists.h.

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().

00696 {
00697         return rsbac_ta_list_lol_get_all_subdesc_ttl(0,
00698                                                      handle,
00699                                                      desc,
00700                                                      array_p, ttl_array_p);
00701 }

static long rsbac_list_lol_get_all_subitems ( rsbac_list_handle_t  handle,
void *  desc,
void **  array_p 
) [inline, static]

Definition at line 796 of file lists.h.

References NULL, and rsbac_ta_list_lol_get_all_subitems_ttl().

00798 {
00799         return rsbac_ta_list_lol_get_all_subitems_ttl(0, handle, desc,
00800                                                       array_p, NULL);
00801 }

static long rsbac_list_lol_get_all_subitems_ttl ( rsbac_list_handle_t  handle,
void *  desc,
void **  array_p,
rsbac_time_t **  ttl_array_p 
) [inline, static]

Definition at line 786 of file lists.h.

References rsbac_ta_list_lol_get_all_subitems_ttl().

00790 {
00791         return rsbac_ta_list_lol_get_all_subitems_ttl(0, handle, desc,
00792                                                       array_p,
00793                                                       ttl_array_p);
00794 }

static int rsbac_list_lol_get_data ( rsbac_list_handle_t  handle,
void *  desc,
void *  data 
) [inline, static]

Definition at line 502 of file lists.h.

References NULL, and rsbac_ta_list_lol_get_data_ttl().

Referenced by rsbac_um_set_pass().

00504 {
00505         return rsbac_ta_list_lol_get_data_ttl(0, handle, NULL, desc, data);
00506 }

static int rsbac_list_lol_get_data_ttl ( rsbac_list_handle_t  handle,
rsbac_time_t ttl_p,
void *  desc,
void *  data 
) [inline, static]

Definition at line 494 of file lists.h.

References rsbac_ta_list_lol_get_data_ttl().

00497 {
00498         return rsbac_ta_list_lol_get_data_ttl(0, handle, ttl_p, desc,
00499                                               data);
00500 }

static int rsbac_list_lol_get_desc ( rsbac_list_handle_t  handle,
void *  desc,
void *  data,
rsbac_list_data_compare_function_t  compare 
) [inline, static]

Definition at line 536 of file lists.h.

References rsbac_ta_list_lol_get_desc().

00540 {
00541         return rsbac_ta_list_lol_get_desc(0, handle, desc, data, compare);
00542 }

int rsbac_list_lol_get_item_size ( rsbac_list_handle_t  handle  ) 

Definition at line 9773 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_EINVALIDLIST, RSBAC_ENOTINITIALIZED, and rsbac_list_lol_reg_item_t::self.

09774 {
09775         struct rsbac_list_lol_reg_item_t *list;
09776 
09777         if (!handle)
09778                 return -RSBAC_EINVALIDLIST;
09779         if (!list_initialized)
09780                 return -RSBAC_ENOTINITIALIZED;
09781 
09782         list = (struct rsbac_list_lol_reg_item_t *) handle;
09783         if (list->self != list)
09784                 return -RSBAC_EINVALIDLIST;
09785         return list->info.desc_size + list->info.data_size;
09786 }

static int rsbac_list_lol_get_next_desc ( rsbac_list_handle_t  handle,
void *  old_desc,
void *  next_desc 
) [inline, static]

Definition at line 572 of file lists.h.

References rsbac_ta_list_lol_get_next_desc().

00574 {
00575         return rsbac_ta_list_lol_get_next_desc(0, handle, old_desc,
00576                                                next_desc);
00577 }

long rsbac_list_lol_get_nr_hashes ( rsbac_list_handle_t  handle  ) 

Definition at line 10635 of file gen_lists.c.

References list_initialized, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, and rsbac_list_lol_reg_item_t::self.

10636 {
10637         struct rsbac_list_lol_reg_item_t *list;
10638 
10639         if (!handle)
10640                 return -RSBAC_EINVALIDLIST;
10641         if (!list_initialized)
10642                 return -RSBAC_ENOTINITIALIZED;
10643 
10644         list = (struct rsbac_list_lol_reg_item_t *) handle;
10645         if (list->self != list)
10646                 return -RSBAC_EINVALIDLIST;
10647 
10648         return list->nr_hashes;
10649 }

static int rsbac_list_lol_get_subdata ( rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc,
void *  subdata 
) [inline, static]

Definition at line 480 of file lists.h.

References NULL, and rsbac_ta_list_lol_get_subdata_ttl().

Referenced by rsbac_rc_check_comp(), and rsbac_ta_get_attr().

00482 {
00483         return rsbac_ta_list_lol_get_subdata_ttl(0, handle, NULL, desc,
00484                                                  subdesc, subdata);
00485 }

static int rsbac_list_lol_get_subdata_ttl ( rsbac_list_handle_t  handle,
rsbac_time_t ttl_p,
void *  desc,
void *  subdesc,
void *  subdata 
) [inline, static]

Definition at line 470 of file lists.h.

References rsbac_ta_list_lol_get_subdata_ttl().

00474 {
00475         return rsbac_ta_list_lol_get_subdata_ttl(0, handle,
00476                                                  ttl_p, desc, subdesc,
00477                                                  subdata);
00478 }

int rsbac_list_lol_get_subitem_size ( rsbac_list_handle_t  handle  ) 

Definition at line 9755 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::info, list_initialized, RSBAC_EINVALIDLIST, 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().

09756 {
09757         struct rsbac_list_lol_reg_item_t *list;
09758 
09759         if (!handle)
09760                 return -RSBAC_EINVALIDLIST;
09761         if (!list_initialized)
09762                 return -RSBAC_ENOTINITIALIZED;
09763 
09764         list = (struct rsbac_list_lol_reg_item_t *) handle;
09765         if (list->self != list)
09766                 return -RSBAC_EINVALIDLIST;
09767         return list->info.subdesc_size + list->info.subdata_size;
09768 }

int rsbac_list_lol_max_items ( rsbac_list_handle_t  handle,
rsbac_list_key_t  key,
u_int  max_items,
u_int  max_subitems 
)

Definition at line 6467 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::info, rsbac_list_lol_info_t::key, list_initialized, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_reg(), rsbac_list_lol_reg_item_t::max_items_per_hash, rsbac_list_lol_reg_item_t::max_subitems, rsbac_list_lol_reg_item_t::name, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, RSBAC_LIST_MAX_NR_ITEMS_LIMIT, rsbac_min, and rsbac_printk().

06469 {
06470         struct rsbac_list_lol_reg_item_t *reg_item_p;
06471         u_long lock_flags;
06472 
06473         if (!handle)
06474                 return -RSBAC_EINVALIDLIST;
06475         if (!list_initialized)
06476                 return -RSBAC_ENOTINITIALIZED;
06477 
06478         rsbac_read_lock(&lol_reg_head.lock, &lock_flags);
06479         reg_item_p = lookup_lol_reg((struct rsbac_list_lol_reg_item_t *) handle);
06480         if (!reg_item_p) {
06481                 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06482                 rsbac_printk(KERN_WARNING "rsbac_list_lol_max_items: setting max_items_per_hash for list denied due to invalid handle!\n");
06483                 return -RSBAC_EINVALIDLIST;
06484         }
06485         if (reg_item_p->info.key != key) {
06486                 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06487                 rsbac_printk(KERN_WARNING "rsbac_list_lol_max_items: setting max_items_per_hash for list %s denied due to invalid key %u!\n",
06488                              reg_item_p->name, key);
06489                 return -EPERM;
06490         }
06491         reg_item_p->max_items_per_hash = rsbac_min(max_items, RSBAC_LIST_MAX_NR_ITEMS_LIMIT);
06492         reg_item_p->max_subitems = rsbac_min(max_subitems, RSBAC_LIST_MAX_NR_ITEMS_LIMIT);
06493         rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06494         return 0;
06495 }

int rsbac_list_lol_no_write ( rsbac_list_handle_t  handle,
rsbac_list_key_t  key,
rsbac_boolean_t  no_write 
)

Definition at line 6398 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, lol_reg_head, lookup_lol_reg(), rsbac_list_lol_reg_item_t::name, rsbac_list_lol_reg_item_t::no_write, RSBAC_EINVALIDLIST, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_printk(), and TRUE.

06400 {
06401         struct rsbac_list_lol_reg_item_t *reg_item_p;
06402         u_long lock_flags;
06403 
06404         if (!handle)
06405                 return -RSBAC_EINVALIDLIST;
06406         if ((no_write != FALSE) && (no_write != TRUE))
06407                 return -RSBAC_EINVALIDVALUE;
06408         if (!list_initialized)
06409                 return -RSBAC_ENOTINITIALIZED;
06410 
06411         rsbac_read_lock(&lol_reg_head.lock, &lock_flags);
06412         reg_item_p =
06413             lookup_lol_reg((struct rsbac_list_lol_reg_item_t *) handle);
06414         if (!reg_item_p) {
06415                 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06416                 rsbac_printk(KERN_WARNING "rsbac_list_lol_no_write: setting no_write for list denied due to invalid handle!\n");
06417                 return -RSBAC_EINVALIDLIST;
06418         }
06419         if (reg_item_p->info.key != key) {
06420                 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06421                 rsbac_printk(KERN_WARNING "rsbac_list_lol_no_write: setting no_write for list %s denied due to invalid key %u!\n",
06422                              reg_item_p->name, key);
06423                 return -EPERM;
06424         }
06425         reg_item_p->no_write = no_write;
06426         rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
06427         return 0;
06428 }

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 6083 of file gen_lists.c.

References NULL, and rsbac_list_lol_register_hashed().

Referenced by rsbac_init_acl(), rsbac_init_mac(), and rsbac_init_pm().

06092                                                                           {
06093         return rsbac_list_lol_register_hashed (ds_version, handle_p, info_p,
06094                                 flags, compare, subcompare, get_conv,
06095                                 get_subconv, def_data, def_subdata,
06096                                 name, device,
06097                                 1, NULL, NULL);
06098 }

int rsbac_list_lol_register_hashed ( 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,
u_int  nr_hashes,
rsbac_list_hash_function_t  hash_function,
char *  old_base_name 
)

Definition at line 5932 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, lol_reg_head, 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(), reg_head, RSBAC_ECOULDNOTADDITEM, RSBAC_EEXISTS, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDVALUE, RSBAC_EINVALIDVERSION, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, RSBAC_LIST_AUTO_HASH_RESIZE, RSBAC_LIST_BACKUP, rsbac_list_lol_max_hashes, RSBAC_LIST_MAX_AGE_LIMIT, RSBAC_LIST_MAX_ITEM_SIZE, RSBAC_LIST_VERSION, RSBAC_MAXNAMELEN, rsbac_pr_debug, 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_rc(), rsbac_init_um(), and rsbac_list_lol_register().

05945 {
05946         struct rsbac_list_lol_reg_item_t *reg_item_p;
05947         struct rsbac_list_lol_reg_item_t *new_reg_item_p;
05948         u_long lock_flags;
05949         int err = 0;
05950 
05951         if (ds_version != RSBAC_LIST_VERSION)
05952                 return -RSBAC_EINVALIDVERSION;
05953         if (!handle_p)
05954                 return -RSBAC_EINVALIDPOINTER;
05955         *handle_p = NULL;
05956         if (!list_initialized)
05957                 return -RSBAC_ENOTINITIALIZED;
05958         if (!info_p->key || !info_p->version || !info_p->desc_size)
05959                 return -RSBAC_EINVALIDVALUE;
05960         if (info_p->max_age > RSBAC_LIST_MAX_AGE_LIMIT)
05961                 return -RSBAC_EINVALIDVALUE;
05962         if (info_p->desc_size + info_p->data_size >
05963             RSBAC_LIST_MAX_ITEM_SIZE)
05964                 return -RSBAC_EINVALIDVALUE;
05965         if (info_p->subdesc_size + info_p->subdata_size >
05966             RSBAC_LIST_MAX_ITEM_SIZE)
05967                 return -RSBAC_EINVALIDVALUE;
05968         if (nr_hashes > rsbac_list_lol_max_hashes)
05969                 nr_hashes = rsbac_list_lol_max_hashes;
05970         else if (nr_hashes > 2) {
05971                 u_int i = 1;
05972 
05973                 while ((i << 1) <= nr_hashes) 
05974                         i = i << 1;
05975                 nr_hashes = i;
05976         }
05977         if (!hash_function) {
05978                 nr_hashes = 1;
05979                 flags &= ~RSBAC_LIST_AUTO_HASH_RESIZE;
05980         } else
05981                 if (!nr_hashes)
05982                         nr_hashes = 1;
05983         if (name) {
05984                 struct rsbac_list_reg_item_t *std_reg_item_p;
05985 
05986                 rsbac_read_lock(&lol_reg_head.lock, &lock_flags);
05987                 reg_item_p = lookup_lol_reg_name(name, device);
05988                 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
05989                 if (reg_item_p) {
05990                         rsbac_pr_debug(lists, "list name %s already exists on device %02u:%02u!\n",
05991                                        name, RSBAC_MAJOR(device),
05992                                        RSBAC_MINOR(device));
05993                         return -RSBAC_EEXISTS;
05994                 }
05995                 rsbac_read_lock(&reg_head.lock, &lock_flags);
05996                 std_reg_item_p = lookup_reg_name(name, device);
05997                 rsbac_read_unlock(&reg_head.lock, &lock_flags);
05998                 if (std_reg_item_p) {
05999                         rsbac_pr_debug(lists, "list name %s already exists on device %02u:%02u!\n",
06000                                        name, RSBAC_MAJOR(device),
06001                                        RSBAC_MINOR(device));
06002                         return -RSBAC_EEXISTS;
06003                 }
06004         } else if (flags & RSBAC_LIST_PERSIST) {
06005                 rsbac_printk(KERN_WARNING "rsbac_list_lol_register: trial to register persistent list of lists without name.\n");
06006                 return -RSBAC_EINVALIDVALUE;
06007         }
06008 
06009         if (flags & RSBAC_LIST_PERSIST) {
06010                 if (RSBAC_IS_AUTO_DEV(device))
06011                         device = rsbac_root_dev;
06012                 if (!RSBAC_MAJOR(device))
06013                         flags &= ~RSBAC_LIST_PERSIST;
06014         }
06015         rsbac_pr_debug(lists, "registering list of lists %s.\n",
06016                        name);
06017         new_reg_item_p = create_lol_reg(info_p, flags, compare, subcompare,
06018                                         get_conv, get_subconv,
06019                                         def_data, def_subdata,
06020                                         name, device,
06021                                         nr_hashes, hash_function,
06022                                         old_base_name);
06023         if (!new_reg_item_p) {
06024                 return -RSBAC_ECOULDNOTADDITEM;
06025         }
06026         /* Restore from disk */
06027         if (flags & RSBAC_LIST_PERSIST) {
06028                 rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u.\n",
06029                                name, RSBAC_MAJOR(device),
06030                                RSBAC_MINOR(device));
06031                 err = read_lol_list(new_reg_item_p);
06032                 /* not found is no error */
06033                 if (err == -RSBAC_ENOTFOUND)
06034                         err = 0;
06035                 else if (err) {
06036                         char tmp[RSBAC_MAXNAMELEN];
06037                         rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u failed with error %s, unregistering list.\n",
06038                                        name, RSBAC_MAJOR(device),
06039                                        RSBAC_MINOR(device),
06040                                        get_error_name(tmp, err));
06041                         clear_lol_reg(new_reg_item_p);
06042                         return err;
06043                 } else
06044                         rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u was successful.\n",
06045                                        name, RSBAC_MAJOR(device),
06046                                        RSBAC_MINOR(device));
06047         }
06048 
06049         rsbac_write_lock(&lol_reg_head.lock, &lock_flags);
06050         reg_item_p = add_lol_reg(new_reg_item_p);
06051         rsbac_write_unlock(&lol_reg_head.lock, &lock_flags);
06052         if (!reg_item_p) {
06053                 rsbac_printk(KERN_WARNING "rsbac_list_lol_register: inserting list %s failed!\n",
06054                              name);
06055                 /* cleanup */
06056                 clear_lol_reg(new_reg_item_p);
06057                 return -RSBAC_ECOULDNOTADDITEM;
06058         }
06059 
06060         /* finish */
06061 #if defined(CONFIG_RSBAC_PROC)
06062         /* create proc entry, if requested */
06063         if (flags & RSBAC_LIST_BACKUP) {
06064                 reg_item_p->proc_entry_p =
06065                     create_proc_entry(reg_item_p->name, S_IFREG | S_IRUGO,
06066                                       proc_rsbac_backup_p);
06067                 if (reg_item_p->proc_entry_p) {
06068                         reg_item_p->proc_entry_p->read_proc =
06069                             lol_backup_proc_read;
06070                         reg_item_p->proc_entry_p->data = reg_item_p;
06071                 }
06072         } else {
06073                 reg_item_p->proc_entry_p = NULL;
06074         }
06075 #endif
06076         *handle_p = reg_item_p;
06077         return err;
06078 }

static int rsbac_list_lol_remove ( rsbac_list_handle_t  handle,
void *  desc 
) [inline, static]

Definition at line 426 of file lists.h.

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(), rsbac_check_acl(), and set_attr_fd().

00427 {
00428         return rsbac_ta_list_lol_remove(0, handle, desc);
00429 }

static int rsbac_list_lol_remove_all ( rsbac_list_handle_t  handle  )  [inline, static]

Definition at line 434 of file lists.h.

References rsbac_ta_list_lol_remove_all().

Referenced by set_attr_fd().

00435 {
00436         return rsbac_ta_list_lol_remove_all(0, handle);
00437 }

static int rsbac_list_lol_subadd ( rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc,
void *  subdata 
) [inline, static]

Definition at line 344 of file lists.h.

References RSBAC_LIST_TTL_KEEP, and rsbac_ta_list_lol_subadd_ttl().

Referenced by acl_create_def(), create_def_roles(), create_def_roles2(), rsbac_auth_p_capset_member(), rsbac_init_rc(), rsbac_pm_pp_intersec(), rsbac_pm_pp_union(), and rsbac_um_set_pass().

00346 {
00347         return rsbac_ta_list_lol_subadd_ttl(0, handle, RSBAC_LIST_TTL_KEEP,
00348                                             desc, subdesc, subdata);
00349 }

static int rsbac_list_lol_subadd_ttl ( rsbac_list_handle_t  handle,
rsbac_time_t  ttl,
void *  desc,
void *  subdesc,
void *  subdata 
) [inline, static]

Definition at line 336 of file lists.h.

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(), copy_pp_tru_set_item_handle(), and rsbac_ta_get_attr().

00339 {
00340         return rsbac_ta_list_lol_subadd_ttl(0, handle, ttl, desc, subdesc,
00341                                             subdata);
00342 }

static long rsbac_list_lol_subcount ( rsbac_list_handle_t  handle,
void *  desc 
) [inline, static]

Definition at line 642 of file lists.h.

References rsbac_ta_list_lol_subcount().

Referenced by rsbac_pm_pp_only(), and rsbac_um_set_pass().

00643 {
00644         return rsbac_ta_list_lol_subcount(0, handle, desc);
00645 }

static int rsbac_list_lol_subexist ( rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc 
) [inline, static]

Definition at line 593 of file lists.h.

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().

00595 {
00596         return rsbac_ta_list_lol_subexist(0, handle, desc, subdesc);
00597 }

static int rsbac_list_lol_subexist_compare ( rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc,
rsbac_list_compare_function_t  compare 
) [inline, static]

Definition at line 620 of file lists.h.

References rsbac_ta_list_lol_subexist_compare().

Referenced by rsbac_auth_p_capset_member().

00624 {
00625         return rsbac_ta_list_lol_subexist_compare(0, handle,
00626                                                   desc, subdesc, compare);
00627 }

static int rsbac_list_lol_subremove ( rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc 
) [inline, static]

Definition at line 391 of file lists.h.

References rsbac_ta_list_lol_subremove().

Referenced by rsbac_check_acl(), and rsbac_pm_pp_intersec().

00393 {
00394         return rsbac_ta_list_lol_subremove(0, handle, desc, subdesc);
00395 }

static int rsbac_list_lol_subremove_all ( rsbac_list_handle_t  handle,
void *  desc 
) [inline, static]

Definition at line 418 of file lists.h.

References rsbac_ta_list_lol_subremove_all().

00419 {
00420         return rsbac_ta_list_lol_subremove_all(0, handle, desc);
00421 }

static int rsbac_list_lol_subremove_from_all ( rsbac_list_handle_t  handle,
void *  subdesc 
) [inline, static]

Definition at line 407 of file lists.h.

References rsbac_ta_list_lol_subremove_from_all().

00409 {
00410         return rsbac_ta_list_lol_subremove_from_all(0, handle, subdesc);
00411 }

int rsbac_list_max_items ( rsbac_list_handle_t  handle,
rsbac_list_key_t  key,
u_int  max_items 
)

Definition at line 6434 of file gen_lists.c.

References 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::max_items_per_hash, rsbac_list_reg_item_t::name, reg_head, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, RSBAC_LIST_MAX_NR_ITEMS_LIMIT, rsbac_min, and rsbac_printk().

06436 {
06437         struct rsbac_list_reg_item_t *reg_item_p;
06438         u_long lock_flags;
06439 
06440         if (!handle)
06441                 return -RSBAC_EINVALIDLIST;
06442         if (!list_initialized)
06443                 return -RSBAC_ENOTINITIALIZED;
06444 
06445         rsbac_read_lock(&reg_head.lock, &lock_flags);
06446         reg_item_p = lookup_reg((struct rsbac_list_reg_item_t *) handle);
06447         if (!reg_item_p) {
06448                 rsbac_read_unlock(&reg_head.lock, &lock_flags);
06449                 rsbac_printk(KERN_WARNING "rsbac_list_max_items: setting max_items_per_hash for list denied due to invalid handle!\n");
06450                 return -RSBAC_EINVALIDLIST;
06451         }
06452         if (reg_item_p->info.key != key) {
06453                 rsbac_read_unlock(&reg_head.lock, &lock_flags);
06454                 rsbac_printk(KERN_WARNING "rsbac_list_max_items: setting max_items_per_hash for list %s denied due to invalid key %u!\n",
06455                              reg_item_p->name, key);
06456                 return -EPERM;
06457         }
06458         reg_item_p->max_items_per_hash = rsbac_min(max_items, RSBAC_LIST_MAX_NR_ITEMS_LIMIT);
06459         rsbac_read_unlock(&reg_head.lock, &lock_flags);
06460         return 0;
06461 }

int rsbac_list_no_write ( rsbac_list_handle_t  handle,
rsbac_list_key_t  key,
rsbac_boolean_t  no_write 
)

Definition at line 6364 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, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_printk(), and TRUE.

06366 {
06367         struct rsbac_list_reg_item_t *reg_item_p;
06368         u_long lock_flags;
06369 
06370         if (!handle)
06371                 return -RSBAC_EINVALIDLIST;
06372         if ((no_write != FALSE) && (no_write != TRUE))
06373                 return -RSBAC_EINVALIDVALUE;
06374         if (!list_initialized)
06375                 return -RSBAC_ENOTINITIALIZED;
06376 
06377         rsbac_read_lock(&reg_head.lock, &lock_flags);
06378         reg_item_p = lookup_reg((struct rsbac_list_reg_item_t *) handle);
06379         if (!reg_item_p) {
06380                 rsbac_read_unlock(&reg_head.lock, &lock_flags);
06381                 rsbac_printk(KERN_WARNING "rsbac_list_no_write: setting no_write for list denied due to invalid handle!\n");
06382                 return -RSBAC_EINVALIDLIST;
06383         }
06384         if (reg_item_p->info.key != key) {
06385                 rsbac_read_unlock(&reg_head.lock, &lock_flags);
06386                 rsbac_printk(KERN_WARNING "rsbac_list_no_write: setting no_write for list %s denied due to invalid key %u!\n",
06387                              reg_item_p->name, key);
06388                 return -EPERM;
06389         }
06390         reg_item_p->no_write = no_write;
06391         rsbac_read_unlock(&reg_head.lock, &lock_flags);
06392         return 0;
06393 }

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 5870 of file gen_lists.c.

References NULL, and rsbac_list_register_hashed().

Referenced by init_module(), register_user_lists1(), register_user_lists2(), rsbac_init_acl(), rsbac_init_debug(), rsbac_init_pm(), and rsbac_list_init().

05877 {
05878         return rsbac_list_register_hashed(ds_version, handle_p, info_p, flags,
05879                                 compare, get_conv, def_data, name, device,
05880                                 1, NULL, NULL);
05881 }

int rsbac_list_register_hashed ( 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,
u_int  nr_hashes,
rsbac_list_hash_function_t  hash_function,
char *  old_base_name 
)

Definition at line 5722 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, lol_reg_head, 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(), reg_head, RSBAC_ECOULDNOTADDITEM, RSBAC_EEXISTS, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDVALUE, RSBAC_EINVALIDVERSION, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, RSBAC_LIST_AUTO_HASH_RESIZE, RSBAC_LIST_BACKUP, RSBAC_LIST_MAX_AGE_LIMIT, rsbac_list_max_hashes, RSBAC_LIST_MAX_ITEM_SIZE, RSBAC_LIST_VERSION, RSBAC_MAXNAMELEN, rsbac_pr_debug, rsbac_printk(), rsbac_root_dev, and rsbac_list_info_t::version.

Referenced by register_dev_lists(), register_fd_lists(), register_ipc_lists(), register_process_lists(), register_user_lists1(), register_user_lists2(), rsbac_init_acl(), rsbac_init_rc(), rsbac_init_um(), and rsbac_list_register().

05732 {
05733         struct rsbac_list_reg_item_t *reg_item_p;
05734         struct rsbac_list_reg_item_t *new_reg_item_p;
05735         u_long lock_flags;
05736         int err = 0;
05737 
05738         if (ds_version != RSBAC_LIST_VERSION) {
05739                 if (name) {
05740                         rsbac_printk(KERN_WARNING "rsbac_list_register: wrong ds_version %u for list %s, expected %u!\n",
05741                                      ds_version, name, RSBAC_LIST_VERSION);
05742                 }
05743                 return -RSBAC_EINVALIDVERSION;
05744         }
05745         if (!handle_p || !info_p)
05746                 return -RSBAC_EINVALIDPOINTER;
05747         *handle_p = NULL;
05748         if (!list_initialized)
05749                 return -RSBAC_ENOTINITIALIZED;
05750         if (!info_p->key || !info_p->version || !info_p->desc_size)
05751                 return -RSBAC_EINVALIDVALUE;
05752         if (info_p->max_age > RSBAC_LIST_MAX_AGE_LIMIT)
05753                 return -RSBAC_EINVALIDVALUE;
05754         if (info_p->desc_size + info_p->data_size >
05755             RSBAC_LIST_MAX_ITEM_SIZE)
05756                 return -RSBAC_EINVALIDVALUE;
05757         if (nr_hashes > rsbac_list_max_hashes)
05758                 nr_hashes = rsbac_list_max_hashes;
05759         else if (nr_hashes > 2) {
05760                 u_int i = 1;
05761 
05762                 while ((i << 1) <= nr_hashes) 
05763                         i = i << 1;
05764                 nr_hashes = i;
05765         }
05766         if (!hash_function) {
05767                 nr_hashes = 1;
05768                 flags &= ~RSBAC_LIST_AUTO_HASH_RESIZE;
05769         } else
05770                 if (!nr_hashes)
05771                         nr_hashes = 1;
05772         if (name) {
05773                 struct rsbac_list_lol_reg_item_t *lol_reg_item_p;
05774 
05775                 rsbac_read_lock(&reg_head.lock, &lock_flags);
05776                 reg_item_p = lookup_reg_name(name, device);
05777                 rsbac_read_unlock(&reg_head.lock, &lock_flags);
05778                 if (reg_item_p) {
05779                         rsbac_pr_debug(lists, "list name %s already exists on device %02u:%02u!\n",
05780                                        name, RSBAC_MAJOR(device),
05781                                        RSBAC_MINOR(device));
05782                         return -RSBAC_EEXISTS;
05783                 }
05784                 rsbac_read_lock(&lol_reg_head.lock, &lock_flags);
05785                 lol_reg_item_p = lookup_lol_reg_name(name, device);
05786                 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags);
05787                 if (lol_reg_item_p) {
05788                         rsbac_pr_debug(lists, "list name %s already exists on device %02u:%02u!\n",
05789                                        name, RSBAC_MAJOR(device),
05790                                        RSBAC_MINOR(device));
05791                         return -RSBAC_EEXISTS;
05792                 }
05793         } else if (flags & RSBAC_LIST_PERSIST) {
05794                 rsbac_printk(KERN_WARNING "rsbac_list_register: trial to register persistent list without name.\n");
05795                 return -RSBAC_EINVALIDVALUE;
05796         }
05797 
05798         if (flags & RSBAC_LIST_PERSIST) {
05799                 if (RSBAC_IS_AUTO_DEV(device))
05800                         device = rsbac_root_dev;
05801                 if (!RSBAC_MAJOR(device))
05802                         flags &= ~RSBAC_LIST_PERSIST;
05803         }
05804         rsbac_pr_debug(lists, "registering list %s for device %02u:%02u.\n",
05805                        name, RSBAC_MAJOR(device), RSBAC_MINOR(device));
05806         new_reg_item_p =
05807             create_reg(info_p, flags, compare, get_conv, def_data, name,
05808                        device, nr_hashes, hash_function, old_base_name);
05809         if (!new_reg_item_p) {
05810                 return -RSBAC_ECOULDNOTADDITEM;
05811         }
05812         /* Restore from disk, but only for real device mounts */
05813         if ((flags & RSBAC_LIST_PERSIST)
05814             && RSBAC_MAJOR(device)
05815             ) {
05816                 rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u.\n",
05817                                name, RSBAC_MAJOR(device), RSBAC_MINOR(device));
05818                 err = read_list(new_reg_item_p);
05819                 /* not found is no error */
05820                 if (err == -RSBAC_ENOTFOUND)
05821                         err = 0;
05822                 else if (err) {
05823                         char tmp[RSBAC_MAXNAMELEN];
05824                         rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u failed with error %s, unregistering list.\n", name,
05825                                        RSBAC_MAJOR(device),
05826                                        RSBAC_MINOR(device),
05827                                        get_error_name(tmp, err));
05828                         clear_reg(new_reg_item_p);
05829                         return err;
05830                 } else
05831                         rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u was successful.\n",
05832                                        name, RSBAC_MAJOR(device),
05833                                        RSBAC_MINOR(device));
05834         }
05835 
05836         rsbac_write_lock(&reg_head.lock, &lock_flags);
05837         reg_item_p = add_reg(new_reg_item_p);
05838         rsbac_write_unlock(&reg_head.lock, &lock_flags);
05839         if (!reg_item_p) {
05840                 rsbac_printk(KERN_WARNING "rsbac_list_register: inserting list %s failed!\n",
05841                              name);
05842                 /* cleanup */
05843                 clear_reg(new_reg_item_p);
05844                 return -RSBAC_ECOULDNOTADDITEM;
05845         }
05846 
05847         /* finish */
05848 #if defined(CONFIG_RSBAC_PROC)
05849         /* create proc entry, if requested */
05850         if (flags & RSBAC_LIST_BACKUP) {
05851                 reg_item_p->proc_entry_p =
05852                     create_proc_entry(reg_item_p->name, S_IFREG | S_IRUGO,
05853                                       proc_rsbac_backup_p);
05854                 if (reg_item_p->proc_entry_p) {
05855                         reg_item_p->proc_entry_p->read_proc =
05856                             backup_proc_read;
05857                         reg_item_p->proc_entry_p->data = reg_item_p;
05858                 }
05859         } else {
05860                 reg_item_p->proc_entry_p = NULL;
05861         }
05862 #endif
05863         *handle_p = reg_item_p;
05864         return err;
05865 }

static int rsbac_list_remove ( rsbac_list_handle_t  handle,
void *  desc 
) [inline, static]

Definition at line 372 of file lists.h.

References rsbac_ta_list_remove().

00373 {
00374         return rsbac_ta_list_remove(0, handle, desc);
00375 }

static int rsbac_list_remove_all ( rsbac_list_handle_t  handle  )  [inline, static]

Definition at line 381 of file lists.h.

References rsbac_ta_list_remove_all().

00382 {
00383         return rsbac_ta_list_remove_all(0, handle);
00384 }

rsbac_version_t rsbac_list_version ( void   ) 

Definition at line 5676 of file gen_lists.c.

References RSBAC_LIST_VERSION.

05677 {
05678         return RSBAC_LIST_VERSION;
05679 }

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 6773 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::hash_function, rsbac_list_reg_item_t::hashed, 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_reg_item_t::nr_hashes, reg_head, RSBAC_EBUSY, RSBAC_EINVALIDLIST, 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().

06776 {
06777         struct rsbac_list_reg_item_t *list;
06778         struct rsbac_list_item_t *item_p;
06779         u_long lock_flags, rlock_flags;
06780         u_int hash = 0;
06781 
06782         if (!handle)
06783                 return -RSBAC_EINVALIDLIST;
06784         if (!desc)
06785                 return -RSBAC_EINVALIDVALUE;
06786         if (!list_initialized)
06787                 return -RSBAC_ENOTINITIALIZED;
06788 
06789         list = (struct rsbac_list_reg_item_t *) handle;
06790         if (!list || (list->self != list))
06791                 return -RSBAC_EINVALIDLIST;
06792 
06793 #ifdef CONFIG_RSBAC_LIST_TRANS
06794         if (ta_number && !rsbac_ta_list_exist(0, ta_handle, &ta_number))
06795                 return -RSBAC_EINVALIDTRANSACTION;
06796 #endif
06797 
06798         rsbac_read_lock(&reg_head.lock, &rlock_flags);
06799         if (list->info.data_size && !data) {
06800                 rsbac_read_unlock(&reg_head.lock, &rlock_flags);
06801                 return -RSBAC_EINVALIDVALUE;
06802         }
06803 
06804 /*
06805         rsbac_pr_debug(lists, "adding to list %s.\n", list->name);
06806 */
06807         if (ttl && (ttl != RSBAC_LIST_TTL_KEEP)) {
06808                 if (ttl > RSBAC_LIST_MAX_AGE_LIMIT)
06809                         ttl = RSBAC_LIST_MAX_AGE_LIMIT;
06810                 ttl += RSBAC_CURRENT_TIME;
06811         }
06812         rsbac_write_lock(&list->lock, &lock_flags);
06813 
06814         if(list->hash_function)
06815                 hash = list->hash_function(desc, list->nr_hashes);
06816 #ifdef CONFIG_RSBAC_LIST_TRANS
06817         if (!ta_number)
06818 #endif
06819         {
06820                 item_p = lookup_item(list, desc);
06821                 if (item_p) {   /* exists -> update data, if any */
06822                         if (ttl != RSBAC_LIST_TTL_KEEP)
06823                                 item_p->max_age = ttl;
06824                         if (data && list->info.data_size) {
06825                                 if (list->def_data
06826                                     && !item_p->max_age
06827                                     && !memcmp(list->def_data, data,
06828                                                list->info.data_size)
06829                                     )
06830                                         do_remove_item(list, item_p, hash);
06831                                 else
06832                                         memcpy(((char *) item_p) +
06833                                                sizeof(*item_p) +
06834                                                list->info.desc_size, data,
06835                                                list->info.data_size);
06836                         }
06837                 } else {
06838                         if (ttl == RSBAC_LIST_TTL_KEEP)
06839                                 ttl = 0;
06840                         if (!list->def_data
06841                             || memcmp(list->def_data, data,
06842                                       list->info.data_size)
06843                             )
06844                                 add_item(list, ttl, desc, data);
06845                 }
06846                 touch(list);
06847                 list->dirty = TRUE;
06848         }
06849 #ifdef CONFIG_RSBAC_LIST_TRANS
06850         if (list->hashed[hash].ta_copied || ta_number) {
06851                 if (!list->hashed[hash].ta_copied)
06852                         ta_copy(ta_number, list, hash);
06853                 else if (ta_number) {
06854                         if (list->hashed[hash].ta_copied != ta_number) {
06855                                 rsbac_write_unlock(&list->lock,
06856                                                    &lock_flags);
06857                                 rsbac_read_unlock(&reg_head.lock,
06858                                                   &rlock_flags);
06859                                 return -RSBAC_EBUSY;
06860                         }
06861                 } else
06862                         ta_number = list->hashed[hash].ta_copied;
06863                 item_p = ta_lookup_item(ta_number, list, desc);
06864                 if (item_p) {   /* exists -> update data, if any */
06865                         if (ttl != RSBAC_LIST_TTL_KEEP)
06866                                 item_p->max_age = ttl;
06867                         if (data && list->info.data_size) {
06868                                 if (list->def_data
06869                                     && !item_p->max_age
06870                                     && !memcmp(list->def_data, data,
06871                                                list->info.data_size)
06872                                     )
06873                                         ta_do_remove_item(list, item_p, hash);
06874                                 else
06875                                         memcpy(((char *) item_p) +
06876                                                sizeof(*item_p) +
06877                                                list->info.desc_size, data,
06878                                                list->info.data_size);
06879                         }
06880                 } else {
06881                         if (ttl == RSBAC_LIST_TTL_KEEP)
06882                                 ttl = 0;
06883                         if (!list->def_data
06884                             || memcmp(list->def_data, data,
06885                                       list->info.data_size)
06886                             )
06887                                 ta_add_item(ta_number, list, ttl, desc,
06888                                             data);
06889                 }
06890         }
06891 #endif
06892         rsbac_write_unlock(&list->lock, &lock_flags);
06893         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
06894         return 0;
06895 }

long rsbac_ta_list_count ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle 
)

Definition at line 9107 of file gen_lists.c.

References rsbac_list_hashed_t::count, rsbac_list_reg_item_t::hashed, list_initialized, rsbac_list_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, 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_ipc(), rsbac_ta_list_all_user(), and rsbac_um_get_group_list().

09109 {
09110         struct rsbac_list_reg_item_t *list;
09111         long result = 0;
09112         int i;
09113 
09114         if (!handle)
09115                 return -RSBAC_EINVALIDLIST;
09116         if (!list_initialized)
09117                 return -RSBAC_ENOTINITIALIZED;
09118 
09119         list = (struct rsbac_list_reg_item_t *) handle;
09120         if (list->self != list)
09121                 return -RSBAC_EINVALIDLIST;
09122 
09123 #ifdef CONFIG_RSBAC_LIST_TRANS
09124         if (ta_number) {
09125                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09126                         return -RSBAC_EINVALIDTRANSACTION;
09127         }
09128 #endif
09129 
09130         for (i=0; i<list->nr_hashes; i++) {
09131 #ifdef CONFIG_RSBAC_LIST_TRANS
09132                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
09133                         result += list->hashed[i].ta_count;
09134                 else
09135 #endif
09136                         result += list->hashed[i].count;
09137         }
09138         return result;
09139 }

int rsbac_ta_list_exist ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc 
)

Definition at line 8707 of file gen_lists.c.

References FALSE, rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, lookup_item(), rsbac_list_item_t::max_age, rsbac_list_reg_item_t::nr_hashes, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, 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_copy(), rsbac_list_exist(), rsbac_list_lol_copy(), 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_max_subdesc(), 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_count(), 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().

08709 {
08710         struct rsbac_list_reg_item_t *list;
08711         u_long lock_flags, rlock_flags;
08712         struct rsbac_list_item_t *item_p;
08713         int result;
08714 #ifdef CONFIG_RSBAC_LIST_TRANS
08715         u_int hash = 0;
08716 #endif
08717 
08718         if (!handle || !desc)
08719                 return FALSE;
08720         if (!list_initialized)
08721                 return FALSE;
08722 
08723         list = (struct rsbac_list_reg_item_t *) handle;
08724         if (list->self != list)
08725                 return -RSBAC_EINVALIDLIST;
08726 
08727 #ifdef CONFIG_RSBAC_LIST_TRANS
08728         if (ta_number) {
08729                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08730                         return -RSBAC_EINVALIDTRANSACTION;
08731                 if(list->hash_function)
08732                         hash = list->hash_function(desc, list->nr_hashes);
08733         }
08734 #endif
08735 
08736         rsbac_read_lock(&reg_head.lock, &rlock_flags);
08737 /*
08738         rsbac_pr_debug(lists, "testing on list %s.\n", list->name);
08739 */
08740         rsbac_read_lock(&list->lock, &lock_flags);
08741 
08742 #ifdef CONFIG_RSBAC_LIST_TRANS
08743         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08744                 item_p = ta_lookup_item(ta_number, list, desc);
08745         else
08746 #endif
08747                 item_p = lookup_item(list, desc);
08748         if (item_p
08749             && (!item_p->max_age || (item_p->max_age > RSBAC_CURRENT_TIME)
08750             )
08751             ) {                 /* exists -> TRUE */
08752                 result = TRUE;
08753         } else {
08754                 result = FALSE;
08755         }
08756         rsbac_read_unlock(&list->lock, &lock_flags);
08757         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08758         return result;
08759 }

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 9443 of file gen_lists.c.

References rsbac_list_hashed_t::count, rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_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, rsbac_list_reg_item_t::nr_hashes, NULL, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, 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().

09445 {
09446         struct rsbac_list_reg_item_t *list;
09447         struct rsbac_list_item_t *item_p;
09448         char *buffer;
09449         u_long lock_flags, rlock_flags;
09450         u_long offset = 0;
09451         long result = 0;
09452         u_int item_size;
09453         u_int item_offset;
09454         int i;
09455         u_long count = 0;
09456 
09457         if (!handle)
09458                 return -RSBAC_EINVALIDLIST;
09459         if (!array_p)
09460                 return -RSBAC_EINVALIDPOINTER;
09461         if (!list_initialized)
09462                 return -RSBAC_ENOTINITIALIZED;
09463 
09464         list = (struct rsbac_list_reg_item_t *) handle;
09465         if (list->self != list)
09466                 return -RSBAC_EINVALIDLIST;
09467         *array_p = NULL;
09468 
09469 #ifdef CONFIG_RSBAC_LIST_TRANS
09470         if (ta_number) {
09471                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09472                         return -RSBAC_EINVALIDTRANSACTION;
09473         }
09474 #endif
09475 
09476         rsbac_read_lock(&reg_head.lock, &rlock_flags);
09477 /*
09478         rsbac_pr_debug(lists, "list %s.\n", list->name);
09479 */
09480         rsbac_read_lock(&list->lock, &lock_flags);
09481         if (!list->info.data_size) {
09482                 rsbac_read_unlock(&list->lock, &lock_flags);
09483                 rsbac_read_unlock(&reg_head.lock, &rlock_flags);
09484                 return -RSBAC_EINVALIDREQUEST;
09485         }
09486         for (i=0; i<list->nr_hashes; i++) {
09487 #ifdef CONFIG_RSBAC_LIST_TRANS
09488                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
09489                         count += list->hashed[i].ta_count;
09490                 else
09491 #endif
09492                         count += list->hashed[i].count;
09493         }
09494         if(!count) {
09495                 result = 0;
09496                 goto out_unlock;
09497         }
09498         item_size = list->info.data_size;
09499         item_offset = list->info.desc_size;
09500 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
09501         if(count > RSBAC_MAX_KMALLOC / item_size)
09502                 count = RSBAC_MAX_KMALLOC / item_size;
09503 #endif
09504         buffer = rsbac_vmalloc(item_size * count);
09505         if (!buffer) {
09506                 result = -ENOMEM;
09507                 goto out_unlock;
09508         }
09509         for (i=0; i<list->nr_hashes; i++) {
09510 #ifdef CONFIG_RSBAC_LIST_TRANS
09511                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
09512                         item_p = list->hashed[i].ta_head;
09513                 else
09514 #endif
09515                         item_p = list->hashed[i].head;
09516                 while (item_p && (result < count)) {
09517                         if (!item_p->max_age
09518                             || (item_p->max_age >
09519                                 RSBAC_CURRENT_TIME)
09520                             ) {
09521                                 memcpy(buffer + offset,
09522                                        ((char *) item_p) +
09523                                        sizeof(*item_p) +
09524                                        item_offset, item_size);
09525                                 offset += item_size;
09526                                 result++;
09527                         }
09528                         item_p = item_p->next;
09529                 }
09530         }
09531         *array_p = buffer;
09532 
09533 out_unlock:
09534         rsbac_read_unlock(&list->lock, &lock_flags);
09535         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
09536         return result;
09537 }

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 9150 of file gen_lists.c.

References rsbac_list_hashed_t::count, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_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, rsbac_list_reg_item_t::nr_hashes, NULL, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_reg_item_t::self.

Referenced by copy_new_ipcs(), 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().

09152 {
09153         struct rsbac_list_reg_item_t *list;
09154         struct rsbac_list_item_t *item_p;
09155         char *buffer;
09156         u_long lock_flags, rlock_flags;
09157         u_long offset = 0;
09158         u_long count = 0;
09159         long result = 0;
09160         u_int item_size;
09161         int i;
09162 
09163         if (!handle)
09164                 return -RSBAC_EINVALIDLIST;
09165         if (!array_p)
09166                 return -RSBAC_EINVALIDPOINTER;
09167         if (!list_initialized)
09168                 return -RSBAC_ENOTINITIALIZED;
09169 
09170         list = (struct rsbac_list_reg_item_t *) handle;
09171         if (list->self != list)
09172                 return -RSBAC_EINVALIDLIST;
09173         *array_p = NULL;
09174 
09175 #ifdef CONFIG_RSBAC_LIST_TRANS
09176         if (ta_number) {
09177                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09178                         return -RSBAC_EINVALIDTRANSACTION;
09179         }
09180 #endif
09181 
09182         rsbac_read_lock(&reg_head.lock, &rlock_flags);
09183 /*
09184         rsbac_pr_debug(lists, "list %s.\n", list->name);
09185 */
09186         rsbac_read_lock(&list->lock, &lock_flags);
09187         for (i=0; i<list->nr_hashes; i++) {
09188 #ifdef CONFIG_RSBAC_LIST_TRANS
09189                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
09190                         count += list->hashed[i].ta_count;
09191                 else
09192 #endif
09193                         count += list->hashed[i].count;
09194         }
09195         if(!count) {
09196                 result = 0;
09197                 goto out_unlock;
09198         }
09199         item_size = list->info.desc_size;
09200 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
09201         if(count > RSBAC_MAX_KMALLOC / item_size)
09202                 count = RSBAC_MAX_KMALLOC / item_size;
09203 #endif
09204         buffer = rsbac_vmalloc(item_size * count);
09205         if (!buffer) {
09206                 result = -ENOMEM;
09207                 goto out_unlock;
09208         }
09209         for (i=0; i<list->nr_hashes; i++) {
09210 #ifdef CONFIG_RSBAC_LIST_TRANS
09211                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
09212                         item_p = list->hashed[i].ta_head;
09213                 else
09214 #endif
09215                         item_p = list->hashed[i].head;
09216                 while (item_p && (result < count)) {
09217                         if (!item_p->max_age
09218                             || (item_p->max_age >
09219                                 RSBAC_CURRENT_TIME)
09220                             ) {
09221                                 memcpy(buffer + offset,
09222                                        ((char *) item_p) +
09223                                        sizeof(*item_p), item_size);
09224                                 offset += item_size;
09225                                 result++;
09226                         }
09227                         item_p = item_p->next;
09228                 }
09229         }
09230         *array_p = buffer;
09231 
09232 out_unlock:
09233         rsbac_read_unlock(&list->lock, &lock_flags);
09234         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
09235         return result;
09236 }

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 9797 of file gen_lists.c.

References rsbac_list_hashed_t::count, rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_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, rsbac_list_reg_item_t::nr_hashes, NULL, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vfree, 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().

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

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 7996 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::hash_function, rsbac_list_reg_item_t::hashed, 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_reg_item_t::nr_hashes, reg_head, RSBAC_EINVALIDLIST, 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().

08000 {
08001         struct rsbac_list_reg_item_t *list;
08002         struct rsbac_list_item_t *item_p;
08003         u_long lock_flags, rlock_flags;
08004         int err = 0;
08005 #ifdef CONFIG_RSBAC_LIST_TRANS
08006         u_int hash = 0;
08007 #endif
08008 
08009         if (!handle)
08010                 return -RSBAC_EINVALIDLIST;
08011         if (!desc)
08012                 return -RSBAC_EINVALIDVALUE;
08013         if (!list_initialized)
08014                 return -RSBAC_ENOTINITIALIZED;
08015 
08016         list = (struct rsbac_list_reg_item_t *) handle;
08017         if (list->self != list)
08018                 return -RSBAC_EINVALIDLIST;
08019 
08020 #ifdef CONFIG_RSBAC_LIST_TRANS
08021         if (ta_number) {
08022                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08023                         return -RSBAC_EINVALIDTRANSACTION;
08024                 if(list->hash_function)
08025                         hash = list->hash_function(desc, list->nr_hashes);
08026         }
08027 #endif
08028 
08029         rsbac_read_lock(&reg_head.lock, &rlock_flags);
08030 /*
08031         rsbac_pr_debug(lists, "getting data from list %s.\n",
08032                        list->name);
08033 */
08034         if (data && !list->info.data_size) {
08035                 rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08036                 return -RSBAC_EINVALIDREQUEST;
08037         }
08038 
08039         rsbac_read_lock(&list->lock, &lock_flags);
08040 #ifdef CONFIG_RSBAC_LIST_TRANS
08041         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08042                 item_p = ta_lookup_item(ta_number, list, desc);
08043         else
08044 #endif
08045                 item_p = lookup_item(list, desc);
08046         if (item_p
08047             && (!item_p->max_age || (item_p->max_age > RSBAC_CURRENT_TIME)
08048             )
08049             ) {                 /* exists -> copy data, if any */
08050                 if (ttl_p) {
08051                         if (item_p->max_age)
08052                                 *ttl_p =
08053                                     item_p->max_age - RSBAC_CURRENT_TIME;
08054                         else
08055                                 *ttl_p = 0;
08056                 }
08057                 if (data) {
08058                         memcpy(data,
08059                                ((char *) item_p) + sizeof(*item_p) +
08060                                list->info.desc_size, list->info.data_size);
08061                 }
08062         } else {
08063                 if (!list->def_data)
08064                         err = -RSBAC_ENOTFOUND;
08065                 else {
08066                         if (ttl_p)
08067                                 *ttl_p = 0;
08068                         if (data)
08069                                 memcpy(data,
08070                                        list->def_data,
08071                                        list->info.data_size);
08072                 }
08073         }
08074         rsbac_read_unlock(&list->lock, &lock_flags);
08075         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08076         return err;
08077 }

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 8586 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(), reg_head, RSBAC_EINVALIDLIST, 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().

08591 {
08592         struct rsbac_list_reg_item_t *list;
08593         struct rsbac_list_item_t *item_p;
08594         u_long lock_flags, rlock_flags;
08595         int err = 0;
08596 
08597         if (!handle)
08598                 return -RSBAC_EINVALIDLIST;
08599         if (!desc || !data)
08600                 return -RSBAC_EINVALIDVALUE;
08601         if (!list_initialized)
08602                 return -RSBAC_ENOTINITIALIZED;
08603 
08604         list = (struct rsbac_list_reg_item_t *) handle;
08605         if (list->self != list)
08606                 return -RSBAC_EINVALIDLIST;
08607 
08608 #ifdef CONFIG_RSBAC_LIST_TRANS
08609         if (ta_number) {
08610                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08611                         return -RSBAC_EINVALIDTRANSACTION;
08612         }
08613 #endif
08614 
08615         rsbac_read_lock(&reg_head.lock, &rlock_flags);
08616 /*
08617         rsbac_pr_debug(lists, "getting desc from list %s.\n", list->name);
08618 */
08619         if (!list->info.data_size) {
08620                 rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08621                 return -RSBAC_EINVALIDREQUEST;
08622         }
08623 
08624         rsbac_read_lock(&list->lock, &lock_flags);
08625 
08626 #ifdef CONFIG_RSBAC_LIST_TRANS
08627         item_p = ta_lookup_item_data(ta_number, list, data, compare);
08628 #else
08629         item_p = lookup_item_data(list, data, compare);
08630 #endif
08631         if (item_p) {           /* exists -> copy desc */
08632                 memcpy(desc,
08633                        ((char *) item_p) + sizeof(*item_p),
08634                        list->info.desc_size);
08635         } else {
08636                 err = -RSBAC_ENOTFOUND;
08637         }
08638         rsbac_read_unlock(&list->lock, &lock_flags);
08639         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08640         return err;
08641 }

int rsbac_ta_list_get_max_desc ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc 
)

Definition at line 8347 of file gen_lists.c.

References rsbac_list_reg_item_t::compare, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, 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::nr_hashes, NULL, rsbac_list_item_t::prev, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_reg_item_t::self, and rsbac_list_hashed_t::tail.

Referenced by rsbac_list_get_max_desc().

08349 {
08350         struct rsbac_list_reg_item_t *list;
08351         struct rsbac_list_item_t *item_p = NULL;
08352         struct rsbac_list_item_t *tmp_item_p;
08353         u_long lock_flags, rlock_flags;
08354         int err = 0;
08355         int i;
08356 
08357         if (!handle)
08358                 return -RSBAC_EINVALIDLIST;
08359         if (!list_initialized)
08360                 return -RSBAC_ENOTINITIALIZED;
08361 
08362         list = (struct rsbac_list_reg_item_t *) handle;
08363         if (list->self != list)
08364                 return -RSBAC_EINVALIDLIST;
08365 
08366 #ifdef CONFIG_RSBAC_LIST_TRANS
08367         if (ta_number) {
08368                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08369                         return -RSBAC_EINVALIDTRANSACTION;
08370         }
08371 #endif
08372 
08373         rsbac_read_lock(&reg_head.lock, &rlock_flags);
08374 /*
08375         rsbac_pr_debug(lists, "list %s.\n", list->name);
08376 */
08377         rsbac_read_lock(&list->lock, &lock_flags);
08378         for (i=0; i<list->nr_hashes; i++) {
08379 #ifdef CONFIG_RSBAC_LIST_TRANS
08380                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
08381                         tmp_item_p = list->hashed[i].ta_tail;
08382                 else
08383 #endif
08384                         tmp_item_p = list->hashed[i].tail;
08385                 while (tmp_item_p
08386                        && tmp_item_p->max_age && (tmp_item_p->max_age > RSBAC_CURRENT_TIME)
08387                     )
08388                         tmp_item_p = tmp_item_p->prev;
08389                 if(tmp_item_p) {
08390                         if(list->compare) {
08391                                 if(!item_p || list->compare(&tmp_item_p[1], &item_p[1]) > 0)
08392                                         item_p = tmp_item_p;
08393                         } else {
08394                                 if(!item_p || memcmp(&tmp_item_p[1], &item_p[1], list->info.desc_size) > 0)
08395                                         item_p = tmp_item_p;
08396                         }
08397                 }
08398         }
08399         if (item_p)
08400                 memcpy(desc, (char *) item_p + sizeof(*item_p),
08401                        list->info.desc_size);
08402         else {
08403                 memset(desc, 0, list->info.desc_size);
08404                 err = -RSBAC_ENOTFOUND;
08405         }
08406         rsbac_read_unlock(&list->lock, &lock_flags);
08407         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08408         return err;
08409 }

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 8414 of file gen_lists.c.

References rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_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_list_reg_item_t::nr_hashes, NULL, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.

Referenced by rsbac_list_get_next_desc().

08417 {
08418         struct rsbac_list_reg_item_t *list;
08419         struct rsbac_list_item_t *item_p;
08420         u_long lock_flags, rlock_flags;
08421         u_int hash = 0;
08422 
08423         if (!handle)
08424                 return -RSBAC_EINVALIDLIST;
08425         if (!list_initialized)
08426                 return -RSBAC_ENOTINITIALIZED;
08427         if (!next_desc)
08428                 return -RSBAC_EINVALIDPOINTER;
08429 
08430         list = (struct rsbac_list_reg_item_t *) handle;
08431         if (list->self != list)
08432                 return -RSBAC_EINVALIDLIST;
08433 
08434 #ifdef CONFIG_RSBAC_LIST_TRANS
08435         if (ta_number) {
08436                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08437                         return -RSBAC_EINVALIDTRANSACTION;
08438         }
08439 #endif
08440 
08441         rsbac_read_lock(&reg_head.lock, &rlock_flags);
08442 /*
08443         rsbac_pr_debug(lists, "list %s.\n", list->name);
08444 */
08445         rsbac_read_lock(&list->lock, &lock_flags);
08446         if (old_desc) {
08447                 if(list->hash_function)
08448                         hash = list->hash_function(old_desc, list->nr_hashes);
08449 #ifdef CONFIG_RSBAC_LIST_TRANS
08450                 if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08451                         item_p = ta_lookup_item(ta_number, list, old_desc);
08452                 else
08453 #endif
08454                         item_p = lookup_item(list, old_desc);
08455                 if(item_p) {
08456                         item_p = item_p->next;
08457                         while (item_p
08458                                && item_p->max_age && (item_p->max_age > RSBAC_CURRENT_TIME)
08459                             ) {
08460                                 item_p = item_p->next;
08461                         }
08462                         hash++;
08463                 } else
08464                         hash = 0;
08465         } else
08466                 item_p = NULL;
08467         while (!item_p && (hash < list->nr_hashes)) {
08468 #ifdef CONFIG_RSBAC_LIST_TRANS
08469                 if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08470                         item_p = list->hashed[hash].ta_head;
08471                 else
08472 #endif
08473                         item_p = list->hashed[hash].head;
08474                 while (item_p
08475                        && item_p->max_age && (item_p->max_age > RSBAC_CURRENT_TIME)
08476                     ) {
08477                         item_p = item_p->next;
08478                 }
08479                 hash++;
08480         }
08481         if (item_p) {
08482                 memcpy(next_desc, (char *) item_p + sizeof(*item_p),
08483                        list->info.desc_size);
08484         }
08485         rsbac_read_unlock(&list->lock, &lock_flags);
08486         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
08487         if (item_p)
08488                 return 0;
08489         else
08490                 return -RSBAC_ENOTFOUND;
08491 }

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 7114 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::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lol_touch, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EBUSY, RSBAC_EINVALIDLIST, 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().

07117 {
07118         struct rsbac_list_lol_reg_item_t *list;
07119         struct rsbac_list_lol_item_t *item_p;
07120         u_long lock_flags, rlock_flags;
07121         u_int hash = 0;
07122 
07123         if (!handle)
07124                 return -RSBAC_EINVALIDLIST;
07125         if (!desc)
07126                 return -RSBAC_EINVALIDVALUE;
07127         if (!list_initialized)
07128                 return -RSBAC_ENOTINITIALIZED;
07129 
07130         list = (struct rsbac_list_lol_reg_item_t *) handle;
07131         if (!list || (list->self != list))
07132                 return -RSBAC_EINVALIDLIST;
07133 
07134 #ifdef CONFIG_RSBAC_LIST_TRANS
07135         if (ta_number && !rsbac_ta_list_exist(0, ta_handle, &ta_number))
07136                 return -RSBAC_EINVALIDTRANSACTION;
07137 #endif
07138 
07139         if (ttl && (ttl != RSBAC_LIST_TTL_KEEP)) {
07140                 if (ttl > RSBAC_LIST_MAX_AGE_LIMIT)
07141                         ttl = RSBAC_LIST_MAX_AGE_LIMIT;
07142                 ttl += RSBAC_CURRENT_TIME;
07143         }
07144 
07145         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07146         if (list->info.data_size && !data) {
07147                 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07148                 return -RSBAC_EINVALIDVALUE;
07149         }
07150 
07151 /*
07152         rsbac_pr_debug(lists, "adding to list %s.\n", list->name);
07153 */
07154         rsbac_write_lock(&list->lock, &lock_flags);
07155 
07156         if(list->hash_function)
07157                 hash = list->hash_function(desc, list->nr_hashes);
07158 #ifdef CONFIG_RSBAC_LIST_TRANS
07159         if (!ta_number)
07160 #endif
07161         {
07162                 item_p = lookup_lol_item(list, desc);
07163                 if (item_p) {   /* exists -> update data, if any */
07164                         if (ttl != RSBAC_LIST_TTL_KEEP)
07165                                 item_p->max_age = ttl;
07166                         if (data && list->info.data_size) {
07167                                 if (list->def_data
07168                                     && !item_p->max_age
07169                                     && !memcmp(list->def_data, data,
07170                                                list->info.data_size)
07171                                     && !item_p->count)
07172                                         do_remove_lol_item(list, item_p, hash);
07173                                 else
07174                                         memcpy(((char *) item_p) +
07175                                                sizeof(*item_p) +
07176                                                list->info.desc_size, data,
07177                                                list->info.data_size);
07178                         }
07179                 } else {
07180                         if (ttl == RSBAC_LIST_TTL_KEEP)
07181                                 ttl = 0;
07182                         if (!list->def_data
07183                             || memcmp(list->def_data, data,
07184                                       list->info.data_size)
07185                             )
07186                                 add_lol_item(list, ttl, desc, data);
07187                 }
07188                 lol_touch(list);
07189                 list->dirty = TRUE;
07190         }
07191 #ifdef CONFIG_RSBAC_LIST_TRANS
07192         if (list->hashed[hash].ta_copied || ta_number) {
07193                 if (!list->hashed[hash].ta_copied)
07194                         ta_lol_copy(ta_number, list, hash);
07195                 else if (ta_number) {
07196                         if (list->hashed[hash].ta_copied != ta_number) {
07197                                 rsbac_write_unlock(&list->lock,
07198                                                    &lock_flags);
07199                                 rsbac_read_unlock(&lol_reg_head.lock,
07200                                                   &rlock_flags);
07201                                 return -RSBAC_EBUSY;
07202                         }
07203                 } else
07204                         ta_number = list->hashed[hash].ta_copied;
07205                 item_p = ta_lookup_lol_item(ta_number, list, desc);
07206                 if (item_p) {   /* exists -> update data, if any */
07207                         if (ttl != RSBAC_LIST_TTL_KEEP)
07208                                 item_p->max_age = ttl;
07209                         if (data && list->info.data_size) {
07210                                 if (list->def_data
07211                                     && !item_p->max_age
07212                                     && !memcmp(list->def_data, data,
07213                                                list->info.data_size)
07214                                     && !item_p->count)
07215                                         ta_do_remove_lol_item(list,
07216                                                               item_p,
07217                                                               hash);
07218                                 else
07219                                         memcpy(((char *) item_p) +
07220                                                sizeof(*item_p) +
07221                                                list->info.desc_size, data,
07222                                                list->info.data_size);
07223                         }
07224                 } else {
07225                         if (ttl == RSBAC_LIST_TTL_KEEP)
07226                                 ttl = 0;
07227                         if (!list->def_data
07228                             || memcmp(list->def_data, data,
07229                                       list->info.data_size)
07230                             )
07231                                 ta_add_lol_item(ta_number, list, ttl, desc,
07232                                                 data);
07233                 }
07234         }
07235 #endif
07236         rsbac_write_unlock(&list->lock, &lock_flags);
07237         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07238         return 0;
07239 }

long rsbac_ta_list_lol_all_subcount ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle 
)

Definition at line 9016 of file gen_lists.c.

References rsbac_list_lol_item_t::count, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_list_lol_all_subcount().

09018 {
09019         struct rsbac_list_lol_reg_item_t *list;
09020         struct rsbac_list_lol_item_t *sublist;
09021         u_long lock_flags, rlock_flags;
09022         long result = 0;
09023         int i;
09024 
09025         if (!handle)
09026                 return -RSBAC_EINVALIDLIST;
09027         if (!list_initialized)
09028                 return -RSBAC_ENOTINITIALIZED;
09029 
09030         list = (struct rsbac_list_lol_reg_item_t *) handle;
09031         if (list->self != list)
09032                 return -RSBAC_EINVALIDLIST;
09033 
09034 #ifdef CONFIG_RSBAC_LIST_TRANS
09035         if (ta_number) {
09036                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09037                         return -RSBAC_EINVALIDTRANSACTION;
09038         }
09039 #endif
09040 
09041         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09042 /*
09043         rsbac_pr_debug(lists, "list %s.\n", list->name);
09044 */
09045         rsbac_read_lock(&list->lock, &lock_flags);
09046 
09047         for (i=0; i<list->nr_hashes; i++) {
09048 #ifdef CONFIG_RSBAC_LIST_TRANS
09049                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
09050                         sublist = list->hashed[i].ta_head;
09051                 else
09052 #endif
09053                         sublist = list->hashed[i].head;
09054                 while (sublist) {
09055                         result += sublist->count;
09056                         sublist = sublist->next;
09057                 }
09058         }
09059         rsbac_read_unlock(&list->lock, &lock_flags);
09060         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09061         return result;
09062 }

long rsbac_ta_list_lol_count ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle 
)

Definition at line 9067 of file gen_lists.c.

References rsbac_list_lol_hashed_t::count, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, 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().

09069 {
09070         struct rsbac_list_lol_reg_item_t *list;
09071         long result = 0;
09072         int i;
09073 
09074         if (!handle)
09075                 return -RSBAC_EINVALIDLIST;
09076         if (!list_initialized)
09077                 return -RSBAC_ENOTINITIALIZED;
09078 
09079         list = (struct rsbac_list_lol_reg_item_t *) handle;
09080         if (list->self != list)
09081                 return -RSBAC_EINVALIDLIST;
09082 
09083 #ifdef CONFIG_RSBAC_LIST_TRANS
09084         if (ta_number) {
09085                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09086                         return -RSBAC_EINVALIDTRANSACTION;
09087         }
09088 #endif
09089 
09090 /*
09091         rsbac_pr_debug(lists, "list %s.\n", list->name);
09092 */
09093         for (i=0; i<list->nr_hashes; i++) {
09094 #ifdef CONFIG_RSBAC_LIST_TRANS
09095                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
09096                         result += list->hashed[i].ta_count;
09097                 else
09098 #endif
09099                         result += list->hashed[i].count;
09100         }
09101         return result;
09102 }

int rsbac_ta_list_lol_exist ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc 
)

Definition at line 8903 of file gen_lists.c.

References FALSE, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, 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().

08905 {
08906         struct rsbac_list_lol_reg_item_t *list;
08907         u_long lock_flags, rlock_flags;
08908         struct rsbac_list_lol_item_t *item_p;
08909         int result;
08910 #ifdef CONFIG_RSBAC_LIST_TRANS
08911         u_int hash = 0;
08912 #endif
08913 
08914         if (!handle || !desc)
08915                 return FALSE;
08916         if (!list_initialized)
08917                 return FALSE;
08918 
08919         list = (struct rsbac_list_lol_reg_item_t *) handle;
08920         if (list->self != list)
08921                 return -RSBAC_EINVALIDLIST;
08922 
08923 #ifdef CONFIG_RSBAC_LIST_TRANS
08924         if (ta_number) {
08925                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08926                         return -RSBAC_EINVALIDTRANSACTION;
08927                 if(list->hash_function)
08928                         hash = list->hash_function(desc, list->nr_hashes);
08929         }
08930 #endif
08931 
08932         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08933 /*
08934         rsbac_pr_debug(lists, "testing on list %s.\n", list->name);
08935 */
08936         rsbac_read_lock(&list->lock, &lock_flags);
08937 
08938 #ifdef CONFIG_RSBAC_LIST_TRANS
08939         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08940                 item_p = ta_lookup_lol_item(ta_number, list, desc);
08941         else
08942 #endif
08943                 item_p = lookup_lol_item(list, desc);
08944         if (item_p
08945             && (!item_p->max_age || (item_p->max_age > RSBAC_CURRENT_TIME)
08946             )
08947             ) {                 /* exists -> TRUE */
08948                 result = TRUE;
08949         } else {
08950                 result = FALSE;
08951         }
08952         rsbac_read_unlock(&list->lock, &lock_flags);
08953         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08954         return result;
08955 }

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 9635 of file gen_lists.c.

References rsbac_list_lol_hashed_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_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_reg_head, rsbac_list_lol_item_t::max_age, rsbac_list_lol_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_list_lol_get_all_data().

09638 {
09639         struct rsbac_list_lol_reg_item_t *list;
09640         struct rsbac_list_lol_item_t *item_p;
09641         char *buffer;
09642         u_long lock_flags, rlock_flags;
09643         u_long offset = 0;
09644         long result = 0;
09645         u_int item_size;
09646         u_int item_offset;
09647         int i;
09648         u_long count = 0;
09649 
09650         if (!handle)
09651                 return -RSBAC_EINVALIDLIST;
09652         if (!array_p)
09653                 return -RSBAC_EINVALIDPOINTER;
09654         if (!list_initialized)
09655                 return -RSBAC_ENOTINITIALIZED;
09656 
09657         list = (struct rsbac_list_lol_reg_item_t *) handle;
09658         if (list->self != list)
09659                 return -RSBAC_EINVALIDLIST;
09660         *array_p = NULL;
09661 
09662 #ifdef CONFIG_RSBAC_LIST_TRANS
09663         if (ta_number) {
09664                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09665                         return -RSBAC_EINVALIDTRANSACTION;
09666         }
09667 #endif
09668 
09669         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09670 /*
09671         rsbac_pr_debug(lists, "list %s.\n", list->name);
09672 */
09673         rsbac_read_lock(&list->lock, &lock_flags);
09674         if (!list->info.data_size) {
09675                 rsbac_read_unlock(&list->lock, &lock_flags);
09676                 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09677                 return -RSBAC_EINVALIDREQUEST;
09678         }
09679         for (i=0; i<list->nr_hashes; i++) {
09680 #ifdef CONFIG_RSBAC_LIST_TRANS
09681                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
09682                         count += list->hashed[i].ta_count;
09683                 else
09684 #endif
09685                         count += list->hashed[i].count;
09686         }
09687         if(!count) {
09688                 result = 0;
09689                 goto out_unlock;
09690         }
09691         item_size = list->info.data_size;
09692         item_offset = list->info.desc_size;
09693 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
09694         if(count > RSBAC_MAX_KMALLOC / item_size)
09695                 count = RSBAC_MAX_KMALLOC / item_size;
09696 #endif
09697         buffer = rsbac_vmalloc(item_size * count);
09698         if (!buffer) {
09699                 result = -ENOMEM;
09700                 goto out_unlock;
09701         }
09702         for (i=0; i<list->nr_hashes; i++) {
09703 #ifdef CONFIG_RSBAC_LIST_TRANS
09704                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
09705                         item_p = list->hashed[i].ta_head;
09706                 else
09707 #endif
09708                         item_p = list->hashed[i].head;
09709                 while (item_p && (result < count)) {
09710                         if (!item_p->max_age
09711                             || (item_p->max_age >
09712                                 RSBAC_CURRENT_TIME)
09713                             ) {
09714                                 memcpy(buffer + offset,
09715                                        ((char *) item_p) +
09716                                        sizeof(*item_p) +
09717                                        item_offset, item_size);
09718                                 offset += item_size;
09719                                 result++;
09720                         }
09721                         item_p = item_p->next;
09722                 }
09723         }
09724         *array_p = buffer;
09725 
09726 out_unlock:
09727         rsbac_read_unlock(&list->lock, &lock_flags);
09728         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09729         return result;
09730 }

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 9344 of file gen_lists.c.

References rsbac_list_lol_hashed_t::count, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_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_reg_head, rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::name, rsbac_list_lol_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_pr_debug, 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().

09347 {
09348         struct rsbac_list_lol_reg_item_t *list;
09349         struct rsbac_list_lol_item_t *item_p;
09350         char *buffer;
09351         u_long lock_flags, rlock_flags;
09352         u_long offset = 0;
09353         long result = 0;
09354         u_int item_size;
09355         int i;
09356         u_long count = 0;
09357 
09358         if (!handle)
09359                 return -RSBAC_EINVALIDLIST;
09360         if (!array_p)
09361                 return -RSBAC_EINVALIDPOINTER;
09362         if (!list_initialized)
09363                 return -RSBAC_ENOTINITIALIZED;
09364 
09365         list = (struct rsbac_list_lol_reg_item_t *) handle;
09366         if (list->self != list)
09367                 return -RSBAC_EINVALIDLIST;
09368         *array_p = NULL;
09369 
09370 #ifdef CONFIG_RSBAC_LIST_TRANS
09371         if (ta_number) {
09372                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09373                         return -RSBAC_EINVALIDTRANSACTION;
09374         }
09375 #endif
09376 
09377         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09378 /*
09379         rsbac_pr_debug(lists, "list %s.\n", list->name);
09380 */
09381         rsbac_read_lock(&list->lock, &lock_flags);
09382         for (i=0; i<list->nr_hashes; i++) {
09383 #ifdef CONFIG_RSBAC_LIST_TRANS
09384                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
09385                         count += list->hashed[i].ta_count;
09386                 else
09387 #endif
09388                         count += list->hashed[i].count;
09389         }
09390         if(!count) {
09391                 result = 0;
09392                 goto out_unlock;
09393         }
09394         item_size = list->info.desc_size;
09395 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
09396         if(count > RSBAC_MAX_KMALLOC / item_size)
09397                 count = RSBAC_MAX_KMALLOC / item_size;
09398 #endif
09399         buffer = rsbac_vmalloc(item_size * count);
09400         if (!buffer) {
09401                 result = -ENOMEM;
09402                 rsbac_pr_debug(lists, "list %s: could not allocate buffer  for %u items of size %u!\n",
09403                         list->name, count, item_size);
09404                 goto out_unlock;
09405         }
09406         for (i=0; i<list->nr_hashes; i++) {
09407 #ifdef CONFIG_RSBAC_LIST_TRANS
09408                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
09409                         item_p = list->hashed[i].ta_head;
09410                 else
09411 #endif
09412                         item_p = list->hashed[i].head;
09413                 while (item_p && (result < count)) {
09414                         if (!item_p->max_age
09415                             || (item_p->max_age >
09416                                 RSBAC_CURRENT_TIME)
09417                             ) {
09418                                 memcpy(buffer + offset,
09419                                        ((char *) item_p) +
09420                                        sizeof(*item_p), item_size);
09421                                 offset += item_size;
09422                                 result++;
09423                         }
09424                         item_p = item_p->next;
09425                 }
09426         }
09427         *array_p = buffer;
09428 
09429 out_unlock:
09430         rsbac_read_unlock(&list->lock, &lock_flags);
09431         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09432         return result;
09433 }

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 10012 of file gen_lists.c.

References rsbac_list_lol_hashed_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_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_reg_head, rsbac_list_lol_item_t::max_age, rsbac_list_lol_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_list_lol_get_all_items().

10015 {
10016         struct rsbac_list_lol_reg_item_t *list;
10017         struct rsbac_list_lol_item_t *item_p;
10018         char *buffer;
10019         u_long lock_flags, rlock_flags;
10020         u_long offset = 0;
10021         long result = 0;
10022         u_int item_size;
10023         int i;
10024         u_long count = 0;
10025 
10026         if (!handle)
10027                 return -RSBAC_EINVALIDLIST;
10028         if (!array_p)
10029                 return -RSBAC_EINVALIDPOINTER;
10030         if (!list_initialized)
10031                 return -RSBAC_ENOTINITIALIZED;
10032 
10033         list = (struct rsbac_list_lol_reg_item_t *) handle;
10034         if (list->self != list)
10035                 return -RSBAC_EINVALIDLIST;
10036         *array_p = NULL;
10037 
10038 #ifdef CONFIG_RSBAC_LIST_TRANS
10039         if (ta_number) {
10040                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
10041                         return -RSBAC_EINVALIDTRANSACTION;
10042         }
10043 #endif
10044 
10045         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
10046 /*
10047         rsbac_pr_debug(lists, "list %s.\n", list->name);
10048 */
10049         rsbac_read_lock(&list->lock, &lock_flags);
10050         for (i=0; i<list->nr_hashes; i++) {
10051 #ifdef CONFIG_RSBAC_LIST_TRANS
10052                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
10053                         count += list->hashed[i].ta_count;
10054                 else
10055 #endif
10056                         count += list->hashed[i].count;
10057         }
10058         if(!count) {
10059                 result = 0;
10060                 goto out_unlock;
10061         }
10062         item_size = list->info.desc_size + list->info.data_size;
10063 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
10064         if(count > RSBAC_MAX_KMALLOC / item_size)
10065                 count = RSBAC_MAX_KMALLOC / item_size;
10066 #endif
10067         buffer = rsbac_vmalloc(item_size * count);
10068         if (!buffer) {
10069                 result = -ENOMEM;
10070                 goto out_unlock;
10071         }
10072         for (i=0; i<list->nr_hashes; i++) {
10073 #ifdef CONFIG_RSBAC_LIST_TRANS
10074                 if (ta_number && (list->hashed[i].ta_copied == ta_number))
10075                         item_p = list->hashed[i].ta_head;
10076                 else
10077 #endif
10078                         item_p = list->hashed[i].head;
10079                 while (item_p && (result < count)) {
10080                         if (!item_p->max_age
10081                             || (item_p->max_age >
10082                                 RSBAC_CURRENT_TIME)
10083                             ) {
10084                                 memcpy(buffer + offset,
10085                                        ((char *) item_p) +
10086                                        sizeof(*item_p), item_size);
10087                                 offset += item_size;
10088                                 result++;
10089                         }
10090                         item_p = item_p->next;
10091                 }
10092         }
10093         *array_p = buffer;
10094 
10095 out_unlock:
10096         rsbac_read_unlock(&list->lock, &lock_flags);
10097         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
10098         return result;
10099 }

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 9542 of file gen_lists.c.

References rsbac_list_lol_item_t::count, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, 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_reg_head, lookup_lol_item(), rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, 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(), and rsbac_um_good_pass().

09545 {
09546         struct rsbac_list_lol_reg_item_t *list;
09547         struct rsbac_list_lol_item_t *sublist;
09548         struct rsbac_list_item_t *item_p;
09549         char *buffer;
09550         u_long lock_flags, rlock_flags;
09551         u_long offset = 0;
09552         long result = 0;
09553         u_long count;
09554         u_int item_size;
09555         u_int item_offset;
09556 #ifdef CONFIG_RSBAC_LIST_TRANS
09557         u_int hash = 0;
09558 #endif
09559 
09560         if (!handle)
09561                 return -RSBAC_EINVALIDLIST;
09562         if (!array_p)
09563                 return -RSBAC_EINVALIDPOINTER;
09564         if (!list_initialized)
09565                 return -RSBAC_ENOTINITIALIZED;
09566 
09567         list = (struct rsbac_list_lol_reg_item_t *) handle;
09568         if (list->self != list)
09569                 return -RSBAC_EINVALIDLIST;
09570         *array_p = NULL;
09571 
09572 #ifdef CONFIG_RSBAC_LIST_TRANS
09573         if (ta_number) {
09574                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09575                         return -RSBAC_EINVALIDTRANSACTION;
09576                 if(list->hash_function)
09577                         hash = list->hash_function(desc, list->nr_hashes);
09578         }
09579 #endif
09580 
09581         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09582 /*
09583         rsbac_pr_debug(lists, "list %s.\n", list->name);
09584 */
09585         rsbac_read_lock(&list->lock, &lock_flags);
09586         if (!list->info.subdata_size) {
09587                 rsbac_read_unlock(&list->lock, &lock_flags);
09588                 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09589                 return -RSBAC_EINVALIDREQUEST;
09590         }
09591 #ifdef CONFIG_RSBAC_LIST_TRANS
09592         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
09593                 sublist = ta_lookup_lol_item(ta_number, list, desc);
09594         else
09595 #endif
09596                 sublist = lookup_lol_item(list, desc);
09597         if (sublist && sublist->count) {
09598                 item_size = list->info.subdata_size;
09599                 item_offset = list->info.subdesc_size;
09600                 count = sublist->count;
09601 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
09602                 if(count > RSBAC_MAX_KMALLOC / item_size)
09603                         count = RSBAC_MAX_KMALLOC / item_size;
09604 #endif
09605                 buffer = rsbac_vmalloc(item_size * count);
09606                 if (buffer) {
09607                         item_p = sublist->head;
09608                         while (item_p && (result < count)) {
09609                                 if (!item_p->max_age
09610                                     || (item_p->max_age >
09611                                         RSBAC_CURRENT_TIME)
09612                                     ) {
09613                                         memcpy(buffer + offset,
09614                                                ((char *) item_p) +
09615                                                sizeof(*item_p) +
09616                                                item_offset, item_size);
09617                                         offset += item_size;
09618                                         result++;
09619                                 }
09620                                 item_p = item_p->next;
09621                         }
09622                         *array_p = buffer;
09623                 } else {
09624                         result = -RSBAC_ENOMEM;
09625                 }
09626         }
09627         rsbac_read_unlock(&list->lock, &lock_flags);
09628         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09629         return result;
09630 }

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 9241 of file gen_lists.c.

References rsbac_list_lol_item_t::count, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, 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_reg_head, lookup_lol_item(), rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, 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().

09246 {
09247         struct rsbac_list_lol_reg_item_t *list;
09248         struct rsbac_list_lol_item_t *sublist;
09249         struct rsbac_list_item_t *item_p;
09250         char *buffer;
09251         rsbac_time_t *ttl_p = NULL;
09252         u_long lock_flags, rlock_flags;
09253         u_long offset = 0;
09254         long result = 0;
09255         u_long count;
09256         u_int item_size;
09257 #ifdef CONFIG_RSBAC_LIST_TRANS
09258         u_int hash = 0;
09259 #endif
09260 
09261         if (!handle)
09262                 return -RSBAC_EINVALIDLIST;
09263         if (!array_p)
09264                 return -RSBAC_EINVALIDPOINTER;
09265         if (!list_initialized)
09266                 return -RSBAC_ENOTINITIALIZED;
09267 
09268         list = (struct rsbac_list_lol_reg_item_t *) handle;
09269         if (list->self != list)
09270                 return -RSBAC_EINVALIDLIST;
09271         *array_p = NULL;
09272 
09273 #ifdef CONFIG_RSBAC_LIST_TRANS
09274         if (ta_number) {
09275                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09276                         return -RSBAC_EINVALIDTRANSACTION;
09277                 if(list->hash_function)
09278                         hash = list->hash_function(desc, list->nr_hashes);
09279         }
09280 #endif
09281 
09282         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09283 /*
09284         rsbac_pr_debug(lists, "list %s.\n", list->name);
09285 */
09286         rsbac_read_lock(&list->lock, &lock_flags);
09287 #ifdef CONFIG_RSBAC_LIST_TRANS
09288         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
09289                 sublist = ta_lookup_lol_item(ta_number, list, desc);
09290         else
09291 #endif
09292                 sublist = lookup_lol_item(list, desc);
09293         if (sublist && sublist->count) {
09294                 item_size = list->info.subdesc_size;
09295                 count = sublist->count;
09296 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
09297                 if(count > RSBAC_MAX_KMALLOC / item_size)
09298                         count = RSBAC_MAX_KMALLOC / item_size;
09299 #endif
09300                 buffer = rsbac_vmalloc(item_size * count);
09301                 if (buffer) {
09302                         if (ttl_array_p)
09303                                 ttl_p =
09304                                     rsbac_vmalloc(sizeof(**ttl_array_p) *
09305                                                   sublist->count);
09306                         item_p = sublist->head;
09307                         while (item_p && (result < count)) {
09308                                 if (!item_p->max_age
09309                                     || (item_p->max_age >
09310                                         RSBAC_CURRENT_TIME)
09311                                     ) {
09312                                         memcpy(buffer + offset,
09313                                                ((char *) item_p) +
09314                                                sizeof(*item_p), item_size);
09315                                         if (ttl_p) {
09316                                                 if (item_p->max_age)
09317                                                         ttl_p[result] =
09318                                                             item_p->
09319                                                             max_age -
09320                                                             RSBAC_CURRENT_TIME;
09321                                                 else
09322                                                         ttl_p[result] = 0;
09323                                         }
09324                                         offset += item_size;
09325                                         result++;
09326                                 }
09327                                 item_p = item_p->next;
09328                         }
09329                         *array_p = buffer;
09330                         if (ttl_array_p)
09331                                 *ttl_array_p = ttl_p;
09332                 } else {
09333                         result = -RSBAC_ENOMEM;
09334                 }
09335         }
09336         rsbac_read_unlock(&list->lock, &lock_flags);
09337         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09338         return result;
09339 }

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 9908 of file gen_lists.c.

References rsbac_list_lol_item_t::count, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, 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_reg_head, lookup_lol_item(), rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, 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().

09913 {
09914         struct rsbac_list_lol_reg_item_t *list;
09915         struct rsbac_list_lol_item_t *sublist;
09916         struct rsbac_list_item_t *item_p;
09917         char *buffer;
09918         rsbac_time_t *ttl_p = NULL;
09919         u_long lock_flags, rlock_flags;
09920         u_long offset = 0;
09921         long result = 0;
09922         u_long count;
09923         u_int item_size;
09924 #ifdef CONFIG_RSBAC_LIST_TRANS
09925         u_int hash = 0;
09926 #endif
09927 
09928         if (!handle)
09929                 return -RSBAC_EINVALIDLIST;
09930         if (!array_p)
09931                 return -RSBAC_EINVALIDPOINTER;
09932         if (!list_initialized)
09933                 return -RSBAC_ENOTINITIALIZED;
09934 
09935         list = (struct rsbac_list_lol_reg_item_t *) handle;
09936         if (list->self != list)
09937                 return -RSBAC_EINVALIDLIST;
09938         *array_p = NULL;
09939 
09940 #ifdef CONFIG_RSBAC_LIST_TRANS
09941         if (ta_number) {
09942                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
09943                         return -RSBAC_EINVALIDTRANSACTION;
09944                 if(list->hash_function)
09945                         hash = list->hash_function(desc, list->nr_hashes);
09946         }
09947 #endif
09948 
09949         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
09950 /*
09951         rsbac_pr_debug(lists, "list %s.\n", list->name);
09952 */
09953         rsbac_read_lock(&list->lock, &lock_flags);
09954 #ifdef CONFIG_RSBAC_LIST_TRANS
09955         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
09956                 sublist = ta_lookup_lol_item(ta_number, list, desc);
09957         else
09958 #endif
09959                 sublist = lookup_lol_item(list, desc);
09960         if (sublist && sublist->count) {
09961                 count = sublist->count;
09962                 item_size =
09963                     list->info.subdesc_size + list->info.subdata_size;
09964 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
09965                 if(count > RSBAC_MAX_KMALLOC / item_size)
09966                         count = RSBAC_MAX_KMALLOC / item_size;
09967 #endif
09968                 buffer = rsbac_vmalloc(item_size * count);
09969                 if (buffer) {
09970                         if (ttl_array_p)
09971                                 ttl_p =
09972                                     rsbac_vmalloc(sizeof(**ttl_array_p) *
09973                                                   sublist->count);
09974                         item_p = sublist->head;
09975                         while (item_p && (result < count)) {
09976                                 if (!item_p->max_age
09977                                     || (item_p->max_age >
09978                                         RSBAC_CURRENT_TIME)
09979                                     ) {
09980                                         memcpy(buffer + offset,
09981                                                ((char *) item_p) +
09982                                                sizeof(*item_p), item_size);
09983                                         if (ttl_p) {
09984                                                 if (item_p->max_age)
09985                                                         ttl_p[result] =
09986                                                             item_p->
09987                                                             max_age -
09988                                                             RSBAC_CURRENT_TIME;
09989                                                 else
09990                                                         ttl_p[result] = 0;
09991                                         }
09992                                         offset += item_size;
09993                                         result++;
09994                                 }
09995                                 item_p = item_p->next;
09996                         }
09997                         *array_p = buffer;
09998                         if (ttl_array_p)
09999                                 *ttl_array_p = ttl_p;
10000                 } else {
10001                         result = -RSBAC_ENOMEM;
10002                 }
10003         }
10004         rsbac_read_unlock(&list->lock, &lock_flags);
10005         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
10006         return result;
10007 }

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 8261 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::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, 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().

08265 {
08266         struct rsbac_list_lol_reg_item_t *list;
08267         struct rsbac_list_lol_item_t *item_p;
08268         u_long lock_flags, rlock_flags;
08269         int err = 0;
08270 #ifdef CONFIG_RSBAC_LIST_TRANS
08271         u_int hash = 0;
08272 #endif
08273 
08274         if (!handle)
08275                 return -RSBAC_EINVALIDLIST;
08276         if (!desc)
08277                 return -RSBAC_EINVALIDVALUE;
08278         if (!list_initialized)
08279                 return -RSBAC_ENOTINITIALIZED;
08280 
08281         list = (struct rsbac_list_lol_reg_item_t *) handle;
08282         if (list->self != list)
08283                 return -RSBAC_EINVALIDLIST;
08284 
08285 #ifdef CONFIG_RSBAC_LIST_TRANS
08286         if (ta_number) {
08287                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08288                         return -RSBAC_EINVALIDTRANSACTION;
08289                 if(list->hash_function)
08290                         hash = list->hash_function(desc, list->nr_hashes);
08291         }
08292 #endif
08293 
08294         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08295 /*
08296         rsbac_pr_debug(lists, "getting data from list %s.\n", list->name);
08297 */
08298         if (data && !list->info.data_size) {
08299                 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08300                 return -RSBAC_EINVALIDREQUEST;
08301         }
08302 
08303         rsbac_read_lock(&list->lock, &lock_flags);
08304 
08305 #ifdef CONFIG_RSBAC_LIST_TRANS
08306         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08307                 item_p = ta_lookup_lol_item(ta_number, list, desc);
08308         else
08309 #endif
08310                 item_p = lookup_lol_item(list, desc);
08311         if (item_p
08312             && (!item_p->max_age || (item_p->max_age > RSBAC_CURRENT_TIME)
08313             )
08314             ) {                 /* exists -> copy data, if any */
08315                 if (ttl_p) {
08316                         if (item_p->max_age)
08317                                 *ttl_p =
08318                                     item_p->max_age - RSBAC_CURRENT_TIME;
08319                         else
08320                                 *ttl_p = 0;
08321                 }
08322                 if (data) {
08323                         memcpy(data,
08324                                ((char *) item_p) + sizeof(*item_p) +
08325                                list->info.desc_size, list->info.data_size);
08326                 }
08327         } else {
08328                 if (!list->def_data)
08329                         err = -RSBAC_ENOTFOUND;
08330                 else {
08331                         if (ttl_p)
08332                                 *ttl_p = 0;
08333                         if (data)
08334                                 memcpy(data,
08335                                        list->def_data,
08336                                        list->info.data_size);
08337                 }
08338         }
08339         rsbac_read_unlock(&list->lock, &lock_flags);
08340         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08341         return err;
08342 }

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 8646 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, lol_reg_head, lookup_lol_item_data(), RSBAC_EINVALIDLIST, 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().

08651 {
08652         struct rsbac_list_lol_reg_item_t *list;
08653         struct rsbac_list_lol_item_t *item_p;
08654         u_long lock_flags, rlock_flags;
08655         int err = 0;
08656 
08657         if (!handle)
08658                 return -RSBAC_EINVALIDLIST;
08659         if (!desc || !data)
08660                 return -RSBAC_EINVALIDVALUE;
08661         if (!list_initialized)
08662                 return -RSBAC_ENOTINITIALIZED;
08663 
08664         list = (struct rsbac_list_lol_reg_item_t *) handle;
08665         if (list->self != list)
08666                 return -RSBAC_EINVALIDLIST;
08667 
08668 #ifdef CONFIG_RSBAC_LIST_TRANS
08669         if (ta_number) {
08670                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08671                         return -RSBAC_EINVALIDTRANSACTION;
08672         }
08673 #endif
08674 
08675         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08676 /*
08677         rsbac_pr_debug(lists, "getting desc from list %s.\n", list->name);
08678 */
08679         if (!list->info.data_size) {
08680                 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08681                 return -RSBAC_EINVALIDREQUEST;
08682         }
08683 
08684         rsbac_read_lock(&list->lock, &lock_flags);
08685 
08686 #ifdef CONFIG_RSBAC_LIST_TRANS
08687         item_p = ta_lookup_lol_item_data(ta_number, list, data, compare);
08688 #else
08689         item_p = lookup_lol_item_data(list, data, compare);
08690 #endif
08691         if (item_p) {           /* exists -> copy desc */
08692                 memcpy(desc,
08693                        ((char *) item_p) + sizeof(*item_p),
08694                        list->info.desc_size);
08695         } else {
08696                 err = -RSBAC_ENOTFOUND;
08697         }
08698         rsbac_read_unlock(&list->lock, &lock_flags);
08699         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08700         return err;
08701 }

int rsbac_ta_list_lol_get_max_subdesc ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc,
void *  subdesc 
)

Definition at line 8082 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, rsbac_list_item_t::prev, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdesc_size, and rsbac_list_lol_item_t::tail.

Referenced by rsbac_um_set_pass().

08085 {
08086         struct rsbac_list_lol_reg_item_t *list;
08087         struct rsbac_list_lol_item_t *sublist;
08088         struct rsbac_list_item_t *item_p;
08089         u_long lock_flags, rlock_flags;
08090         int err = 0;
08091 #ifdef CONFIG_RSBAC_LIST_TRANS
08092         u_int hash = 0;
08093 #endif
08094 
08095         if (!handle)
08096                 return -RSBAC_EINVALIDLIST;
08097         if (!desc || !subdesc)
08098                 return -RSBAC_EINVALIDVALUE;
08099         if (!list_initialized)
08100                 return -RSBAC_ENOTINITIALIZED;
08101 
08102         list = (struct rsbac_list_lol_reg_item_t *) handle;
08103         if (list->self != list)
08104                 return -RSBAC_EINVALIDLIST;
08105 
08106 #ifdef CONFIG_RSBAC_LIST_TRANS
08107         if (ta_number) {
08108                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08109                         return -RSBAC_EINVALIDTRANSACTION;
08110                 if(list->hash_function)
08111                         hash = list->hash_function(desc, list->nr_hashes);
08112         }
08113 #endif
08114 
08115         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08116 /*
08117         rsbac_pr_debug(lists, "getting data from list %s.\n",
08118                        list->name);
08119 */
08120 
08121         rsbac_read_lock(&list->lock, &lock_flags);
08122 
08123 #ifdef CONFIG_RSBAC_LIST_TRANS
08124         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08125                 sublist = ta_lookup_lol_item(ta_number, list, desc);
08126         else
08127 #endif
08128                 sublist = lookup_lol_item(list, desc);
08129         if (sublist) {          /* exists -> lookup subitem */
08130                 item_p = sublist->tail;
08131                 while (item_p
08132                        && item_p->max_age
08133                        && (item_p->max_age > RSBAC_CURRENT_TIME)
08134                     )
08135                         item_p = item_p->prev;
08136                 if (item_p)
08137                         memcpy(subdesc, (char *) item_p + sizeof(*item_p),
08138                                list->info.subdesc_size);
08139                 else {
08140                         memset(subdesc, 0, list->info.subdesc_size);
08141                         err = -RSBAC_ENOTFOUND;
08142                 }
08143         } else {
08144                 if (!(list->flags & RSBAC_LIST_DEF_DATA))
08145                         err = -RSBAC_ENOTFOUND;
08146         }
08147         rsbac_read_unlock(&list->lock, &lock_flags);
08148         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08149         return err;
08150 }

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 8496 of file gen_lists.c.

References rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_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_reg_head, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, 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().

08499 {
08500         struct rsbac_list_lol_reg_item_t *list;
08501         struct rsbac_list_lol_item_t *item_p;
08502         u_long lock_flags, rlock_flags;
08503         u_int hash = 0;
08504 
08505         if (!handle)
08506                 return -RSBAC_EINVALIDLIST;
08507         if (!list_initialized)
08508                 return -RSBAC_ENOTINITIALIZED;
08509         if (!next_desc)
08510                 return -RSBAC_EINVALIDPOINTER;
08511 
08512         list = (struct rsbac_list_lol_reg_item_t *) handle;
08513         if (list->self != list)
08514                 return -RSBAC_EINVALIDLIST;
08515 
08516 #ifdef CONFIG_RSBAC_LIST_TRANS
08517         if (ta_number) {
08518                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08519                         return -RSBAC_EINVALIDTRANSACTION;
08520         }
08521 #endif
08522 
08523         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08524 /*
08525         rsbac_pr_debug(lists, "list %s.\n", list->name);
08526 */
08527         rsbac_read_lock(&list->lock, &lock_flags);
08528         if (old_desc) {
08529                 if(list->hash_function)
08530                         hash = list->hash_function(old_desc, list->nr_hashes);
08531 #ifdef CONFIG_RSBAC_LIST_TRANS
08532                 if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08533                         item_p = ta_lookup_lol_item(ta_number, list, old_desc);
08534                 else
08535 #endif
08536                         item_p = lookup_lol_item(list, old_desc);
08537                 if(item_p) {
08538                         item_p = item_p->next;
08539                         while (item_p
08540                                && item_p->max_age && (item_p->max_age > RSBAC_CURRENT_TIME)
08541                             ) {
08542                                 item_p = item_p->next;
08543                         }
08544                         hash++;
08545                 } else
08546                         hash = 0;
08547         } else
08548                 item_p = NULL;
08549         while (!item_p && (hash < list->nr_hashes)) {
08550 #ifdef CONFIG_RSBAC_LIST_TRANS
08551                 if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08552                         item_p = list->hashed[hash].ta_head;
08553                 else
08554 #endif
08555                         item_p = list->hashed[hash].head;
08556                 while (item_p
08557                        && item_p->max_age && (item_p->max_age > RSBAC_CURRENT_TIME)
08558                     ) {
08559                         item_p = item_p->next;
08560                 }
08561                 hash++;
08562         }
08563         if (item_p) {
08564                 memcpy(next_desc, (char *) item_p + sizeof(*item_p),
08565                        list->info.desc_size);
08566         }
08567         rsbac_read_unlock(&list->lock, &lock_flags);
08568         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08569         if (item_p)
08570                 return 0;
08571         else
08572                 return -RSBAC_ENOTFOUND;
08573 }

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 8155 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::def_subdata, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, 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().

08160 {
08161         struct rsbac_list_lol_reg_item_t *list;
08162         struct rsbac_list_lol_item_t *sublist;
08163         struct rsbac_list_item_t *item_p;
08164         u_long lock_flags, rlock_flags;
08165         int err = 0;
08166 #ifdef CONFIG_RSBAC_LIST_TRANS
08167         u_int hash = 0;
08168 #endif
08169 
08170         if (!handle)
08171                 return -RSBAC_EINVALIDLIST;
08172         if (!desc || !subdesc)
08173                 return -RSBAC_EINVALIDVALUE;
08174         if (!list_initialized)
08175                 return -RSBAC_ENOTINITIALIZED;
08176 
08177         list = (struct rsbac_list_lol_reg_item_t *) handle;
08178         if (list->self != list)
08179                 return -RSBAC_EINVALIDLIST;
08180 
08181 #ifdef CONFIG_RSBAC_LIST_TRANS
08182         if (ta_number) {
08183                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08184                         return -RSBAC_EINVALIDTRANSACTION;
08185                 if(list->hash_function)
08186                         hash = list->hash_function(desc, list->nr_hashes);
08187         }
08188 #endif
08189 
08190         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08191 /*
08192         rsbac_pr_debug(lists, "getting data from list %s.\n", list->name);
08193 */
08194         if (subdata && !list->info.subdata_size) {
08195                 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08196                 return -RSBAC_EINVALIDREQUEST;
08197         }
08198 
08199         rsbac_read_lock(&list->lock, &lock_flags);
08200 
08201 #ifdef CONFIG_RSBAC_LIST_TRANS
08202         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08203                 sublist = ta_lookup_lol_item(ta_number, list, desc);
08204         else
08205 #endif
08206                 sublist = lookup_lol_item(list, desc);
08207         if (sublist) {          /* exists -> lookup subitem */
08208                 item_p = lookup_lol_subitem(list, sublist, subdesc);
08209                 if (item_p
08210                     && (!item_p->max_age
08211                         || (item_p->max_age > RSBAC_CURRENT_TIME)
08212                     )
08213                     ) {         /* exists -> copy data, if any */
08214                         if (ttl_p) {
08215                                 if (item_p->max_age)
08216                                         *ttl_p =
08217                                             item_p->max_age -
08218                                             RSBAC_CURRENT_TIME;
08219                                 else
08220                                         *ttl_p = 0;
08221                         }
08222                         if (subdata) {
08223                                 memcpy(subdata,
08224                                        ((char *) item_p) +
08225                                        sizeof(*item_p) +
08226                                        list->info.subdesc_size,
08227                                        list->info.subdata_size);
08228                         }
08229                 } else {
08230                         if (!list->def_subdata)
08231                                 err = -RSBAC_ENOTFOUND;
08232                         else {
08233                                 if (ttl_p)
08234                                         *ttl_p = 0;
08235                                 if (subdata)
08236                                         memcpy(subdata,
08237                                                list->def_subdata,
08238                                                list->info.subdata_size);
08239                         }
08240                 }
08241         } else {
08242                 if (!list->def_subdata)
08243                         err = -RSBAC_ENOTFOUND;
08244                 else {
08245                         if (ttl_p)
08246                                 *ttl_p = 0;
08247                         if (subdata)
08248                                 memcpy(subdata,
08249                                        list->def_subdata,
08250                                        list->info.subdata_size);
08251                 }
08252         }
08253         rsbac_read_unlock(&list->lock, &lock_flags);
08254         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08255         return err;
08256 }

int rsbac_ta_list_lol_remove ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc 
)

Definition at line 7841 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lol_touch, lookup_lol_item(), rsbac_list_lol_reg_item_t::nr_hashes, remove_lol_item(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, 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().

07843 {
07844         struct rsbac_list_lol_reg_item_t *list;
07845         u_long lock_flags, rlock_flags;
07846         u_int hash = 0;
07847 
07848         if (!handle)
07849                 return -RSBAC_EINVALIDLIST;
07850         if (!desc)
07851                 return -RSBAC_EINVALIDVALUE;
07852         if (!list_initialized)
07853                 return -RSBAC_ENOTINITIALIZED;
07854 
07855         list = (struct rsbac_list_lol_reg_item_t *) handle;
07856         if (list->self != list)
07857                 return -RSBAC_EINVALIDLIST;
07858 
07859 #ifdef CONFIG_RSBAC_LIST_TRANS
07860         if (ta_number) {
07861                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07862                         return -RSBAC_EINVALIDTRANSACTION;
07863         }
07864 #endif
07865 
07866         if(list->hash_function)
07867                 hash = list->hash_function(desc, list->nr_hashes);
07868         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07869 /*
07870         rsbac_pr_debug(lists, "removing from list of lists %s.\n",
07871                        list->name);
07872 */
07873         rsbac_write_lock(&list->lock, &lock_flags);
07874 #ifdef CONFIG_RSBAC_LIST_TRANS
07875         if (list->hashed[hash].ta_copied) {
07876                 if (ta_number) {
07877                         if (ta_lookup_lol_item
07878                             (list->hashed[hash].ta_copied, list, desc)) {
07879                                 if (list->hashed[hash].ta_copied != ta_number) {
07880                                         rsbac_write_unlock(&list->lock,
07881                                                            &lock_flags);
07882                                         rsbac_read_unlock(&lol_reg_head.
07883                                                           lock,
07884                                                           &rlock_flags);
07885                                         return -RSBAC_EBUSY;
07886                                 } else
07887                                         ta_remove_lol_item(ta_number, list,
07888                                                            desc);
07889                         }
07890                 } else
07891                         ta_remove_lol_item(list->hashed[hash].ta_copied, list, desc);
07892         } else {
07893                 if (ta_number && lookup_lol_item(list, desc)) {
07894                         ta_lol_copy(ta_number, list, hash);
07895                         ta_remove_lol_item(ta_number, list, desc);
07896                 }
07897         }
07898         if (!ta_number)
07899 #endif
07900         {
07901                 if (lookup_lol_item(list, desc)) {      /* exists -> remove */
07902                         remove_lol_item(list, desc);
07903                         lol_touch(list);
07904                         list->dirty = TRUE;
07905                 }
07906         }
07907         rsbac_write_unlock(&list->lock, &lock_flags);
07908         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07909         return 0;
07910 }

int rsbac_ta_list_lol_remove_all ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle 
)

Definition at line 7916 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.

Referenced by rsbac_list_lol_remove_all().

07918 {
07919         struct rsbac_list_lol_reg_item_t *list;
07920         u_long lock_flags, rlock_flags;
07921         int i;
07922 
07923         if (!handle)
07924                 return -RSBAC_EINVALIDLIST;
07925         if (!list_initialized)
07926                 return -RSBAC_ENOTINITIALIZED;
07927 
07928         list = (struct rsbac_list_lol_reg_item_t *) handle;
07929         if (list->self != list)
07930                 return -RSBAC_EINVALIDLIST;
07931 
07932 #ifdef CONFIG_RSBAC_LIST_TRANS
07933         if (ta_number) {
07934                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07935                         return -RSBAC_EINVALIDTRANSACTION;
07936         }
07937 #endif
07938 
07939         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07940 /*
07941         rsbac_pr_debug(lists, "removing all items from list of lists %s.\n",
07942                        list->name);
07943 */
07944         rsbac_write_lock(&list->lock, &lock_flags);
07945 #ifdef CONFIG_RSBAC_LIST_TRANS
07946         for (i=0; i<list->nr_hashes; i++) {
07947                 if (list->hashed[i].ta_copied) {
07948                         if (ta_number) {
07949                                 if (list->hashed[i].ta_copied == ta_number) {
07950                                         ta_remove_all_lol_items(list, i);
07951                                         if (!list->hashed[i].head) {
07952                                                 list->hashed[i].ta_copied = 0;
07953                                         }
07954                                 } else {
07955                                         rsbac_write_unlock(&list->lock,
07956                                                            &lock_flags);
07957                                         rsbac_read_unlock(&lol_reg_head.lock,
07958                                                           &rlock_flags);
07959                                         return -RSBAC_EBUSY;
07960                                 }
07961                         } else
07962                                 ta_remove_all_lol_items(list, i);
07963                 } else {
07964                         if (ta_number) {
07965                                 if (list->hashed[i].head) {
07966                                         list->hashed[i].ta_head = NULL;
07967                                         list->hashed[i].ta_tail = NULL;
07968                                         list->hashed[i].ta_curr = NULL;
07969                                         list->hashed[i].ta_count = 0;
07970                                         list->hashed[i].ta_copied = ta_number;
07971                                 }
07972                         }
07973                 }
07974         }
07975 
07976         if (!ta_number)
07977 #endif
07978                 for (i=0; i<list->nr_hashes; i++) {
07979                         if (list->hashed[i].head) {
07980                                 remove_all_lol_items(list, i);
07981                                 lol_touch(list);
07982                                 list->dirty = TRUE;
07983                         }
07984                 }
07985         rsbac_write_unlock(&list->lock, &lock_flags);
07986         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07987         return 0;
07988 }

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 6902 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::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lol_touch, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_item_t::max_age, rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, remove_lol_item(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, 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, 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().

06906 {
06907         struct rsbac_list_lol_reg_item_t *list;
06908         struct rsbac_list_lol_item_t *sublist;
06909         struct rsbac_list_item_t *item_p;
06910         u_long lock_flags, rlock_flags;
06911         int err = 0;
06912         u_int hash = 0;
06913 
06914         if (!handle)
06915                 return -RSBAC_EINVALIDLIST;
06916         if (!desc || !subdesc)
06917                 return -RSBAC_EINVALIDVALUE;
06918         if (!list_initialized)
06919                 return -RSBAC_ENOTINITIALIZED;
06920 
06921         list = (struct rsbac_list_lol_reg_item_t *) handle;
06922         if (!list || (list->self != list))
06923                 return -RSBAC_EINVALIDLIST;
06924 
06925 #ifdef CONFIG_RSBAC_LIST_TRANS
06926         if (ta_number && !rsbac_ta_list_exist(0, ta_handle, &ta_number))
06927                 return -RSBAC_EINVALIDTRANSACTION;
06928 #endif
06929 
06930         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
06931         if (list->info.subdata_size && !subdata) {
06932                 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
06933                 return -RSBAC_EINVALIDVALUE;
06934         }
06935 
06936 /*
06937         rsbac_pr_debug(lists, "adding to list %s.\n", list->name);
06938 */
06939         rsbac_write_lock(&list->lock, &lock_flags);
06940 
06941         if(list->hash_function)
06942                 hash = list->hash_function(desc, list->nr_hashes);
06943 #ifdef CONFIG_RSBAC_LIST_TRANS
06944         if (!ta_number)
06945 #endif
06946         {
06947                 sublist = lookup_lol_item(list, desc);
06948                 if (!sublist && (list->flags & RSBAC_LIST_DEF_DATA)
06949                     )
06950                         sublist =
06951                             add_lol_item(list, 0, desc, list->def_data);
06952                 if (sublist) {
06953                         if (sublist->max_age
06954                             && (sublist->max_age <= RSBAC_CURRENT_TIME)
06955                             ) {
06956                                 remove_lol_item(list, desc);
06957                                 err = -RSBAC_EINVALIDTARGET;
06958                         } else {
06959                                 /* exists -> lookup subitem */
06960                                 if (ttl && (ttl != RSBAC_LIST_TTL_KEEP)) {
06961                                         if (ttl > RSBAC_LIST_MAX_AGE_LIMIT)
06962                                                 ttl =
06963                                                     RSBAC_LIST_MAX_AGE_LIMIT;
06964                                         ttl += RSBAC_CURRENT_TIME;
06965                                 }
06966                                 item_p =
06967                                     lookup_lol_subitem(list, sublist,
06968                                                        subdesc);
06969                                 if (item_p) {   /* exists -> update data, if any */
06970                                         if (ttl != RSBAC_LIST_TTL_KEEP)
06971                                                 item_p->max_age = ttl;
06972                                         if (subdata
06973                                             && list->info.subdata_size) {
06974                                                 if (list->def_subdata
06975                                                     && !item_p->max_age
06976                                                     && !memcmp(list->
06977                                                                def_subdata,
06978                                                                subdata,
06979                                                                list->info.
06980                                                                subdata_size)
06981                                                     )
06982                                                         do_remove_lol_subitem
06983                                                             (sublist,
06984                                                              item_p);
06985                                                 else
06986                                                         memcpy(((char *)
06987                                                                 item_p) +
06988                                                                sizeof
06989                                                                (*item_p) +
06990                                                                list->info.
06991                                                                subdesc_size,
06992                                                                subdata,
06993                                                                list->info.
06994                                                                subdata_size);
06995                                         }
06996                                 } else {
06997                                         if (ttl == RSBAC_LIST_TTL_KEEP)
06998                                                 ttl = 0;
06999                                         if (!list->def_subdata
07000                                             || memcmp(list->def_subdata,
07001                                                       subdata,
07002                                                       list->info.
07003                                                       subdata_size)
07004                                             )
07005                                                 add_lol_subitem(list,
07006                                                                 sublist,
07007                                                                 ttl,
07008                                                                 subdesc,
07009                                                                 subdata);
07010                                 }
07011                                 lol_touch(list);
07012                                 list->dirty = TRUE;
07013                         }
07014                 } else {
07015                         err = -RSBAC_EINVALIDTARGET;
07016                         goto out_unlock;
07017                 }
07018         }
07019 #ifdef CONFIG_RSBAC_LIST_TRANS
07020         if (list->hashed[hash].ta_copied || ta_number) {
07021                 if (!list->hashed[hash].ta_copied) {
07022                         if ((err = ta_lol_copy(ta_number, list, hash)))
07023                                 goto out_unlock;
07024                 } else if (ta_number) {
07025                         if (list->hashed[hash].ta_copied != ta_number) {
07026                                 err = -RSBAC_EBUSY;
07027                                 goto out_unlock;
07028                         }
07029                 } else
07030                         ta_number = list->hashed[hash].ta_copied;
07031                 sublist = ta_lookup_lol_item(ta_number, list, desc);
07032                 if (!sublist && (list->flags & RSBAC_LIST_DEF_DATA)
07033                     )
07034                         sublist =
07035                             ta_add_lol_item(ta_number, list, 0, desc,
07036                                             list->def_data);
07037                 if (sublist) {
07038                         if (sublist->max_age
07039                             && (sublist->max_age <= RSBAC_CURRENT_TIME)
07040                             ) {
07041                                 ta_remove_lol_item(ta_number, list, desc);
07042                                 err = -RSBAC_EINVALIDTARGET;
07043                         } else {
07044                                 /* exists -> lookup subitem */
07045                                 if (ttl && (ttl != RSBAC_LIST_TTL_KEEP)) {
07046                                         if (ttl > RSBAC_LIST_MAX_AGE_LIMIT)
07047                                                 ttl =
07048                                                     RSBAC_LIST_MAX_AGE_LIMIT;
07049                                         ttl += RSBAC_CURRENT_TIME;
07050                                 }
07051                                 item_p =
07052                                     lookup_lol_subitem(list, sublist,
07053                                                        subdesc);
07054                                 if (item_p) {   /* exists -> update data, if any */
07055                                         if (ttl != RSBAC_LIST_TTL_KEEP)
07056                                                 item_p->max_age = ttl;
07057                                         if (subdata
07058                                             && list->info.subdata_size) {
07059                                                 if (list->def_subdata
07060                                                     && !item_p->max_age
07061                                                     && !memcmp(list->
07062                                                                def_subdata,
07063                                                                subdata,
07064                                                                list->info.
07065                                                                subdata_size)
07066                                                     )
07067                                                         do_remove_lol_subitem
07068                                                             (sublist,
07069                                                              item_p);
07070                                                 else
07071                                                         memcpy(((char *)
07072                                                                 item_p) +
07073                                                                sizeof
07074                                                                (*item_p) +
07075                                                                list->info.
07076                                                                subdesc_size,
07077                                                                subdata,
07078                                                                list->info.
07079                                                                subdata_size);
07080                                         }
07081                                 } else {
07082                                         if (ttl == RSBAC_LIST_TTL_KEEP)
07083                                                 ttl = 0;
07084                                         if (!list->def_subdata
07085                                             || memcmp(list->def_subdata,
07086                                                       subdata,
07087                                                       list->info.
07088                                                       subdata_size)
07089                                             )
07090                                                 add_lol_subitem(list,
07091                                                                 sublist,
07092                                                                 ttl,
07093                                                                 subdesc,
07094                                                                 subdata);
07095                                 }
07096                         }
07097                 } else {
07098                         err = -RSBAC_EINVALIDTARGET;
07099                 }
07100         }
07101 #endif
07102 
07103       out_unlock:
07104         rsbac_write_unlock(&list->lock, &lock_flags);
07105         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07106         return err;
07107 }

long rsbac_ta_list_lol_subcount ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc 
)

Definition at line 8962 of file gen_lists.c.

References rsbac_list_lol_item_t::count, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, 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().

08964 {
08965         struct rsbac_list_lol_reg_item_t *list;
08966         struct rsbac_list_lol_item_t *sublist;
08967         u_long lock_flags, rlock_flags;
08968         long result;
08969 #ifdef CONFIG_RSBAC_LIST_TRANS
08970         u_int hash = 0;
08971 #endif
08972 
08973         if (!handle)
08974                 return -RSBAC_EINVALIDLIST;
08975         if (!list_initialized)
08976                 return -RSBAC_ENOTINITIALIZED;
08977 
08978         list = (struct rsbac_list_lol_reg_item_t *) handle;
08979         if (list->self != list)
08980                 return -RSBAC_EINVALIDLIST;
08981 
08982 #ifdef CONFIG_RSBAC_LIST_TRANS
08983         if (ta_number) {
08984                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08985                         return -RSBAC_EINVALIDTRANSACTION;
08986                 if(list->hash_function)
08987                         hash = list->hash_function(desc, list->nr_hashes);
08988         }
08989 #endif
08990 
08991         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08992 /*
08993         rsbac_pr_debug(lists, "list %s.\n", list->name);
08994 */
08995         rsbac_read_lock(&list->lock, &lock_flags);
08996 
08997 #ifdef CONFIG_RSBAC_LIST_TRANS
08998         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08999                 sublist = ta_lookup_lol_item(ta_number, list, desc);
09000         else
09001 #endif
09002                 sublist = lookup_lol_item(list, desc);
09003         if (sublist) {
09004                 result = sublist->count;
09005         } else {
09006                 result = -RSBAC_ENOTFOUND;
09007         }
09008         rsbac_read_unlock(&list->lock, &lock_flags);
09009         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
09010         return result;
09011 }

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 8765 of file gen_lists.c.

References FALSE, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, 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().

08768 {
08769         struct rsbac_list_lol_reg_item_t *list;
08770         struct rsbac_list_lol_item_t *sublist;
08771         u_long lock_flags, rlock_flags;
08772         struct rsbac_list_item_t *item_p;
08773         int result;
08774 #ifdef CONFIG_RSBAC_LIST_TRANS
08775         u_int hash = 0;
08776 #endif
08777 
08778         if (!handle || !desc || !subdesc)
08779                 return FALSE;
08780         if (!list_initialized)
08781                 return FALSE;
08782 
08783         list = (struct rsbac_list_lol_reg_item_t *) handle;
08784         if (list->self != list)
08785                 return -RSBAC_EINVALIDLIST;
08786 
08787 #ifdef CONFIG_RSBAC_LIST_TRANS
08788         if (ta_number) {
08789                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08790                         return -RSBAC_EINVALIDTRANSACTION;
08791                 if(list->hash_function)
08792                         hash = list->hash_function(desc, list->nr_hashes);
08793         }
08794 #endif
08795 
08796         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08797 /*
08798         rsbac_pr_debug(lists, "testing on list %s.\n", list->name);
08799 */
08800         rsbac_read_lock(&list->lock, &lock_flags);
08801 
08802 #ifdef CONFIG_RSBAC_LIST_TRANS
08803         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08804                 sublist = ta_lookup_lol_item(ta_number, list, desc);
08805         else
08806 #endif
08807                 sublist = lookup_lol_item(list, desc);
08808         if (sublist) {          /* exists -> lookup subitem */
08809                 item_p = lookup_lol_subitem(list, sublist, subdesc);
08810                 if (item_p
08811                     && (!item_p->max_age
08812                         || (item_p->max_age > RSBAC_CURRENT_TIME)
08813                     )
08814                     ) {         /* exists -> TRUE */
08815                         result = TRUE;
08816                 } else {
08817                         result = FALSE;
08818                 }
08819         } else {
08820                 result = FALSE;
08821         }
08822         rsbac_read_unlock(&list->lock, &lock_flags);
08823         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08824         return result;
08825 }

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 8830 of file gen_lists.c.

References FALSE, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_item(), lookup_lol_subitem_user_compare(), rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, rsbac_list_lol_subexist(), rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.

Referenced by rsbac_list_lol_subexist_compare().

08836 {
08837         struct rsbac_list_lol_reg_item_t *list;
08838         struct rsbac_list_lol_item_t *sublist;
08839         u_long lock_flags, rlock_flags;
08840         struct rsbac_list_item_t *item_p;
08841         int result;
08842 #ifdef CONFIG_RSBAC_LIST_TRANS
08843         u_int hash = 0;
08844 #endif
08845 
08846         if (!handle || !desc || !subdesc)
08847                 return FALSE;
08848         if (!list_initialized)
08849                 return FALSE;
08850         /* Use standard function, if compare is not provided. */
08851         if (!compare)
08852                 return rsbac_list_lol_subexist(handle, desc, subdesc);
08853 
08854         list = (struct rsbac_list_lol_reg_item_t *) handle;
08855         if (list->self != list)
08856                 return -RSBAC_EINVALIDLIST;
08857 
08858 #ifdef CONFIG_RSBAC_LIST_TRANS
08859         if (ta_number) {
08860                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
08861                         return -RSBAC_EINVALIDTRANSACTION;
08862                 if(list->hash_function)
08863                         hash = list->hash_function(desc, list->nr_hashes);
08864         }
08865 #endif
08866 
08867         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
08868 /*
08869         rsbac_pr_debug(lists, "testing on list %s.\n", list->name);
08870 */
08871         rsbac_read_lock(&list->lock, &lock_flags);
08872 
08873 #ifdef CONFIG_RSBAC_LIST_TRANS
08874         if (ta_number && (list->hashed[hash].ta_copied == ta_number))
08875                 sublist = ta_lookup_lol_item(ta_number, list, desc);
08876         else
08877 #endif
08878                 sublist = lookup_lol_item(list, desc);
08879         if (sublist) {          /* exists -> lookup subitem */
08880                 item_p =
08881                     lookup_lol_subitem_user_compare(list, sublist, subdesc,
08882                                                     compare);
08883                 if (item_p
08884                     && (!item_p->max_age
08885                         || (item_p->max_age > RSBAC_CURRENT_TIME)
08886                     )
08887                     ) {         /* exists -> TRUE */
08888                         result = TRUE;
08889                 } else {
08890                         result = FALSE;
08891                 }
08892         } else {
08893                 result = FALSE;
08894         }
08895         rsbac_read_unlock(&list->lock, &lock_flags);
08896         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
08897         return result;
08898 }

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 7529 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, do_remove_lol_item(), rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lol_touch, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, remove_lol_subitem(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, 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().

07532 {
07533         struct rsbac_list_lol_reg_item_t *list;
07534         struct rsbac_list_lol_item_t *sublist;
07535         u_long lock_flags, rlock_flags;
07536         u_int hash = 0;
07537 
07538         if (!handle)
07539                 return -RSBAC_EINVALIDLIST;
07540         if (!desc || !subdesc)
07541                 return -RSBAC_EINVALIDVALUE;
07542         if (!list_initialized)
07543                 return -RSBAC_ENOTINITIALIZED;
07544 
07545         list = (struct rsbac_list_lol_reg_item_t *) handle;
07546         if (list->self != list)
07547                 return -RSBAC_EINVALIDLIST;
07548 
07549 #ifdef CONFIG_RSBAC_LIST_TRANS
07550         if (ta_number) {
07551                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07552                         return -RSBAC_EINVALIDTRANSACTION;
07553         }
07554 #endif
07555 
07556         if(list->hash_function)
07557                 hash = list->hash_function(desc, list->nr_hashes);
07558         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07559 /*
07560         rsbac_pr_debug(lists, "removing from list of lists %s, device %02u:%02u.\n",
07561                        list->name, RSBAC_MAJOR(list->device),
07562                        RSBAC_MINOR(list->device));
07563 */
07564         rsbac_write_lock(&list->lock, &lock_flags);
07565 #ifdef CONFIG_RSBAC_LIST_TRANS
07566         if (list->hashed[hash].ta_copied) {
07567                 sublist = ta_lookup_lol_item(list->hashed[hash].ta_copied, list, desc);
07568                 if (sublist) {
07569                         if (sublist->max_age
07570                             && (sublist->max_age <= RSBAC_CURRENT_TIME)
07571                             ) {
07572                                 ta_do_remove_lol_item(list, sublist, hash);
07573                         } else {
07574                                 if (ta_number
07575                                     && (list->hashed[hash].ta_copied != ta_number)) {
07576                                         rsbac_write_unlock(&list->lock,
07577                                                            &lock_flags);
07578                                         rsbac_read_unlock(&lol_reg_head.
07579                                                           lock,
07580                                                           &rlock_flags);
07581                                         return -RSBAC_EBUSY;
07582                                 }
07583                                 if (lookup_lol_subitem
07584                                     (list, sublist, subdesc))
07585                                         remove_lol_subitem(list, sublist,
07586                                                            subdesc);
07587                                 if (!sublist->count
07588                                     &&
07589                                     ((list->def_data
07590                                       && !memcmp(((char *) sublist) +
07591                                                  sizeof(*sublist) +
07592                                                  list->info.desc_size,
07593                                                  list->def_data,
07594                                                  list->info.data_size)
07595                                      )
07596                                      || (!list->info.data_size
07597                                          && (list->
07598                                              flags & RSBAC_LIST_DEF_DATA)
07599                                      )
07600                                     )
07601                                     ) {
07602                                         ta_do_remove_lol_item(list,
07603                                                               sublist,
07604                                                               hash);
07605                                 }
07606                         }
07607                 }
07608         } else {
07609                 if (ta_number && lookup_lol_item(list, desc)) {
07610                         ta_lol_copy(ta_number, list, hash);
07611                         ta_remove_lol_item(ta_number, list, desc);
07612                 }
07613         }
07614         if (!ta_number)
07615 #endif
07616         {
07617                 sublist = lookup_lol_item(list, desc);
07618                 if (sublist) {
07619                         if (sublist->max_age
07620                             && (sublist->max_age <= RSBAC_CURRENT_TIME)
07621                             ) {
07622                                 do_remove_lol_item(list, sublist, hash);
07623                                 lol_touch(list);
07624                                 list->dirty = TRUE;
07625                         } else {
07626                                 if (lookup_lol_subitem(list, sublist, subdesc)) {       /* exists -> remove and set dirty */
07627                                         remove_lol_subitem(list, sublist,
07628                                                            subdesc);
07629                                         lol_touch(list);
07630                                         list->dirty = TRUE;
07631                                 }
07632                                 if (!sublist->count
07633                                     && ((list->def_data
07634                                          && !memcmp(((char *) sublist) +
07635                                                     sizeof(*sublist) +
07636                                                     list->info.desc_size,
07637                                                     list->def_data,
07638                                                     list->info.data_size)
07639                                         )
07640                                         || (!list->info.data_size
07641                                             && (list->
07642                                                 flags &
07643                                                 RSBAC_LIST_DEF_DATA)
07644                                         )
07645                                     )
07646                                     ) {
07647                                         do_remove_lol_item(list, sublist, hash);
07648                                         lol_touch(list);
07649                                         list->dirty = TRUE;
07650                                 }
07651                         }
07652                 }
07653         }
07654         rsbac_write_unlock(&list->lock, &lock_flags);
07655         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07656         return 0;
07657 }

int rsbac_ta_list_lol_subremove_all ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc 
)

Definition at line 7744 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::hash_function, rsbac_list_lol_reg_item_t::hashed, 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_reg_head, lol_touch, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, remove_all_lol_subitems(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, 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().

07746 {
07747         struct rsbac_list_lol_reg_item_t *list;
07748         struct rsbac_list_lol_item_t *sublist;
07749         u_long lock_flags, rlock_flags;
07750         u_int hash = 0;
07751 
07752         if (!handle)
07753                 return -RSBAC_EINVALIDLIST;
07754         if (!list_initialized)
07755                 return -RSBAC_ENOTINITIALIZED;
07756 
07757         list = (struct rsbac_list_lol_reg_item_t *) handle;
07758         if (list->self != list)
07759                 return -RSBAC_EINVALIDLIST;
07760 
07761 #ifdef CONFIG_RSBAC_LIST_TRANS
07762         if (ta_number) {
07763                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07764                         return -RSBAC_EINVALIDTRANSACTION;
07765         }
07766 #endif
07767 
07768         if(list->hash_function)
07769                 hash = list->hash_function(desc, list->nr_hashes);
07770         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07771 /*
07772         rsbac_pr_debug(lists, "removing all subitems from list of lists %s.\n",
07773                        list->name);
07774 */
07775         rsbac_write_lock(&list->lock, &lock_flags);
07776 #ifdef CONFIG_RSBAC_LIST_TRANS
07777         if (list->hashed[hash].ta_copied) {
07778                 sublist = ta_lookup_lol_item(list->hashed[hash].ta_copied, list, desc);
07779                 if (sublist) {
07780                         if (sublist->max_age
07781                             && (sublist->max_age <= RSBAC_CURRENT_TIME)
07782                             ) {
07783                                 ta_do_remove_lol_item(list, sublist, hash);
07784                         } else {
07785                                 if (ta_number
07786                                     && (list->hashed[hash].ta_copied != ta_number)) {
07787                                         rsbac_write_unlock(&list->lock,
07788                                                            &lock_flags);
07789                                         rsbac_read_unlock(&lol_reg_head.
07790                                                           lock,
07791                                                           &rlock_flags);
07792                                         return -RSBAC_EBUSY;
07793                                 }
07794                                 remove_all_lol_subitems(sublist);
07795                                 if ((list->def_data
07796                                      && !memcmp(((char *) sublist) +
07797                                                 sizeof(*sublist) +
07798                                                 list->info.desc_size,
07799                                                 list->def_data,
07800                                                 list->info.data_size)
07801                                     )
07802                                     || (!list->info.data_size
07803                                         && (list->
07804                                             flags & RSBAC_LIST_DEF_DATA)
07805                                     )
07806 
07807                                     ) {
07808                                         ta_do_remove_lol_item(list,
07809                                                               sublist,
07810                                                               hash);
07811                                 }
07812                         }
07813                 }
07814         } else {
07815                 if (ta_number && lookup_lol_item(list, desc)) {
07816                         ta_lol_copy(ta_number, list, hash);
07817                         sublist =
07818                             ta_lookup_lol_item(ta_number, list, desc);
07819                         if (sublist)
07820                                 remove_all_lol_subitems(sublist);
07821                 }
07822         }
07823         if (!ta_number)
07824 #endif
07825         {
07826                 sublist = lookup_lol_item(list, desc);
07827                 if (sublist && sublist->head) {
07828                         remove_all_lol_subitems(sublist);
07829                         lol_touch(list);
07830                         list->dirty = TRUE;
07831                 }
07832         }
07833         rsbac_write_unlock(&list->lock, &lock_flags);
07834         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07835         return 0;
07836 }

int rsbac_ta_list_lol_subremove_count ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc,
u_long  count 
)

Definition at line 7392 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(), do_remove_lol_subitem(), rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, 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_reg_head, lol_touch, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EBUSY, RSBAC_EINVALIDLIST, 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_um_set_pass().

07395 {
07396         struct rsbac_list_lol_reg_item_t *list;
07397         struct rsbac_list_lol_item_t *sublist;
07398         u_long lock_flags, rlock_flags;
07399         u_int hash = 0;
07400 
07401         if (!count)
07402                 return 0;
07403         if (!handle)
07404                 return -RSBAC_EINVALIDLIST;
07405         if (!desc)
07406                 return -RSBAC_EINVALIDVALUE;
07407         if (!list_initialized)
07408                 return -RSBAC_ENOTINITIALIZED;
07409 
07410         list = (struct rsbac_list_lol_reg_item_t *) handle;
07411         if (list->self != list)
07412                 return -RSBAC_EINVALIDLIST;
07413 
07414 #ifdef CONFIG_RSBAC_LIST_TRANS
07415         if (ta_number) {
07416                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07417                         return -RSBAC_EINVALIDTRANSACTION;
07418         }
07419 #endif
07420 
07421         if(list->hash_function)
07422                 hash = list->hash_function(desc, list->nr_hashes);
07423 
07424         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07425 /*
07426         rsbac_pr_debug(lists, "removing from list of lists %s, device %02u:%02u.\n",
07427                        list->name, RSBAC_MAJOR(list->device),
07428                        RSBAC_MINOR(list->device));
07429 */
07430         rsbac_write_lock(&list->lock, &lock_flags);
07431 #ifdef CONFIG_RSBAC_LIST_TRANS
07432         if (list->hashed[hash].ta_copied) {
07433                 sublist = ta_lookup_lol_item(list->hashed[hash].ta_copied, list, desc);
07434                 if (sublist) {
07435                         if (sublist->max_age
07436                             && (sublist->max_age <= RSBAC_CURRENT_TIME)
07437                             ) {
07438                                 ta_do_remove_lol_item(list, sublist, hash);
07439                         } else {
07440                                 if (ta_number
07441                                     && (list->hashed[hash].ta_copied != ta_number)) {
07442                                         rsbac_write_unlock(&list->lock,
07443                                                            &lock_flags);
07444                                         rsbac_read_unlock(&lol_reg_head.
07445                                                           lock,
07446                                                           &rlock_flags);
07447                                         return -RSBAC_EBUSY;
07448                                 }
07449                                 while (sublist->head && (count > 0)) {
07450                                         do_remove_lol_subitem(sublist,
07451                                                               sublist->head);
07452                                         count--;
07453                                 }
07454                                 if (!sublist->count
07455                                     && ((list->def_data
07456                                          && !memcmp(((char *) sublist) +
07457                                                     sizeof(*sublist) +
07458                                                     list->info.desc_size,
07459                                                     list->def_data,
07460                                                     list->info.data_size)
07461                                         )
07462                                         || (!list->info.data_size
07463                                             && (list->
07464                                                 flags &
07465                                                 RSBAC_LIST_DEF_DATA)
07466                                         )
07467                                     )
07468                                     ) {
07469                                         ta_do_remove_lol_item(list,
07470                                                               sublist,
07471                                                               hash);
07472                                 }
07473                         }
07474                 }
07475         } else {
07476                 if (ta_number && lookup_lol_item(list, desc)) {
07477                         ta_lol_copy(ta_number, list, hash);
07478                         ta_remove_lol_item(ta_number, list, desc);
07479                 }
07480         }
07481         if (!ta_number)
07482 #endif
07483         {
07484                 sublist = lookup_lol_item(list, desc);
07485                 if (sublist) {
07486                         if (sublist->max_age
07487                             && (sublist->max_age <= RSBAC_CURRENT_TIME)
07488                             ) {
07489                                 do_remove_lol_item(list, sublist, hash);
07490                                 lol_touch(list);
07491                                 list->dirty = TRUE;
07492                         } else {
07493                                 while (sublist->head && (count > 0)) {
07494                                         do_remove_lol_subitem(sublist,
07495                                                               sublist->head);
07496                                         count--;
07497                                 }
07498                                 lol_touch(list);
07499                                 list->dirty = TRUE;
07500                                 if (!sublist->count
07501                                     && ((list->def_data
07502                                          && !memcmp(((char *) sublist) +
07503                                                     sizeof(*sublist) +
07504                                                     list->info.desc_size,
07505                                                     list->def_data,
07506                                                     list->info.data_size)
07507                                         )
07508                                         || (!list->info.data_size
07509                                             && (list->
07510                                                 flags &
07511                                                 RSBAC_LIST_DEF_DATA)
07512                                         )
07513                                     )
07514                                     ) {
07515                                         do_remove_lol_item(list, sublist, hash);
07516                                 }
07517                         }
07518                 }
07519         }
07520         rsbac_write_unlock(&list->lock, &lock_flags);
07521         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07522         return 0;
07523 }

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 7663 of file gen_lists.c.

References rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, rsbac_list_lol_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, remove_lol_subitem(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.

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().

07666 {
07667         struct rsbac_list_lol_reg_item_t *list;
07668         struct rsbac_list_lol_item_t *sublist;
07669         u_long lock_flags, rlock_flags;
07670         int i;
07671 
07672         if (!handle)
07673                 return -RSBAC_EINVALIDLIST;
07674         if (!subdesc)
07675                 return -RSBAC_EINVALIDVALUE;
07676         if (!list_initialized)
07677                 return -RSBAC_ENOTINITIALIZED;
07678 
07679         list = (struct rsbac_list_lol_reg_item_t *) handle;
07680         if (list->self != list)
07681                 return -RSBAC_EINVALIDLIST;
07682 
07683 #ifdef CONFIG_RSBAC_LIST_TRANS
07684         if (ta_number) {
07685                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07686                         return -RSBAC_EINVALIDTRANSACTION;
07687         }
07688 #endif
07689 
07690         rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
07691 /*
07692         rsbac_pr_debug(lists, "removing from list of lists %s.\n", list->name);
07693 */
07694         rsbac_write_lock(&list->lock, &lock_flags);
07695 #ifdef CONFIG_RSBAC_LIST_TRANS
07696         for (i=0; i<list->nr_hashes; i++) {
07697                 if (list->hashed[i].ta_copied) {
07698                         if (ta_number && (list->hashed[i].ta_copied != ta_number)) {
07699                                 rsbac_write_unlock(&list->lock, &lock_flags);
07700                                 rsbac_read_unlock(&lol_reg_head.lock,
07701                                                   &rlock_flags);
07702                                 return -RSBAC_EBUSY;
07703                         }
07704                         sublist = list->hashed[i].head;
07705                         while (sublist) {
07706                                 remove_lol_subitem(list, sublist, subdesc);
07707                                 sublist = sublist->next;
07708                         }
07709                 } else {
07710                         if (ta_number) {
07711                                 ta_lol_copy(ta_number, list, i);
07712                                 sublist = list->hashed[i].head;
07713                                 while (sublist) {
07714                                         remove_lol_subitem(list, sublist, subdesc);
07715                                         sublist = sublist->next;
07716                                 }
07717                         }
07718                 }
07719         }
07720         if (!ta_number)
07721 #endif
07722         {
07723                 for (i=0; i<list->nr_hashes; i++) {
07724                         sublist = list->hashed[i].head;
07725                         while (sublist) {
07726                                 if (lookup_lol_subitem(list, sublist, subdesc)) {       /* exists -> remove and set dirty */
07727                                         remove_lol_subitem(list, sublist, subdesc);
07728                                         lol_touch(list);
07729                                         list->dirty = TRUE;
07730                                 }
07731                                 sublist = sublist->next;
07732                         }
07733                 }
07734         }
07735         rsbac_write_unlock(&list->lock, &lock_flags);
07736         rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
07737         return 0;
07738 }

int rsbac_ta_list_remove ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle,
void *  desc 
)

Definition at line 7245 of file gen_lists.c.

References rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, lookup_item(), rsbac_list_reg_item_t::nr_hashes, reg_head, remove_item(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, 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().

07247 {
07248         struct rsbac_list_reg_item_t *list;
07249         u_long lock_flags, rlock_flags;
07250         u_int hash = 0;
07251 
07252         if (!handle)
07253                 return -RSBAC_EINVALIDLIST;
07254         if (!desc)
07255                 return -RSBAC_EINVALIDVALUE;
07256         if (!list_initialized)
07257                 return -RSBAC_ENOTINITIALIZED;
07258 
07259         list = (struct rsbac_list_reg_item_t *) handle;
07260         if (!list || (list->self != list))
07261                 return -RSBAC_EINVALIDLIST;
07262 
07263 #ifdef CONFIG_RSBAC_LIST_TRANS
07264         if (ta_number) {
07265                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07266                         return -RSBAC_EINVALIDTRANSACTION;
07267         }
07268 #endif
07269 
07270         rsbac_read_lock(&reg_head.lock, &rlock_flags);
07271 /*
07272         rsbac_pr_debug(lists, "removing from list %s.\n", list->name);
07273 */
07274         if(list->hash_function)
07275                 hash = list->hash_function(desc, list->nr_hashes);
07276         rsbac_write_lock(&list->lock, &lock_flags);
07277 #ifdef CONFIG_RSBAC_LIST_TRANS
07278         if (list->hashed[hash].ta_copied) {
07279                 if (ta_number) {
07280                         if (ta_lookup_item(list->hashed[hash].ta_copied, list, desc)) {
07281                                 if (list->hashed[hash].ta_copied != ta_number) {
07282                                         rsbac_write_unlock(&list->lock,
07283                                                            &lock_flags);
07284                                         rsbac_read_unlock(&reg_head.lock,
07285                                                           &rlock_flags);
07286                                         return -RSBAC_EBUSY;
07287                                 } else
07288                                         ta_remove_item(ta_number, list,
07289                                                        desc);
07290                         }
07291                 } else
07292                         ta_remove_item(list->hashed[hash].ta_copied, list, desc);
07293         } else {
07294                 if (ta_number && lookup_item(list, desc)) {
07295                         ta_copy(ta_number, list, hash);
07296                         ta_remove_item(ta_number, list, desc);
07297                 }
07298         }
07299         if (!ta_number)
07300 #endif
07301         {
07302                 if (lookup_item(list, desc)) {  /* exists -> remove */
07303                         remove_item(list, desc);
07304                         touch(list);
07305                         list->dirty = TRUE;
07306                 }
07307         }
07308         rsbac_write_unlock(&list->lock, &lock_flags);
07309         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
07310         return 0;
07311 }

int rsbac_ta_list_remove_all ( rsbac_list_ta_number_t  ta_number,
rsbac_list_handle_t  handle 
)

Definition at line 7317 of file gen_lists.c.

References rsbac_list_reg_item_t::hashed, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::nr_hashes, reg_head, RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.

Referenced by rsbac_list_remove_all().

07319 {
07320         struct rsbac_list_reg_item_t *list;
07321         u_long lock_flags, rlock_flags;
07322         int i;
07323 
07324         if (!handle)
07325                 return -RSBAC_EINVALIDLIST;
07326         if (!list_initialized)
07327                 return -RSBAC_ENOTINITIALIZED;
07328 
07329         list = (struct rsbac_list_reg_item_t *) handle;
07330         if (list->self != list)
07331                 return -RSBAC_EINVALIDLIST;
07332 
07333 #ifdef CONFIG_RSBAC_LIST_TRANS
07334         if (ta_number) {
07335                 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number))
07336                         return -RSBAC_EINVALIDTRANSACTION;
07337         }
07338 #endif
07339 
07340         rsbac_read_lock(&reg_head.lock, &rlock_flags);
07341 /*
07342         rsbac_pr_debug(lists, "removing all items from list %s.\n", list->name);
07343 */
07344         rsbac_write_lock(&list->lock, &lock_flags);
07345 #ifdef CONFIG_RSBAC_LIST_TRANS
07346         for (i=0; i<list->nr_hashes; i++) {
07347                 if (list->hashed[i].ta_copied) {
07348                         if (ta_number) {
07349                                 if (list->hashed[i].ta_copied == ta_number) {
07350                                         ta_remove_all_items(list, i);
07351                                         if (!list->hashed[i].head) {
07352                                                 list->hashed[i].ta_copied = 0;
07353                                         }
07354                                 } else {
07355                                         rsbac_write_unlock(&list->lock,
07356                                                            &lock_flags);
07357                                         rsbac_read_unlock(&reg_head.lock,
07358                                                           &rlock_flags);
07359                                         return -RSBAC_EBUSY;
07360                                 }
07361                         } else
07362                                 ta_remove_all_items(list, i);
07363                 } else {
07364                         if (ta_number) {
07365                                 if (list->hashed[i].head) {
07366                                         list->hashed[i].ta_head = NULL;
07367                                         list->hashed[i].ta_tail = NULL;
07368                                         list->hashed[i].ta_curr = NULL;
07369                                         list->hashed[i].ta_count = 0;
07370                                         list->hashed[i].ta_copied = ta_number;
07371                                 }
07372                         }
07373                 }
07374         }
07375                 
07376         if (!ta_number)
07377 #endif
07378                 for (i=0; i<list->nr_hashes; i++)
07379                         if (list->hashed[i].head) {
07380                                 remove_all_items(list, i);
07381                                 touch(list);
07382                                 list->dirty = TRUE;
07383                         }
07384         rsbac_write_unlock(&list->lock, &lock_flags);
07385         rsbac_read_unlock(&reg_head.lock, &rlock_flags);
07386         return 0;
07387 }


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