]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: Fix the file ownership, skip missing
authorBoris Ranto <branto@redhat.com>
Thu, 25 May 2017 12:36:13 +0000 (14:36 +0200)
committerBoris Ranto <branto@redhat.com>
Tue, 30 May 2017 23:35:12 +0000 (01:35 +0200)
This commit fixes the file ownership for the /usr/bin/ and /etc/ceph
files and skips missing files as some of the files that we do specify
now can be missing from the system (not installed, e.f. radosgw).

Fixes: http://tracker.ceph.com/issues/20077
Signed-off-by: Boris Ranto <branto@redhat.com>
src/ceph-disk/ceph_disk/main.py
src/ceph-disk/tests/test_main.py

index 8564e09566b2653647e493cdf78e2cfb63706709..0487ee2e6d0e8798520d02b4b2c43e605122691a 100755 (executable)
@@ -4830,11 +4830,11 @@ def main_trigger(args):
 def main_fix(args):
     # A hash table containing 'path': ('uid', 'gid', blocking, recursive)
     fix_table = [
-        ('/usr/bin/ceph-mon', 'ceph', 'ceph', True, False),
-        ('/usr/bin/ceph-mds', 'ceph', 'ceph', True, False),
-        ('/usr/bin/ceph-osd', 'ceph', 'ceph', True, False),
-        ('/usr/bin/radosgw', 'ceph', 'ceph', True, False),
-        ('/etc/ceph', 'ceph', 'ceph', True, True),
+        ('/usr/bin/ceph-mon', 'root', 'root', True, False),
+        ('/usr/bin/ceph-mds', 'root', 'root', True, False),
+        ('/usr/bin/ceph-osd', 'root', 'root', True, False),
+        ('/usr/bin/radosgw', 'root', 'root', True, False),
+        ('/etc/ceph', 'root', 'root', True, True),
         ('/var/run/ceph', 'ceph', 'ceph', True, True),
         ('/var/log/ceph', 'ceph', 'ceph', True, True),
         ('/var/log/radosgw', 'ceph', 'ceph', True, True),
@@ -4892,6 +4892,10 @@ def main_fix(args):
     # Use find to relabel + chown ~simultaenously
     if args.all:
         for directory, uid, gid, blocking, recursive in fix_table:
+            # Skip directories/files that are not installed
+            if not os.access(directory, os.F_OK):
+                continue
+
             c = [
                 'find',
                 directory,
@@ -4931,6 +4935,10 @@ def main_fix(args):
     # Fix permissions
     if args.permissions:
         for directory, uid, gid, blocking, recursive in fix_table:
+            # Skip directories/files that are not installed
+            if not os.access(directory, os.F_OK):
+                continue
+
             if recursive:
                 c = [
                     'chown',
@@ -4966,6 +4974,10 @@ def main_fix(args):
     # Fix SELinux labels
     if args.selinux:
         for directory, uid, gid, blocking, recursive in fix_table:
+            # Skip directories/files that are not installed
+            if not os.access(directory, os.F_OK):
+                continue
+
             if recursive:
                 c = [
                     'restorecon',
index 45fe48a16905f23176d7f92478ac8f619b0f6730..8c3e08451fd9f9d774f1cb63de988ea213848581 100644 (file)
@@ -1328,11 +1328,19 @@ class TestCephDiskDeactivateAndDestroy(unittest.TestCase):
             commands.append(" ".join(x))
             return ("", "", None)
 
+        class Os(object):
+            F_OK = 0
+
+            @staticmethod
+            def access(x, y):
+                return True
+
         with patch.multiple(
             main,
             command=_command,
             command_init=lambda x: commands.append(x),
             command_wait=lambda x: None,
+            os=Os,
         ):
             main.main_fix(args)
             commands = " ".join(commands)