Semanage/libsemanage seems to be broken.
Quoted 22 lines · Ivan Gyurdiev
Quoted 3 lines
# semanage user -a -rSystemLow-SystemHigh -R user_r -R sysadm_r walsh_u # semaage user -d walsh_uI assume this was misspelled in the email only.
Quoted 13 lines
# semanage user -l MLS/ MLS/ SELinux User MCS Level MCS Range SELinux Roleslwalsh None None root s0 SystemLow-SystemHigh system_r sysadm_r user_r rwalsh s0 s0 system_r sysadm_r user_r system_u s0 SystemLow-SystemHigh system_r twalsh s0 s0 user_r user_u s0 SystemLow-SystemHigh system_r sysadm_r user_r walsh_u None NoneQuoted 5 lines
#semanage user -d
walsh_u/usr/sbin/semanage: SELinux userwalsh_uis defined in policy, cannot be deleted#semanage user -a -rSystemLow-SystemHigh -R
user_r-Rsysadm_rwalsh_u/usr/sbin/semanage: SELinux userwalsh_uis already defined
Quoted 8 lines
Hmm.... are you shipping the prefix file for genhomedircon yet?
This appears to be caused by the
users_extrafile not getting cleared on policy rebuild.
I used to always clear this file. However, after Joshua's patch to support the users extra file in the package format, this was changed to not clear the file. The idea was that oncommit(), that file would get overwritten by theusers_extrasettings from the policy package.However, I expected this to be a required file. Is this not the case?
If theusers_extrais not a required section of the module package, then perhaps we should explicitly clear that file on rebuild. The same argument applies to the seusers file, and the file contexts file. Are those sections optional?
The attached patch should fix the problem - it treats seusers and users_extra as optional sections. If they are not present, the corresponding dbase is cleared. File contexts appear to be requred (no len == 0 check).
libsemanage/src/direct_api.c +16 -9
@@ -475,7 +475,7 @@ static int semanage_direct_commit(semana/* ==================== File-backed ================== */ -/* write the linked file contexts template */ +/* File Contexts */ if ((ofilename =semanage_path (SEMANAGE_TMP ,SEMANAGE_FC_TMPL )) ==NULL ||write_file (sh, ofilename,sepol_module_package_get_file_contexts (base),sepol_module_package_get_file_contexts_len (base)) ==-1 ) {
@@ -484,29 +484,36 @@ static int semanage_direct_commit(semanaif (semanage_split_fc (sh)) goto cleanup; - + + pfcontexts->dtable->drop_cache (pfcontexts->dbase); + +/* Seusers */ if (sepol_module_package_get_seusers_len (base)) {if ((ofilename =semanage_path (SEMANAGE_TMP ,SEMANAGE_SEUSERS )) ==NULL ||write_file (sh, ofilename,sepol_module_package_get_seusers (base),sepol_module_package_get_seusers_len (base)) ==-1 ) { goto cleanup; } + pseusers->dtable->drop_cache (pseusers->dbase); + + }else { +if (pseusers->dtable->clear (sh, pseusers->dbase) <0 ) + goto cleanup; } +/* Users_extra */ if (sepol_module_package_get_user_extra_len (base)) {if ((ofilename =semanage_path (SEMANAGE_TMP ,SEMANAGE_USER_EXTRA )) ==NULL ||write_file (sh, ofilename,sepol_module_package_get_user_extra (base),sepol_module_package_get_user_extra_len (base)) ==-1 ) { goto cleanup; } - } + pusers_extra->dtable->drop_cache (pusers_extra->dbase); -/* Drop any cached content for file_contexts, seusers, or users_extra, -* since it is now superceded by the files just written, and needs to be -* re-cached */ - pfcontexts->dtable->drop_cache (pfcontexts->dbase); - pseusers->dtable->drop_cache (pseusers->dbase); - pusers_extra->dtable->drop_cache (pusers_extra->dbase); + }else { +if (pusers_extra->dtable->clear (sh, pusers_extra->dbase) <0 ) + goto cleanup; + }/* ==================== Policydb-backed ================ */
Quoted 4 lines · Ivan Gyurdiev
The attached patch should fix the problem - it treats seusers and
users_extraas optional sections. If they are not present, the corresponding dbase is cleared. File contexts appear to be requred (no len == 0 check).
Merged as of libsemanage 1.5.22.
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.