]> 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, 6 Jun 2017 09:24:00 +0000 (11:24 +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>
(cherry picked from commit 077038b4393a28ccbd38ca4a90105dbd4c1ffcd5)

src/ceph-disk/ceph_disk/main.py
src/ceph-disk/tests/test_main.py

index c783c46730fe72aa802004de076441dabf56866d..6e09a449ea4b0c0aeea642f04e78967e528a795c 100755 (executable)
@@ -4686,11 +4686,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),
@@ -4748,6 +4748,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,
@@ -4787,6 +4791,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',
@@ -4822,6 +4830,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 3f0e714e90bee6f7f0f158072d719e45469bbb4d..f6993362bcefb0b29fd6a4de87fcb6db695db9dd 100644 (file)
@@ -1300,11 +1300,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)