Use the paths array
Joshua's complained about my non-use of the store path array. Correct this issue.
libsemanage/src/direct_api.c +23 -12
@@ -117,11 +117,13 @@ int semanage_direct_connect(semanage_han sh->funcs = &direct_funcs;/* Object databases: local modifications */ -if (user_base_file_dbase_init (sh,"users.local" , +if (user_base_file_dbase_init (sh, +semanage_fname (SEMANAGE_USERS_BASE_LOCAL ),semanage_user_base_dbase_local (sh)) <0 ) goto err; -if (user_extra_file_dbase_init (sh,"users_extra.local" , +if (user_extra_file_dbase_init (sh, +semanage_fname (SEMANAGE_USERS_EXTRA_LOCAL ),semanage_user_extra_dbase_local (sh)) <0 ) goto err;
@@ -131,27 +133,33 @@ int semanage_direct_connect(semanage_han semanage_user_dbase_local(sh)) < 0) goto err; -if (port_file_dbase_init (sh,"ports.local" , +if (port_file_dbase_init (sh, +semanage_fname (SEMANAGE_PORTS_LOCAL ),semanage_port_dbase_local (sh)) <0 ) goto err; -if (iface_file_dbase_init (sh,"interfaces.local" , +if (iface_file_dbase_init (sh, +semanage_fname (SEMANAGE_INTERFACES_LOCAL ),semanage_iface_dbase_local (sh)) <0 ) goto err; -if (bool_file_dbase_init (sh,"booleans.local" , +if (bool_file_dbase_init (sh, +semanage_fname (SEMANAGE_BOOLEANS_LOCAL ),semanage_bool_dbase_local (sh)) <0 ) goto err; -if (fcontext_file_dbase_init (sh,"file_contexts.local" , +if (fcontext_file_dbase_init (sh, +semanage_fname (SEMANAGE_FC_LOCAL ),semanage_fcontext_dbase_local (sh)) <0 ) goto err; -if (seuser_file_dbase_init (sh,"seusers" , +if (seuser_file_dbase_init (sh, +semanage_fname (SEMANAGE_SEUSERS_LOCAL ),semanage_seuser_dbase_local (sh)) <0 ) goto err; -if (node_file_dbase_init (sh,"nodes.local" , +if (node_file_dbase_init (sh, +semanage_fname (SEMANAGE_NODES_LOCAL ),semanage_node_dbase_local (sh)) <0 ) goto err;
@@ -160,7 +168,8 @@ int semanage_direct_connect(semanage_han semanage_user_base_dbase_policy(sh)) < 0) goto err; -if (user_extra_file_dbase_init (sh,"users_extra" , +if (user_extra_file_dbase_init (sh, +semanage_fname (SEMANAGE_USERS_EXTRA ),semanage_user_extra_dbase_policy (sh)) <0 ) goto err;
@@ -179,11 +188,13 @@ int semanage_direct_connect(semanage_hanif (bool_policydb_dbase_init (sh,semanage_bool_dbase_policy (sh)) <0 ) goto err; -if (fcontext_file_dbase_init (sh,"file_contexts" , +if (fcontext_file_dbase_init (sh, +semanage_fname (SEMANAGE_FC ),semanage_fcontext_dbase_policy (sh)) <0 ) goto err; -if (seuser_file_dbase_init (sh,"seusers.final" , +if (seuser_file_dbase_init (sh, +semanage_fname (SEMANAGE_SEUSERS ),semanage_seuser_dbase_policy (sh)) <0 ) goto err;
@@ -503,7 +514,7 @@ static int semanage_direct_commit(semana/* Users_extra */ if (sepol_module_package_get_user_extra_len (base)) { -if ((ofilename =semanage_path (SEMANAGE_TMP ,SEMANAGE_USER_EXTRA )) ==NULL || +if ((ofilename =semanage_path (SEMANAGE_TMP ,SEMANAGE_USERS_EXTRA )) ==NULL ||write_file (sh, ofilename,sepol_module_package_get_user_extra (base),sepol_module_package_get_user_extra_len (base)) ==-1 ) { goto cleanup;
libsemanage/src/pywrap-test.py +0 -2
@@ -1026,8 +1026,6 @@ class Tests: raise Error("Could not commit test transaction") print "Commit status (transaction number): ", status - self.test_nodes(sh) - status = semanage.semanage_begin_transaction(sh) if status < 0: raise Error("Could not start semanage transaction")
libsemanage/src/semanage_store.c +13 -0
@@ -96,6 +96,14 @@ static const char *semanage_sandbox_path"/homedir_template" ,"/file_contexts.template" ,"/commit_num" , +"/ports.local" , +"/interfaces.local" , +"/nodes.local" , +"/booleans.local" , +"/file_contexts.local" , +"/seusers" , +"/users_extra.local" , +"/users.local" ,"/seusers.final" , "/users_extra", };
@@ -188,6 +196,11 @@ int semanage_check_init(const char *rootreturn 0 ; } +/* Given a definition number, return a file name from the paths array */ +const char *semanage_fname (enum semanage_sandbox_defs file_enum) { +return semanage_sandbox_paths[file_enum]; +} +/* Given a store location (active/previous/tmp) and a definition * number, return a fully-qualified path to that file or directory. * The caller must not alter the string returned (and hence why this
libsemanage/src/semanage_store.h +16 -2
@@ -45,8 +45,16 @@ enum semanage_sandbox_defs {SEMANAGE_HOMEDIR_TMPL ,SEMANAGE_FC_TMPL ,SEMANAGE_COMMIT_NUM_FILE , +SEMANAGE_PORTS_LOCAL , +SEMANAGE_INTERFACES_LOCAL , +SEMANAGE_NODES_LOCAL , +SEMANAGE_BOOLEANS_LOCAL , +SEMANAGE_FC_LOCAL , +SEMANAGE_SEUSERS_LOCAL , +SEMANAGE_USERS_BASE_LOCAL , +SEMANAGE_USERS_EXTRA_LOCAL ,SEMANAGE_SEUSERS , -SEMANAGE_USER_EXTRA , +SEMANAGE_USERS_EXTRA ,SEMANAGE_STORE_NUM_PATHS };
@@ -55,7 +63,13 @@ enum semanage_sandbox_defs {*/ const char *semanage_conf_path (void );int semanage_check_init (const char *root); -const char *semanage_path (enum semanage_store_defs store,enum semanage_sandbox_defs file); + +extern const char *semanage_fname ( +enum semanage_sandbox_defs file_enum); + +extern const char *semanage_path ( +enum semanage_store_defs store, +enum semanage_sandbox_defs file);int semanage_create_store (semanage_handle_t *sh,int create);
Quoted 2 lines · Ivan Gyurdiev
Joshua's complained about my non-use of the store path array. Correct this issue.
It appears that users.local and users_extra.local are in the wrong order in the path array, or in the enumerated type - take your pick.
libsemanage/src/semanage_store.c +8 -0
@@ -96,6 +96,14 @@ static const char *semanage_sandbox_path"/homedir_template" ,"/file_contexts.template" ,"/commit_num" , +"/ports.local" , +"/interfaces.local" , +"/nodes.local" , +"/booleans.local" , +"/file_contexts.local" , +"/seusers" , +"/users_extra.local" , +"/users.local" ,"/seusers.final" , "/users_extra", };
libsemanage/src/semanage_store.h +9 -1
@@ -45,8 +45,16 @@ enum semanage_sandbox_defs {SEMANAGE_HOMEDIR_TMPL ,SEMANAGE_FC_TMPL ,SEMANAGE_COMMIT_NUM_FILE , +SEMANAGE_PORTS_LOCAL , +SEMANAGE_INTERFACES_LOCAL , +SEMANAGE_NODES_LOCAL , +SEMANAGE_BOOLEANS_LOCAL , +SEMANAGE_FC_LOCAL , +SEMANAGE_SEUSERS_LOCAL , +SEMANAGE_USERS_BASE_LOCAL , +SEMANAGE_USERS_EXTRA_LOCAL ,SEMANAGE_SEUSERS , -SEMANAGE_USER_EXTRA , +SEMANAGE_USERS_EXTRA ,SEMANAGE_STORE_NUM_PATHS };
Signature · 8 lines
Stephen Smalley National Security Agency -- 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.