From: Boris Ranto Date: Wed, 8 Mar 2017 08:38:39 +0000 (+0100) Subject: ceph-disk: Add --system option for fix command X-Git-Tag: v12.0.2~189^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8d81af42fd507c7b92c8279eb114b0a733ac1da6;p=ceph.git ceph-disk: Add --system option for fix command This adds the ability to restore the labels of the underlying system data in addition to ceph data. Signed-off-by: Boris Ranto --- diff --git a/src/ceph-disk/ceph_disk/main.py b/src/ceph-disk/ceph_disk/main.py index 95f896a1cfd..fd9ef05136a 100755 --- a/src/ceph-disk/ceph_disk/main.py +++ b/src/ceph-disk/ceph_disk/main.py @@ -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,