]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: Add --system option for fix command 14345/head
authorBoris Ranto <branto@redhat.com>
Wed, 8 Mar 2017 08:38:39 +0000 (09:38 +0100)
committerBoris Ranto <branto@redhat.com>
Wed, 10 May 2017 16:03:02 +0000 (18:03 +0200)
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>
(cherry picked from commit 8d81af42fd507c7b92c8279eb114b0a733ac1da6)

src/ceph-disk/ceph_disk/main.py

index d2f52a3552cb4cc0b9d8c45daf2ae4dba7de7f8e..4e8c7569cf64053ea1882bfd8e31c0fcf3479f25 100755 (executable)
@@ -4723,6 +4723,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:
@@ -4830,6 +4847,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
@@ -4942,6 +4964,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',
@@ -4958,7 +4986,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,