]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: allow uid/gid == 0 in copy_tree, copy_files, move_files
authorTim Serong <tserong@suse.com>
Mon, 5 Oct 2020 09:14:42 +0000 (20:14 +1100)
committerSebastian Wagner <sebastian.wagner@suse.com>
Wed, 18 Nov 2020 10:52:17 +0000 (11:52 +0100)
If the uid or gid passed to copy_tree(), copy_files() or
move_files() is 0 (the root user), the current check for
`if not uid or not gid` does the wrong thing, i.e. it
thinks the uid and/or gid aren't set, then calls out to
extract_uid_gid(), which fails when run against
prometheus/grafana/alertmanager containers.

Fixes: https://tracker.ceph.com/issues/47745
Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit 768e89d9ae733c88a9e85b71b5432f8d6f511f43)

src/cephadm/cephadm

index 6a65dd2ccb992252e443258ea0019bb8c3c8ae50..3af725a36b5984ec4242eaa6a91bdd58c39c3fac 100755 (executable)
@@ -1467,7 +1467,7 @@ def copy_tree(src, dst, uid=None, gid=None):
     """
     Copy a directory tree from src to dst
     """
-    if not uid or not gid:
+    if uid is None or gid is None:
         (uid, gid) = extract_uid_gid()
 
     for src_dir in src:
@@ -1492,7 +1492,7 @@ def copy_files(src, dst, uid=None, gid=None):
     """
     Copy a files from src to dst
     """
-    if not uid or not gid:
+    if uid is None or gid is None:
         (uid, gid) = extract_uid_gid()
 
     for src_file in src:
@@ -1512,7 +1512,7 @@ def move_files(src, dst, uid=None, gid=None):
     """
     Move files from src to dst
     """
-    if not uid or not gid:
+    if uid is None or gid is None:
         (uid, gid) = extract_uid_gid()
 
     for src_file in src: