|
|
da373f |
From a5e6e764c8753c254e801b32059530fbc2e86e8d Mon Sep 17 00:00:00 2001
|
|
|
da373f |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
da373f |
Date: Tue, 5 May 2020 16:44:15 +0100
|
|
|
da373f |
Subject: [PATCH] mlcustomize: Fall back to autorelabel if specfile does not
|
|
|
da373f |
exist (RHBZ#1828952).
|
|
|
da373f |
|
|
|
da373f |
https://bugzilla.redhat.com/show_bug.cgi?id=1828952#c2
|
|
|
da373f |
|
|
|
da373f |
Cherry picked from libguestfs-common
|
|
|
da373f |
commit 101dac2eac8c61f0081c343b5d69cfa4efbc2a98 and backported
|
|
|
da373f |
to libguestfs 1.40 branch (which predates the common submodule).
|
|
|
da373f |
|
|
|
da373f |
If SELINUXTYPE is set to some value other than targeted then we look
|
|
|
da373f |
for a directory /etc/selinux/<SELINUXTYPE> which does not exist.
|
|
|
da373f |
However this should not cause a fatal error. Using setfiles to do the
|
|
|
da373f |
relabelling immediately is a nice-to-have, but we can fallback to
|
|
|
da373f |
using autorelabel if we're unable to achieve it.
|
|
|
da373f |
---
|
|
|
da373f |
customize/SELinux_relabel.ml | 6 ++++++
|
|
|
da373f |
1 file changed, 6 insertions(+)
|
|
|
da373f |
|
|
|
da373f |
diff --git a/customize/SELinux_relabel.ml b/customize/SELinux_relabel.ml
|
|
|
da373f |
index 5df1f0895..5ecf7bd7e 100644
|
|
|
da373f |
--- a/customize/SELinux_relabel.ml
|
|
|
da373f |
+++ b/customize/SELinux_relabel.ml
|
|
|
da373f |
@@ -77,6 +77,12 @@ and use_setfiles g =
|
|
|
da373f |
let specfile =
|
|
|
da373f |
sprintf "/etc/selinux/%s/contexts/files/file_contexts" policy in
|
|
|
da373f |
|
|
|
da373f |
+ (* If the spec file doesn't exist then fall back to using
|
|
|
da373f |
+ * autorelabel (RHBZ#1828952).
|
|
|
da373f |
+ *)
|
|
|
da373f |
+ if not (g#is_file ~followsymlinks:true specfile) then
|
|
|
da373f |
+ failwith "no spec file";
|
|
|
da373f |
+
|
|
|
da373f |
(* RHEL 6.2 - 6.5 had a malformed specfile that contained the
|
|
|
da373f |
* invalid regular expression "/var/run/spice-vdagentd.\pid"
|
|
|
da373f |
* (instead of "\.p"). This stops setfiles from working on
|
|
|
da373f |
--
|
|
|
da373f |
2.18.4
|
|
|
da373f |
|