]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: Retain suid/guid bits in subvolume clone 40270/head
authorKotresh HR <khiremat@redhat.com>
Thu, 18 Mar 2021 12:54:44 +0000 (18:24 +0530)
committerNathan Cutler <ncutler@suse.com>
Tue, 13 Apr 2021 13:46:20 +0000 (15:46 +0200)
Fixes: https://tracker.ceph.com/issues/49882
Signed-off-by: Kotresh HR <khiremat@redhat.com>
(cherry picked from commit 92dc982318fa7d49c3185615b84a7a7764c6ed42)

Conflicts:
  qa/tasks/cephfs/test_volumes.py: Few of the testcases are not preset
      in octopus, hence the conflicts.

qa/tasks/cephfs/test_volumes.py
src/pybind/mgr/volumes/fs/async_cloner.py

index 67f138f879298ebc02475b851d5631c1094f09e0..778ad83d3b55d89c7e6be50c25c5b842beef88e3 100644 (file)
@@ -3649,6 +3649,48 @@ class TestVolumes(CephFSTestCase):
         # verify trash dir is clean
         self._wait_for_trash_empty()
 
+    def test_subvolume_snapshot_clone_retain_suid_guid(self):
+        subvolume = self._generate_random_subvolume_name()
+        snapshot = self._generate_random_snapshot_name()
+        clone = self._generate_random_clone_name()
+
+        # create subvolume
+        self._fs_cmd("subvolume", "create", self.volname, subvolume)
+
+        # Create a file with suid, guid bits set along with executable bit.
+        args = ["subvolume", "getpath", self.volname, subvolume]
+        args = tuple(args)
+        subvolpath = self._fs_cmd(*args)
+        self.assertNotEqual(subvolpath, None)
+        subvolpath = subvolpath[1:].rstrip() # remove "/" prefix and any trailing newline
+
+        file_path = subvolpath
+        file_path = os.path.join(subvolpath, "test_suid_file")
+        self.mount_a.run_shell(["touch", file_path])
+        self.mount_a.run_shell(["chmod", "u+sx,g+sx", file_path])
+
+        # snapshot subvolume
+        self._fs_cmd("subvolume", "snapshot", "create", self.volname, subvolume, snapshot)
+
+        # schedule a clone
+        self._fs_cmd("subvolume", "snapshot", "clone", self.volname, subvolume, snapshot, clone)
+
+        # check clone status
+        self._wait_for_clone_to_complete(clone)
+
+        # verify clone
+        self._verify_clone(subvolume, snapshot, clone)
+
+        # remove snapshot
+        self._fs_cmd("subvolume", "snapshot", "rm", self.volname, subvolume, snapshot)
+
+        # remove subvolumes
+        self._fs_cmd("subvolume", "rm", self.volname, subvolume)
+        self._fs_cmd("subvolume", "rm", self.volname, clone)
+
+        # verify trash dir is clean
+        self._wait_for_trash_empty()
+
     def test_subvolume_snapshot_reconf_max_concurrent_clones(self):
         """
         Validate 'max_concurrent_clones' config option
index 0c5155e75aba9a0bf6bf66f2107d6d378c643c07..c42808582eec2fa10d8619d5387a11147b3491ec 100644 (file)
@@ -117,6 +117,7 @@ def sync_attrs(fs_handle, target_path, source_statx):
         fs_handle.lchown(target_path, int(source_statx["uid"]), int(source_statx["gid"]))
         fs_handle.lutimes(target_path, (time.mktime(source_statx["atime"].timetuple()),
                                         time.mktime(source_statx["mtime"].timetuple())))
+        fs_handle.lchmod(target_path, source_statx["mode"])
     except cephfs.Error as e:
         log.warn("error synchronizing attrs for {0} ({1})".format(target_path, e))
         raise e