]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: Restore SELinux context 23278/head
authorBoris Ranto <branto@redhat.com>
Tue, 10 Jul 2018 20:52:38 +0000 (22:52 +0200)
committerBoris Ranto <branto@redhat.com>
Fri, 27 Jul 2018 18:27:22 +0000 (20:27 +0200)
We need to reset the root context of the file system after mounting it.
Otherwise, the SELinux policy rules will not be preserved.

Fixes: https://tracker.ceph.com/issues/24785
Signed-off-by: Boris Ranto <branto@redhat.com>
src/ceph-volume/ceph_volume/util/prepare.py
src/ceph-volume/ceph_volume/util/system.py

index 32d5fe20d53bd296810fd1479718096d76824ccc..c1fd5e64d34adc1caf5b8729a472271877a7058e 100644 (file)
@@ -120,6 +120,9 @@ def mount_tmpfs(path):
         path
     ])
 
+    # Restore SELinux context
+    system.set_context(path)
+
 
 def create_osd_path(osd_id, tmpfs=False):
     path = '/var/lib/ceph/osd/%s-%s' % (conf.cluster, osd_id)
@@ -219,6 +222,9 @@ def mount_osd(device, osd_id, **kw):
     command.append(destination)
     process.run(command)
 
+    # Restore SELinux context
+    system.set_context(destination)
+
 
 def _link_device(device, device_type, osd_id):
     """
index eeb7bdc04383094e1b6d881af5c471180a5f823c..b637f023a4410e807d2bc5aacc4626aefba8e3c7 100644 (file)
@@ -273,3 +273,12 @@ def get_mounts(devices=False, paths=False, realpath=False):
         return devices_mounted
     else:
         return paths_mounted
+
+
+def set_context(path, recursive = False):
+    # restore selinux context to default policy values
+    if which('restorecon').startswith('/'):
+        if recursive:
+            process.run(['restorecon', '-R', path])
+        else:
+            process.run(['restorecon', path])