Bug 1291601 - Updating selinux-policy{,-targeted} destroys all local fcontext configuration
Summary: Updating selinux-policy{,-targeted} destroys all local fcontext configuration
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 23
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1288696 1294301 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-12-15 09:05 UTC by Jamie Nguyen
Modified: 2016-01-04 13:48 UTC (History)
7 users (show)

Fixed In Version: selinux-policy-3.13.1-158.fc23
Clone Of:
Environment:
Last Closed: 2015-12-22 22:03:47 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jamie Nguyen 2015-12-15 09:05:59 UTC
Updating or downgrading selinux-policy destroys all local fcontext configuration.

Steps to reproduce
------------------

The same thing happens for both updating (as below) or downgrading.

# rpm -q selinux-policy selinux-policy-targeted
selinux-policy-3.13.1-152.fc23
selinux-policy-targeted-3.13.1-152.fc23

# semanage fcontext -a -t bin_t /srv/bin(/.*)?"

# semanage fcontext --list --locallist
/srv/bin(/.*)?    all files    system_u:object_r:bin_t:s0

# dnf update -y selinux\*

# rpm -q selinux-policy selinux-policy-targeted
selinux-policy-3.13.1-157.fc23
selinux-policy-targeted-3.13.1-157.fc23

# semanage fcontext --list --locallist
(no output)

Expected behaviour
------------------

Local fcontext configuration should be untouched after updating or downgrading selinux-policy and selinux-policy-targeted.

Comment 1 Jamie Nguyen 2015-12-15 09:08:19 UTC
I tested this on my desktop (Fedora 23 "Workstation") as well as a fresh VM with a minimal netinstall of Fedora 23 "Server". In both cases, local fcontext configuration is lost.

Comment 2 Petr Lautrbach 2015-12-15 09:52:11 UTC
It should be already fixed in selinux-policy-3.13.1-155.fc23, see https://bugzilla.redhat.com/show_bug.cgi?id=1279621

Comment 3 Lukas Vrabec 2015-12-15 09:59:08 UTC
It's still broken.

Comment 4 Petr Lautrbach 2015-12-15 10:05:58 UTC
(In reply to Petr Lautrbach from comment #2)
> It should be already fixed in selinux-policy-3.13.1-155.fc23, see
> https://bugzilla.redhat.com/show_bug.cgi?id=1279621

It's apparently not the same problem. 

But I'm not able to reproduce it on my own:

# rpm -q selinux-policy-targeted
selinux-policy-targeted-3.13.1-152.fc23.noarch

# semanage fcontext --list --locallist          

# semanage fcontext -a -t bin_t "/srv/bin(/.*)?"

# semanage fcontext --list --locallist          
SELinux fcontext                                   type               Context

/srv/bin(/.*)?                                     all files          system_u:object_r:bin_t:s0 

# dnf update selinux-policy
...

# rpm -q selinux-policy-targeted
selinux-policy-targeted-3.13.1-157.fc23.noarch

# semanage fcontext --list --locallist
SELinux fcontext                                   type               Context

/srv/bin(/.*)?                                     all files          system_u:object_r:bin_t:s0

Comment 5 Jamie Nguyen 2015-12-15 11:09:18 UTC
This procedure should be 100% reproducible using the Fedora Cloud image. These are the exact steps I ran:

# cd /var/lib/libvirt/images

# wget https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-23-20151030.x86_64.raw.xz

# xz -d Fedora-Cloud-Base-23-20151030.x86_64.raw.xz

# virt-customize \
      --add Fedora-Cloud-Base-23-20151030.x86_64.raw \
      --root-password password:1234 \
      --run-command "systemctl mask cloud-init.service"

# virt-install --name f23 --ram 2048 \
      --disk /var/lib/libvirt/images/Fedora-Cloud-Base-23-20151030.x86_64.raw \
      --os-variant fedora22 --import

(In virt-viewer.)
Login: root
Password: 1234

# rpm -q selinux-policy
selinux-policy-3.13.1-152.fc23

# dnf install -y policycoreutils-python-utils

# semanage fcontext -a -t bin_t "/srv/bin(/.*)?"

# semanage fcontext --list --locallist
/srv/bin(/.*)?    all files    system_u:object_r:bin_t:s0

# dnf update -y selinux\*

# rpm -q selinux-policy selinux-policy-targeted
selinux-policy-3.13.1-157.fc23

# semanage fcontext --list --locallist
(no output)

Comment 6 Petr Lautrbach 2015-12-15 14:03:22 UTC
The problem was introduced in a commit a345bb5a250d7d745d1e1c9e9bd2c0b9c711d013 where /etc/selinux/targeted/contexts/files/file_contexts.local lost '%config(noreplace)' flag. The following patch shoudl fix it:

--- a/selinux-policy.spec
+++ b/selinux-policy.spec
@@ -227,9 +227,9 @@ rm -rf %{buildroot}%{_sysconfdir}/selinux/%1/modules/active/policy.kern \
 %verify(not md5 size mtime) %{_sysconfdir}/selinux/%1/contexts/files/file_contexts \
 %verify(not md5 size mtime) %{_sysconfdir}/selinux/%1/contexts/files/file_contexts.bin \
 %verify(not md5 size mtime) %{_sysconfdir}/selinux/%1/contexts/files/file_contexts.homedirs* \
-%verify(not md5 size mtime) %{_sysconfdir}/selinux/%1/contexts/files/file_contexts.local \
+%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/files/file_contexts.local \
 %verify(not md5 size mtime) %{_sysconfdir}/selinux/%1/contexts/files/file_contexts.local.bin \
-# %ghost %{_sysconfdir}/selinux/%1/contexts/files/*.bin \
+%ghost %{_sysconfdir}/selinux/%1/contexts/files/*.bin \
 %config(noreplace) %{_sysconfdir}/selinux/%1/contexts/files/file_contexts.subs \
 %{_sysconfdir}/selinux/%1/contexts/files/file_contexts.subs_dist \
 %{_sysconfdir}/selinux/%1/booleans.subs_dist \

Comment 7 Lukas Vrabec 2015-12-15 15:20:17 UTC
*** Bug 1288696 has been marked as a duplicate of this bug. ***

Comment 8 Lukas Vrabec 2015-12-15 15:33:42 UTC
Patch applied. 
Tested on Fedora 23.


Thank you.

Comment 9 Fedora Update System 2015-12-16 11:06:38 UTC
selinux-policy-3.13.1-158.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2015-eb32da49ac

Comment 10 Fedora Update System 2015-12-17 10:29:05 UTC
selinux-policy-3.13.1-158.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update selinux-policy'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-eb32da49ac

Comment 11 Fedora Update System 2015-12-22 22:03:38 UTC
selinux-policy-3.13.1-158.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 12 Lukas Vrabec 2016-01-04 13:48:03 UTC
*** Bug 1294301 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.