User extra data (part 1)
Hi, this patch begins to solve the ROLE expansion problem in genhomedircon.
It adds a user_extra record, which will store "extra data", which is data that doesn't go into policy, keyed on the selinux user (the key is shared).
Currently this record contains only a (name, prefix) pair. It is backed by a flat file instantiated 3 times - users_extra.system (distro-shipped), users_extra.local (local modifications), and users_extra (stacked). The first two get merged into the third.
The format is similar to the SELinux user format, since I thought this format is more change-friendly, unlike the seusers format. Format is: user %s prefix %s ; (multiline and random space layout is fine, as usual).
========
No validation is currently done on the user field (todo).
No APIs are exposed, everything is static or hidden - this is deliberate, because I haven't decided what APIs need to be exposed. In particular, I haven't given up on the idea of implementing a join. This record should not exist from the outside user's point of view - the user does not/should not care that the data goes into two different data backends - it's keyed on the same thing, and should be accessible together. I will continue working on a join a bit more, and if it doesn't work out, we can just expose this record.
Another issue is how users_extra.system will be updated. Joshua, do you have any suggestions?
libsemanage/src/direct_api.c +16 -0
@@ -113,6 +113,10 @@ int semanage_direct_connect(semanage_hanif (user_file_dbase_init (sh,semanage_user_dbase_local (sh)) <0 ) goto err; +if (user_extra_file_dbase_init (sh,"users_extra.local" , +semanage_user_extra_dbase_local (sh)) <0 ) + goto err; +if (port_file_dbase_init (sh,semanage_port_dbase_local (sh)) <0 ) goto err;
@@ -129,9 +133,17 @@ int semanage_direct_connect(semanage_hanif (seuser_file_dbase_init (sh,semanage_seuser_dbase (sh)) <0 ) goto err; +if (user_extra_file_dbase_init (sh,"users_extra.system" , +semanage_user_extra_dbase_system (sh)) <0 ) + goto err; +if (user_policydb_dbase_init (sh,semanage_user_dbase_policy (sh)) <0 ) goto err; +if (user_extra_file_dbase_init (sh,"users_extra" , +semanage_user_extra_dbase_policy (sh)) <0 ) + goto err; +if (port_policydb_dbase_init (sh,semanage_port_dbase_policy (sh)) <0 ) goto err;
@@ -174,13 +186,17 @@ static int semanage_direct_disconnect(se/* Remove object databases */ user_file_dbase_release (semanage_user_dbase_local (sh)); +user_extra_file_dbase_release (semanage_user_extra_dbase_local (sh));port_file_dbase_release (semanage_port_dbase_local (sh));iface_file_dbase_release (semanage_iface_dbase_local (sh));bool_file_dbase_release (semanage_bool_dbase_local (sh));fcontext_file_dbase_release (semanage_fcontext_dbase_local (sh));seuser_file_dbase_release (semanage_seuser_dbase (sh)); +user_extra_file_dbase_release (semanage_user_extra_dbase_system (sh)); +user_policydb_dbase_release (semanage_user_dbase_policy (sh)); +user_extra_file_dbase_release (semanage_user_extra_dbase_policy (sh));port_policydb_dbase_release (semanage_port_dbase_policy (sh));iface_policydb_dbase_release (semanage_iface_dbase_policy (sh));bool_policydb_dbase_release (semanage_bool_dbase_policy (sh));
libsemanage/src/handle.h +36 -13
75 lines not on this page · raw message
libsemanage/src/policy_components.c +12 -1
@@ -122,11 +122,21 @@ int semanage_base_merge_components( semanage_handle_t* handle) {int i; + +/* Order is important here - change things carefully. +* System components first, local next. Verify runs with +* mutual dependencies are ran after everything is merged */ load_table_t components[] = { {semanage_user_dbase_local (handle),semanage_user_dbase_policy (handle),MODE_MODIFY }, + {semanage_user_extra_dbase_system (handle), +semanage_user_extra_dbase_policy (handle),MODE_MODIFY }, + + {semanage_user_extra_dbase_local (handle), +semanage_user_extra_dbase_policy (handle),MODE_MODIFY }, + {semanage_port_dbase_local (handle),semanage_port_dbase_policy (handle),MODE_MODIFY },
@@ -181,10 +191,11 @@ int semanage_commit_components(int i;dbase_config_t * components[] = { -/* semanage_modules_dbase(handle), */ semanage_iface_dbase_local (handle),semanage_bool_dbase_local (handle),semanage_user_dbase_local (handle), +semanage_user_extra_dbase_local (handle), +semanage_user_extra_dbase_policy (handle),semanage_port_dbase_local (handle),semanage_fcontext_dbase_local (handle),semanage_fcontext_dbase_policy (handle),
libsemanage/src/seusers_file.c +0 -2
@@ -12,13 +12,11 @@ typedef struct dbase_file dbase_t;#include <stdlib.h> #include <stdio.h> -#include <strings.h> #include "seuser_internal.h" #include "database_file.h" #include "parse_utils.h" #include "debug.h" -#include "semanage_store.h" #include "handle.h" static int seuser_print(
libsemanage/src/user_extra_record.c +176 -0
176 lines not on this page · raw message
libsemanage/src/user_internal.h +40 -1
59 lines not on this page · raw message
libsemanage/src/user_record.c +7 -0
@@ -49,6 +49,13 @@ void semanage_user_key_free( }hidden_def (semanage_user_key_free) +hidden void semanage_user_key_unpack( +const semanage_user_key_t * key, +const char ** name) { + +sepol_user_key_unpack (key, name); +} +int semanage_user_compare (const semanage_user_t * user,const semanage_user_key_t * key) {
libsemanage/src/users_extra_file.c +130 -0
130 lines not on this page · raw message
Bugfix for modified flags attached. I need to write support for re-using the linked policy from the last run - none of the file backed components needs to relink every time. Otherwise those modified flags aren't very useful - they only do something for the case of active booleans (prevent overwrite by policy booleans).
libsemanage/src/direct_api.c +6 -3
@@ -368,6 +368,7 @@ static int semanage_direct_commit(semana/* Check if anything was changed */ int modified = sh->modules_modified;dbase_config_t * users =semanage_user_dbase_local (sh); +dbase_config_t * users_extra =semanage_user_extra_dbase_local (sh);dbase_config_t * ports =semanage_port_dbase_local (sh);dbase_config_t * bools =semanage_bool_dbase_local (sh);dbase_config_t * ifaces =semanage_iface_dbase_local (sh);
@@ -375,15 +376,17 @@ static int semanage_direct_commit(semanadbase_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); +int users_extra_modified = users_extra->dtable->is_modified (users_extra->dbase); modified |= users->dtable->is_modified (users->dbase); modified |= ports->dtable->is_modified (ports->dbase); modified |= bools->dtable->is_modified (bools->dbase); - modified |= fcontexts_modified; modified |= ifaces->dtable->is_modified (ifaces->dbase); -/* FIXME: get rid of this, once we support loading the existing policy, -* instead of rebuilding it for seusers */ +/* FIXME: get rid of these, once we support loading the existing policy, +* instead of rebuilding it */ modified |= seusers_modified; + modified |= fcontexts_modified; + modified |= users_extra_modified;/* If there were policy changes, or explicitly requested, rebuild the policy */ if (sh->do_rebuild || modified) {
Quoted 5 lines · Ivan Gyurdiev
Bugfix for modified flags attached. I need to write support for re-using the linked policy from the last run - none of the file backed components needs to relink every time. Otherwise those modified flags aren't very useful - they only do something for the case of active booleans (prevent overwrite by policy booleans).
Merged the patch and bugfix as of libsemanage 1.5.12.
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.
Ivan Gyurdiev wrote:
<snip>
Quoted 3 lines
Another issue is how users_extra.system will be updated. Joshua, do you have any suggestions?
I really don't want to export a whole slew of extra interfaces for dealing with system level stuff so some of the options are
1) letting rpm/whatever be trusted to smash things in the store (non-ideal)
2) Write an 'import' interface that tells semanage to grab all the system files from somewhere and smash the ones in the store (sort of hackish)
3) add user_extra.system to the policy package and smash it on base policy upgrade (this is my favorite)
<snip>
--
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 9 lines
I really don't want to export a whole slew of extra interfaces for dealing with system level stuff so some of the options are
1) letting rpm/whatever be trusted to smash things in the store (non-ideal)
2) Write an 'import' interface that tells semanage to grab all the system files from somewhere and smash the ones in the store (sort of hackish)
3) add user_extra.system to the policy package and smash it on base policy upgrade (this is my favorite)
I have no preference... Dan?
--
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 · Ivan Gyurdiev
Quoted 9 lines
I really don't want to export a whole slew of extra interfaces for dealing with system level stuff so some of the options are
1) letting rpm/whatever be trusted to smash things in the store (non-ideal)
2) Write an 'import' interface that tells semanage to grab all the system files from somewhere and smash the ones in the store (sort of hackish)
3) add user_extra.system to the policy package and smash it on base policy upgrade (this is my favorite)
I have no preference... Dan?
I really don't understand what you are trying to do here.
We are trying to build a mapping between SELinux User and default login type? Correct? But there is a relationship between the default login role and the type. SO I guess I have no preference. The current policycoreutils is hacked to select user for user_u and staff for root or staff_u in non targeted policy.
--
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
Quoted 4 lines
Quoted 4 lines
I really don't want to export a whole slew of extra interfaces for dealing with system level stuff so some of the options are
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
1) letting rpm/whatever be trusted to smash things in the store (non-ideal)
2) Write an 'import' interface that tells semanage to grab all the system files from somewhere and smash the ones in the store (sort of hackish)
3) add user_extra.system to the policy package and smash it on base policy upgrade (this is my favorite)
I have no preference... Dan?
I really don't understand what you are trying to do here.
We're trying to come up with a way to ship a default configuration for labeling prefixes. This used to be stored in system.users (as the first role took the meaning of a prefix). Basically, there's a file now that looks like this:
user <name> prefix <name> ;
We have to get it into the sandbox somehow, and Joshua is suggesting an addition to the policy package as the way to do that.
Quoted 1 line
We are trying to build a mapping between SELinux User and default login type? Correct? But there is a relationship between the default login role and the type. SO I guess I have no preference.
Well, Steven's been claiming otherwise for a while now, and I thought that was at the core of the whole problem - the need to relate arbitrary labeling prefixes to selinux users. I do see how a relationship between the session login role and the labeling prefix would be useful if we had polyinstantiation (then we could label files differently for different logins). However, we currently don't have that - so we can't match a different label prefix for each of the possible login roles in default-contexts, we have to settle for a single prefix, that's associated with the user.
Quoted 1 line
The current policycoreutils is hacked to select user for
user_uand staff for root orstaff_uin non targeted policy.
Yes, and this is the problem I'm trying to address. Libsemanage now has the capability to provide you with a prefix. See:semanage_user_get_prefix()semanage_user_set_prefix().
However, all those prefixes default to user - we need the file I mentioned above to initialize them.
--
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.