Bug 1472709 - setfiles now requires "-m" to restore contexts in some chroot environments
setfiles now requires "-m" to restore contexts in some chroot environments
Product: Fedora
Classification: Fedora
Component: policycoreutils (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Petr Lautrbach
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2017-07-19 04:40 EDT by Ian Wienand
Modified: 2018-05-29 08:08 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2018-05-29 08:08:21 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Ian Wienand 2017-07-19 04:40:20 EDT
diskimage-builder builds a fedora image within a chroot environment on a host.  This is happening on an ubuntu xenial system -- this is part of building images for use by the OpenStack CI environment.  We have long had a final step before we create the final image of running "setfiles" within the chroot of the final image to restore contexts so that the image we are building boots quickly [2]

Unfortunately this stopped working with F26.  The setfiles just does nothing at all

# setfiles -d   /etc/selinux/targeted/contexts/files/file_contexts /
# echo $?

If I take the F25 setfiles binary and run it, it works.  So that got me digging into git history, where I noticed the suspect change where F26 has started using selinux_restorecon [3].

Reading this change I noticed "-m"

  ... do not read /proc/mounts to obtain a list of non-seclabel mounts ...

and realised that we're in a chroot environment on a loopback disk on an ubuntu system, so this is probably not matching.  So long story short, the "-m" fixed things for me

I get that what is happening with diskimage-builder is pretty uncommon usage, but it is pretty painful having setfiles having no error code or any output indication of what's going on at all without this flag, when it's been working for literally years.  I had to first figure out how to break into our vms (because lack of selinux meant nothing could log in), figure out it was selinux at fault, then spend considerable time figuring out that the 'setfiles' was doing nothing now during the build, and then correlating this with git history ...

Maybe the cat is out of the bag; but it would be my suggestion that "-m" should be applied by default on setfiles to maintain the behavior with the prior versions.  if anything, a flag should be inverted to turn it off.

[1] https://docs.openstack.org/diskimage-builder/latest/
[2] http://git.openstack.org/cgit/openstack/diskimage-builder/tree/diskimage_builder/elements/rpm-distro/finalise.d/90-selinux-fixfiles-restore
[3] https://github.com/SELinuxProject/selinux/commit/602347c7422e971a5674fe2767267a96e3b4f61c
Comment 1 Fedora End Of Life 2018-05-03 04:44:00 EDT
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. 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 '26'.

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 26 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.
Comment 2 Fedora End Of Life 2018-05-29 08:08:21 EDT
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
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

Thank you for reporting this bug and we are sorry it could not be fixed.

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