]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: Add --system option for fix command 13310/head
authorBoris Ranto <branto@redhat.com>
Wed, 8 Mar 2017 08:38:39 +0000 (09:38 +0100)
committerBoris Ranto <branto@redhat.com>
Mon, 20 Mar 2017 08:57:18 +0000 (09:57 +0100)
This adds the ability to restore the labels of the underlying system
data in addition to ceph data.

Signed-off-by: Boris Ranto <branto@redhat.com>
src/ceph-disk/ceph_disk/main.py

index 95f896a1cfdb7c7d83db6779189312468af221d3..fd9ef05136a6e550fcc2ac46b483cbf937801993 100755 (executable)
@@ -4765,6 +4765,23 @@ def main_fix(args):
             LOG.error(daemon + ' is running, please stop it, first')
             raise Error(daemon + ' running')
 
+    # Relabel the basic system data without the ceph files
+    if args.system or args.all:
+        c = ['restorecon', '-R', '/']
+        for directory, _, _, _, _ in fix_table:
+            # Skip /var/lib/ceph subdirectories
+            if directory.startswith('/var/lib/ceph/'):
+                continue
+            c.append('-e')
+            c.append(directory)
+
+        out, err, ret = command(c)
+
+        if ret:
+            LOG.error("Failed to restore labels of the underlying system")
+            LOG.error(err)
+            raise Error("basic restore failed")
+
     # Use find to relabel + chown ~simultaenously
     if args.all:
         for directory, uid, gid, blocking, recursive in fix_table:
@@ -4872,6 +4889,11 @@ def main_fix(args):
             LOG.error(err)
             raise Error("background failed")
 
+    LOG.info(
+        "The ceph files has been fixed, please reboot "
+        "the system for the changes to take effect."
+    )
+
 
 def setup_statedir(dir):
     # XXX The following use of globals makes linting
@@ -4984,6 +5006,12 @@ def make_fix_parser(subparsers):
         """)),
         help='fix SELinux labels and/or file permissions')
 
+    fix_parser.add_argument(
+        '--system',
+        action='store_true',
+        default=False,
+        help='fix SELinux labels for the non-ceph system data'
+    )
     fix_parser.add_argument(
         '--selinux',
         action='store_true',
@@ -5000,7 +5028,7 @@ def make_fix_parser(subparsers):
         '--all',
         action='store_true',
         default=False,
-        help='fix file permissions as well as SELinux labels for ceph data'
+        help='perform all the fix-related operations'
     )
     fix_parser.set_defaults(
         func=main_fix,