Description of problem: When running `rpm --rebuildb` (as suggested at the end of the Fedup upgrade documentation here: https://fedoraproject.org/wiki/FedUp#Cleaning_Up_Post_Upgrade) the rpm_var_lib_t context is lost from the files in /var/lib/rpm. Version-Release number of selected component (if applicable): rpm-4.12.0.1-3.fc21.x86_64 How reproducible: 100% of the time Steps to Reproduce: 1. Execute `rpm --rebuilddb` as root Actual results: The context of all files in /var/lib/rpm is now var_lib_t Expected results: The context of all files in /var/lib/rpm remains rpm_var_lib_t Additional info: Running restorecon results in the following output: # restorecon -rv /var/lib/rpm/ restorecon reset /var/lib/rpm/Name context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Conflictname context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Basenames context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Installtid context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Triggername context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Providename context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Dirnames context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Sha1header context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Requirename context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Sigmd5 context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Packages context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Obsoletename context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 restorecon reset /var/lib/rpm/Group context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0
Also: # ls -Z /bin/rpm -rwxr-xr-x. root root system_u:object_r:rpm_exec_t:s0 /bin/rpm # restorecon -nv /bin/rpm <no output>
Ah, this was a known (to me) but largely forgotten "regression" in rpm 4.12 , related to selinux support being splitted to a plugin and some old hacks getting pruned out in the process (commit b5e3e1efee28ce0a4bb5e9eae6740d4422f75f1c). Rpm used to have a specific matchpathcon() + setfilecon() in the rpmdb rebuild code for this, but that makes precisely zero sense from rpm POV - its just a bunch of files getting rename()'d, why should rpm need to do anything special about it? There are various options to deal with this, such as: a) Add pre- and post-rebuilddb plugin hooks to allow selinux plugin to handle it b) Tell selinux policy about the directory used for rpmdb rebuilds c) Change the rpmdb rebuild to occur inside /var/lib/rpm (in a temp dir or such) Option b) is by far the least amount of work (exactly one line of declaration in selinux-policy), whereas a) and c) require varying amounts of actual code changes. So lets try to get this done in selinux-policy: Rpm does database rebuilds in /var/lib/rpmrebuilddb.<pid>/ directory to avoid disturbing the current database in case something goes wrong, and then renamed into place. This causes the selinux label to be off, ie this bug. Handling this case in selinux-policy should be a simple matter of something like: diff --git a/rpm.fc b/rpm.fc index ebe91fc..a888b49 100644 --- a/rpm.fc +++ b/rpm.fc @@ -43,6 +43,7 @@ ifdef(`distro_redhat',` /var/lib/alternatives(/.*)? gen_context(system_u:object_r:rpm_var_lib_t,s0) /var/lib/rpm(/.*)? gen_context(system_u:object_r:rpm_var_lib_t,s0) +/var/lib/rpmrebuilddb.*(/.*)? gen_context(system_u:object_r:rpm_var_lib_t,s0) /var/lib/YaST2(/.*)? gen_context(system_u:object_r:rpm_var_lib_t,s0) /var/lib/yum(/.*)? gen_context(system_u:object_r:rpm_var_lib_t,s0)
Since this is probably not going to be fixed for F21, perhaps someone could update the advice given at https://fedoraproject.org/wiki/FedUp#Cleaning_Up_Post_Upgrade to include the label correction of /var/lib/rpm after running rpm --rebuilddb?
(In reply to Raman Gupta from comment #3) > Since this is probably not going to be fixed for F21, perhaps someone could > update the advice given at > https://fedoraproject.org/wiki/FedUp#Cleaning_Up_Post_Upgrade to include the > label correction of /var/lib/rpm after running rpm --rebuilddb? I added the proposed text on the Talk page, but don't feel comfortable doing the edit on the main page directly until someone with more experience maintaining the Fedora Wiki chimes in.
commit 77e383b11934ea0b1e0ff60908ea36b878b1e53f Author: Lukas Vrabec <lvrabec> Date: Fri Nov 28 16:11:27 2014 +0100 Label /var/lib/rpmrebuilddb/ as rpm_var_lib_t. BZ (1167946)
Note the commit message is a bit off now: the directory isn't /var/lib/rpmrebuilddb/ but /var/lib/rpmrebuilddb.<pid>/. It seems to be correct in the patch though.
selinux-policy-3.13.1-103.fc21 has been submitted as an update for Fedora 21. https://admin.fedoraproject.org/updates/selinux-policy-3.13.1-103.fc21
Package selinux-policy-3.13.1-103.fc21: * should fix your issue, * was pushed to the Fedora 21 testing repository, * should be available at your local mirror within two days. Update it with: # su -c 'yum update --enablerepo=updates-testing selinux-policy-3.13.1-103.fc21' as soon as you are able to. Please go to the following url: https://admin.fedoraproject.org/updates/FEDORA-2014-17044/selinux-policy-3.13.1-103.fc21 then log in and leave karma (feedback).
With the updated policy, rpm --rebuilddb does not label /var/lib/rpm with rpm_var_lib_t: # ls -Z /var/lib/rpm -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Basenames -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Conflictname -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Dirnames -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Group -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Installtid -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Name -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Obsoletename -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Packages -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Providename -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Requirename -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Sha1header -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Sigmd5 -rw-r--r--. root root unconfined_u:object_r:var_lib_t:s0 Triggername
However, in the updated policy, var_lib_t appears to be correct? # /sbin/restorecon -nv /var/lib/rpm <no output>
That seems broken, this is what the policy says: /var/lib/rpm(/.*)? gen_context(system_u:object_r:rpm_var_lib_t,s0) /var/lib/rpmrebuilddb.*(/.*)? gen_context(system_u:object_r:rpm_var_lib_t,s0) If its not working as expected, do give negative karma for the update to prevent a bad update going out as stable.
(In reply to Raman Gupta from comment #10) > However, in the updated policy, var_lib_t appears to be correct? > > # /sbin/restorecon -nv /var/lib/rpm > <no output> Correction (I was missing the -r in restorecon): the policy appears to be correct, but "--rebuilddb" still loses the context. # /sbin/restorecon -rnv /var/lib/rpm/ /sbin/restorecon reset /var/lib/rpm/Name context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Conflictname context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Basenames context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Installtid context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Triggername context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Providename context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Dirnames context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Sha1header context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Requirename context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Sigmd5 context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Packages context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Obsoletename context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 /sbin/restorecon reset /var/lib/rpm/Group context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:rpm_var_lib_t:s0 I have submitted negative karma.
The problem here is we are no longer transitioning from unconfined_t to rpm_t so these files are being created with the incorrect label. Same problem happens with /var/cache/dnf b955f9ec993f38d61dc42048d61ad425f7ea230a sets up a file name transition to make sure this directory gets labeled correctly.
selinux-policy-3.13.1-103.fc21 has been pushed to the Fedora 21 stable repository. If problems still persist, please make note of it in this bug report.
Not fixed by pushed update. Reopening.
Yes the fix did not make this package, but it is in git.
The fix is either still not included in selinux-policy-3.13.1-105.fc21.noarch, or the fix was incorrect.
This message is a reminder that Fedora 21 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 21. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '21'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 21 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
Fedora 21 changed to end-of-life (EOL) status on 2015-12-01. Fedora 21 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.