Complete query APIs for in-policy objects
Changes:
- drop convert functions for now - we will require binary compatibility at least in the immediate future, as off-list discussion w/ Tresys established. We might need to get back to this problem after FC5t1
- implement all query APIs for in-policy objects, and simplify them.
I've done minimal testing - the iterate() function works... (and I know count() works from before). List is not going to work, because it's a stub. Query... haven't tested it yet (but all sepol functions were tested w/ respect to sepol, and worked).
libsemanage/src/booleans_policy.c +21 -59
@@ -16,23 +16,6 @@ typedef struct dbase_direct dbase_t;#include "database.h" #include "debug.h" -static inline int semanage2sepol_key ( -semanage_bool_key_t * semanage_key, -sepol_bool_key_t ** sepol_key) { - - *sepol_key = (sepol_bool_key_t *) semanage_key; -return STATUS_SUCCESS ; -} - - -static inline int semanage2sepol_data ( -semanage_bool_t * semanage_data, -sepol_bool_t ** sepol_data) { - - *sepol_data = (sepol_bool_t *) semanage_data; -return STATUS_SUCCESS ; -} -/* BOOLEAN RECORD (SEPOL): method table */ record_table_t SEPOL_BOOL_RTABLE = { .create = sepol_bool_create,
@@ -48,11 +31,11 @@ int semanage_bool_query( semanage_bool_key_t* key, semanage_bool_t** response) { -/* Stub */ - handle =NULL ; - key =NULL ; - response =NULL ; -return STATUS_ERR ; +dbase_config_t * dconfig =semanage_bool_dbase_policy (handle); + +/* Note: requires binary compatible sepol record */ +return dconfig->dtable->query (handle, dconfig->dbase, + (sepol_bool_key_t *) key, (sepol_bool_t **) response); } int semanage_bool_exists(
@@ -60,39 +43,19 @@ int semanage_bool_exists( semanage_bool_key_t* key, int* response) { -dbase_config_t * dconfig = -semanage_bool_dbase_policy (handle); -sepol_bool_key_t * sepol_key; - -if (semanage2sepol_key (key, &sepol_key) <0 ) - goto err; - -if (dconfig->dtable->exists (handle, dconfig->dbase, - sepol_key, response) <0 ) - goto err; - -return STATUS_SUCCESS ; - - err: -/* FIXME: handle error */ -return STATUS_ERR ; +dbase_config_t * dconfig =semanage_bool_dbase_policy (handle); + +/* Note: requires binary compatible sepol record */ +return dconfig->dtable->exists (handle, dconfig->dbase, + (sepol_bool_key_t *) key, response); }int semanage_bool_count (semanage_handle_t * handle,int * response) { -dbase_config_t * dconfig = -semanage_bool_dbase_policy (handle); - -if (dconfig->dtable->count (handle, dconfig->dbase, response) <0 ) - goto err; - -return STATUS_SUCCESS ; - - err: -/* FIXME: handle error */ -return STATUS_ERR ; +dbase_config_t * dconfig =semanage_bool_dbase_policy (handle); +return dconfig->dtable->count (handle, dconfig->dbase, response); } int semanage_bool_iterate(
@@ -101,11 +64,11 @@ int semanage_bool_iterate( void* varg), void* handler_arg) { -/* Stub */ - handle =NULL ; - handler =NULL ; - handler_arg =NULL ; -return STATUS_ERR ; +/* Note: requires binary compatible sepol record */ + dbase_config_t* dconfig = semanage_bool_dbase_policy(handle); +return dconfig->dtable->iterate (handle, dconfig->dbase, + (int (*) (sepol_bool_t *,void *)) + handler, handler_arg); } int semanage_bool_list(
@@ -113,9 +76,8 @@ int semanage_bool_list( semanage_bool_t*** records, size_t* count) { -/* Stub */ - handle =NULL ; - records =NULL ; - count =NULL ; -return STATUS_ERR ; +/* Note: requires binary compatible sepol record */ +dbase_config_t * dconfig =semanage_bool_dbase_policy (handle); +return dconfig->dtable->list (handle, dconfig->dbase, + (sepol_bool_t ***) records, count); }
libsemanage/src/interfaces_policy.c +20 -59
113 lines not on this page · raw message
libsemanage/src/ports_policy.c +20 -59
113 lines not on this page · raw message
libsemanage/src/users_policy.c +20 -59
113 lines not on this page · raw message