Validation of local file contexts
This patch adds context validation of local changes to file contexts.
Should I also check if the regexp is valid? Should I check if the Unix user exists for seusers?
=======
This also adds another warning for semanage <---> sepol incompatible data structures, but this is a known issue.
I could hide the warnings, but I'd rather not - we may still want to address the problem. I tried to write conversion wrappers once before, and got rather far - maybe I'll finish this work, if you think it's desirable not to rely on compatible records.
=========
Another thing that I'd like to note - those kinds of validation runs prevent installing seusers or file_contexts that are bad, but also work in the opposite direction, and prevent policy upgrades that will break local customizations - not sure if this is the desired approach.
libsemanage/src/direct_api.c +12 -2
@@ -351,12 +351,13 @@ static int semanage_direct_commit(semanadbase_config_t * ifaces =semanage_iface_dbase_local (sh);dbase_config_t * fcontexts =semanage_fcontext_dbase_local (sh);dbase_config_t * seusers =semanage_seuser_dbase (sh); +int fcontexts_modified = fcontexts->dtable->is_modified (fcontexts->dbase); +int seusers_modified = seusers->dtable->is_modified (seusers->dbase); modified |= users->dtable->is_modified (users->dbase); modified |= ports->dtable->is_modified (ports->dbase); modified |= bools->dtable->is_modified (bools->dbase); - modified |= fcontexts->dtable->is_modified (fcontexts->dbase); + modified |= fcontexts_modified; modified |= ifaces->dtable->is_modified (ifaces->dbase); -int seusers_modified = seusers->dtable->is_modified (seusers->dbase);/* FIXME: get rid of this, once we support loading the existing policy, * instead of rebuilding it for seusers */
@@ -408,6 +409,15 @@ static int semanage_direct_commit(semana/* FIXME: else if !modified, but seusers_modified, * load the existing policy instead of rebuilding */ +/* Validate local modifications to file contexts. +* Note: those are still cached, even though they've been +* merged into the main file_contexts. We won't check the +* large file_contexts - checked at compile time */ +if (sh->do_rebuild || modified || fcontexts_modified) { +if (semanage_fcontext_validate_local (sh, out) <0 ) + goto cleanup; + } +/* Validate seusers against policy * if either policy changed, or seusers changed, * or we forced a rebuild */
libsemanage/src/fcontext_internal.h +5 -0
@@ -4,6 +4,7 @@#include <semanage/fcontext_record.h> #include <semanage/fcontexts_local.h> #include <semanage/fcontexts_policy.h> +#include <sepol/policydb.h> #include "database.h" #include "handle.h" #include "dso.h"
@@ -21,4 +22,8 @@ extern int fcontext_file_dbase_init(extern void fcontext_file_dbase_release (dbase_config_t * dconfig); +extern int hidden semanage_fcontext_validate_local( +semanage_handle_t * handle, +const sepol_policydb_t * policydb); +#endif
libsemanage/src/fcontexts_local.c +55 -0
66 lines not on this page · raw message
libsemanage/src/seusers.c +0 -1
@@ -97,7 +97,6 @@ int semanage_seuser_list(return dbase_list (handle, dconfig, records, count); } -struct validate_handler_arg {semanage_handle_t * handle;const sepol_policydb_t * policydb;
Quoted 3 lines · Ivan Gyurdiev
This patch adds context validation of local changes to file contexts.
Should I also check if the regexp is valid?
I'm not sure, as libsemanage presently doesn't do any other interpretation of the regex. Might want to defer this to the clients.
Quoted 1 line
Should I check if the Unix user exists for seusers?
As with the above, I'm inclined to defer this to the clients, as Unix users aren't something managed by libsemanage itself.
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.
Quoted 11 lines · Stephen Smalley
Quoted 4 lines · Ivan Gyurdiev
This patch adds context validation of local changes to file contexts.
Should I also check if the regexp is valid?
I'm not sure, as libsemanage presently doesn't do any other interpretation of the regex. Might want to defer this to the clients.
Quoted 7 lines
Quoted 2 lines
Should I check if the Unix user exists for seusers?
As with the above, I'm inclined to defer this to the clients, as Unix users aren't something managed by libsemanage itself.
Yes leave these to the clients.
--
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.