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>
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)
command.append(destination)
process.run(command)
+ # Restore SELinux context
+ system.set_context(destination)
+
def _link_device(device, device_type, osd_id):
"""
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])