Resync to sepol changes
- update POLICYDB record extension to contain the functions: add, modify, set, exists, iterate, and query
- configure all tables with the appropriate functions
- implement those functions in database_policydb.c (6 stubs removed).
- implement database_file.c:iterate() (1 more stub)
- add more error messages, so I can tell what's going on - they can be fixed later to something better.
- change Stub status code of all print functions from STATUS_ERR to STATUS_NODATA, so that the flat file parser will exit and not get stuck in infinite loop recalling the stubs.
- fix bug: initialize modified to 0 in FILE database
=============
I got commit() to start working somehow (no idea how), so now I can test this.
It _should_ commit the users file successfully... but it doesn't yet - need to do some more investigation. I'm pretty sure it's read successfully, updated successfully, and merged into policy... not sure why it doesn't commit.
I'll probably get it working pretty soon. For now, it stays #if0-ed
libsemanage/src/booleans_file.c +1 -1
@@ -36,7 +36,7 @@ static int bool_parse(/* Stub */ info =NULL ; bool = NULL; -return STATUS_ERR ; +return STATUS_NODATA ; }
libsemanage/src/booleans_policydb.c +5 -2
@@ -22,8 +22,11 @@ extern record_table_t SEPOL_BOOL_RTABLE;/* BOOLEAN RECRORD (SEPOL): POLICYDB extension: method table */ record_policydb_table_t SEMANAGE_BOOL_POLICYDB_RTABLE = { - .add =NULL ,/* FIXME */ - .modify =NULL ,/* FIXME */ + .add =NULL , + .modify =NULL , + .set = sepol_bool_set, + .query =NULL ,/* FIXME */ + .exists =NULL ,/* FIXME */ .iterate = sepol_bool_iterate, };
libsemanage/src/database_file.c +37 -13
97 lines not on this page · raw message
libsemanage/src/database_policydb.c +42 -37
176 lines not on this page · raw message
libsemanage/src/database_policydb.h +29 -5
@@ -11,17 +11,41 @@ typedef struct dbase_policydb dbase_poli/* POLICYDB extension to RECORD interface - method table */ typedef struct record_policydb_table { -/* Add record into the policy database */ -int (*add) (sepol_policydb_t * policydb,record_t * record); +/* Add policy record */ +int (*add) ( +sepol_policydb_t * policydb, +record_key_t * rkey, +record_t * record); + +/* Modify policy record */ +int (*modify) ( +sepol_policydb_t * policydb, +record_key_t * rkey, +record_t * record); -/* Modify record into the policy database */ -int (*modify) (sepol_policydb_t * policydb,record_t * record); +/* Set policy record */ +int (*set) ( +sepol_policydb_t * policydb, +record_key_t * rkey, +record_t * record); + +/* Query policy record */ +int (*query) ( +sepol_policydb_t * policydb, +record_key_t * rkey, +record_t ** response); +/* Check if a record exists */ +int (*exists) ( +sepol_policydb_t * policydb, +record_key_t * rkey, +int * response); +/* Iterate over records */ int (*iterate) (sepol_policydb_t * policydb,int (*fn)(record_t * record,void * fn_arg), -void * arg); +void * arg); }record_policydb_table_t ;
libsemanage/src/interfaces_file.c +2 -3
@@ -36,8 +36,7 @@ static int iface_parse(/* Stub */ info =NULL ; iface =NULL ; -return STATUS_ERR ; - +return STATUS_NODATA ; }/* IFACE RECORD: metod table (interfaces_local.c) */
@@ -52,7 +51,7 @@ record_file_table_t SEMANAGE_IFACE_FILE_int iface_file_dbase_init (dbase_config_t * dconfig) {if (dbase_file_init ( -NULL ,/* FIXME */ +"" ,/* FIXME */ &SEMANAGE_IFACE_RTABLE , &SEMANAGE_IFACE_FILE_RTABLE , &dconfig->dbase) <0 )
libsemanage/src/interfaces_policydb.c +5 -2
@@ -22,8 +22,11 @@ extern record_table_t SEPOL_IFACE_RTABLE/* INTERFACE RECRORD (SEPOL): POLICYDB extension: method table */ record_policydb_table_t SEMANAGE_IFACE_POLICYDB_RTABLE = { - .add = sepol_iface_add, - .modify =NULL ,/* FIXME */ + .add =NULL , + .modify = sepol_iface_modify, + .set =NULL , + .query = sepol_iface_query, + .exists = sepol_iface_exists, .iterate = sepol_iface_iterate, };
libsemanage/src/policy_components.c +11 -7
@@ -25,20 +25,25 @@ static int load_handler(dbase_t * dbase = arg->dconfig->dbase;dbase_table_t * dtable = arg->dconfig->dtable;record_table_t * rtable = dtable->get_rtable (handle, dbase); - +if (rtable->key_extract (record, &rkey) <0 ) goto err;switch (arg->mode) { - + +/* WARNING: +* This assumes binary compatibility between +* the source and target key/record type. This is currently +* true, but may change in the future (?) */ +case MODE_SET : -if (dtable->set (handle, dbase, rkey, record) <0 ) +if (dtable->set (handle, dbase, rkey, record) <0 ) goto err;break ;default :case MODE_MODIFY : -if (dtable->modify (handle, dbase, rkey, record) <0 ) +if (dtable->modify (handle, dbase, rkey, record) <0 ) goto err;break ;
@@ -91,15 +96,14 @@ int semanage_base_merge_components( load_arg.mode = components[i].mode;if (from->dtable->iterate ( - handle, from->dbase, load_handler, &load_arg) <0 ) + handle, from->dbase, load_handler, &load_arg) <0 ) goto err; - }return STATUS_SUCCESS ; err: -/* FIXME: handle error */ +ERR (handle,"could not merge local modifications into policy" );return STATUS_ERR ; }
libsemanage/src/ports_policydb.c +5 -2
@@ -22,8 +22,11 @@ extern record_table_t SEPOL_PORT_RTABLE;/* PORT RECORD (SEPOL): POLICYDB extension : method table */ record_policydb_table_t SEMANAGE_PORT_POLICYDB_RTABLE = { - .add = sepol_port_add, - .modify =NULL ,/* FIXME */ + .add =NULL , + .modify = sepol_port_modify, + .set =NULL , + .query = sepol_port_query, + .exists = sepol_port_exists, .iterate = sepol_port_iterate, };
libsemanage/src/seusers_file.c +1 -1
@@ -34,7 +34,7 @@ static int seuser_parse(/* Stub */ info =NULL ; seuser =NULL ; -return STATUS_ERR ; +return STATUS_NODATA ; }/* SEUSER RECORD: method table (seusers.c) */
libsemanage/src/users_policydb.c +4 -1
@@ -22,8 +22,11 @@ extern record_table_t SEPOL_USER_RTABLE;/* USER RECRORD (SEPOL): POLICYDB extension: method table */ record_policydb_table_t SEMANAGE_USER_POLICYDB_RTABLE = { - .add =NULL ,/* FIXME */ + .add =NULL , .modify = sepol_user_modify, + .set =NULL , + .query =NULL ,/* FIXME */ + .exists = sepol_user_exists, .iterate = sepol_user_iterate, };
libsepol/src/users.c +1 -1
@@ -265,7 +265,7 @@ int sepol_user_modify( goto err; } } - +free (name);free (roles);free (mls_range);
lyris test
?
Quoted 31 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Ivan Gyurdiev
Sent: zaterdag 22 oktober 2005 20:55
To: [email protected]
Cc: Stephen Smalley
Subject: [ SEMANAGE ] Resync to sepol changes- update POLICYDB record extension to contain the functions: add, modify, set, exists, iterate, and query
- configure all tables with the appropriate functions
- implement those functions indatabase_policydb.c(6 stubs removed).
- implement database_file.c:iterate() (1 more stub)- add more error messages, so I can tell what's going on - they can be fixed later to something better.
- change Stub status code of all print functions fromSTATUS_ERRtoSTATUS_NODATA, so that the flat file parser will exit and not get stuck in infinite loop recalling the stubs.- fix bug: initialize modified to 0 in FILE database
=============
I gotcommit()to start working somehow (no idea how), so now I can test this.
It _should_ commit the users file successfully... but it doesn't yet - need to do some more investigation.
I'm pretty sure it's read successfully, updated successfully, and merged into policy... not sure why it doesn't commit.
Quoted 3 lines
I'll probably get it working pretty soon. For now, it stays #if0-ed
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 3 lines
It _should_ commit the users file successfully... but it doesn't yet - need to do some more investigation. I'm pretty sure it's read successfully, updated successfully, and merged into policy... not sure why it doesn't commit.
I see what's wrong... my implementations of add() and modify() invoke other functions of the database, but the enter_ro/exit_ro/enter_rw functions are not reentrant. As a result, the read lock is dropped early, and more importantly, the cache is dropped too (so all modifications are lost every time).
Hmm...
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 4 lines
- change Stub status code of all print functions from
STATUS_ERRtoSTATUS_NODATA, so that the flat file parser will exit and not get stuck in infinite loop recalling the stubs.
s/print/parse/ here
My file parser loop hands all control over record parsing to the parse() function, so it is dependent on it to tell it when the last record is parsed (by signaling STATUS_NODATA), so that's the loop I got rid of for stubs.
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.