libsepol/cil: Ignore object_r in userrole mappings when creating policy binary
PATCH 1/1 libsepol/cil: Ignore object_r in userrole mappings when creating policy binary
Commit 77779d2ca, which added support for userattributes in CIL, accidentally removed code that ignored object_r when adding userrole mappings to the policydb. This meant that running commands like semanage user -l would incorrectly show object_r. This patch adds that code back in. Note that CIL requires that these mappings exist to properly validate file contexts, so pp2cil's behavior of creating these mappings is not modified.
--- libsepol/cil/src/cil_binary.c | 6 ++++++ 1 file changed, 6 insertions(+)
libsepol/cil/src/cil_binary.c +6 -0
@@ -754,6 +754,12 @@ int cil_userrole_to_policydb(policydb_t *pdb, const struct cil_db *db, struct ci goto exit; } +if (sepol_role->s.value ==1 ) { +// role is object_r, ignore it since it is implicitly associated +// with all users +continue ; + } +if (ebitmap_set_bit (&sepol_user->roles.roles, sepol_role->s.value -1 ,1 )) {cil_log (CIL_INFO ,"Failed to set role bit for user\n" ); rc =SEPOL_ERR ;
Signature · 1 line
2.5.5
James Carter
AppliedQuoted 9 lines · Steve Lawrence
Commit
77779d2ca, which added support for userattributes in CIL, accidentally removed code that ignoredobject_rwhen adding userrole mappings to the policydb. This meant that running commands likesemanage user -lwould incorrectly showobject_r. This patch adds that code back in. Note that CIL requires that these mappings exist to properly validate file contexts, so pp2cil's behavior of creating these mappings is not modified.Signed-off-by Steve Lawrence <[email protected]>
Applied,
Thanks,
Quoted 22 lines
--- libsepol/cil/src/cil_binary.c | 6 ++++++ 1 file changed, 6 insertions(+)libsepol/cil/src/cil_binary.c +6
-0@@ -754,6 +754,12 @@ int cil_userrole_to_policydb(policydb_t *pdb, const struct cil_db *db, struct ci goto exit; } +if (sepol_role->s.value ==1 ) { +// role is object_r, ignore it since it is implicitly associated +// with all users +continue ; + } +if (ebitmap_set_bit (&sepol_user->roles.roles, sepol_role->s.value -1 ,1 )) {cil_log (CIL_INFO ,"Failed to set role bit for user\n" ); rc =SEPOL_ERR ;
Signature · 2 lines
James Carter <[email protected]> National Security Agency