]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: filter internal directories in 'subvolumegroup ls' command
authorNikhilkumar Shelke <nshelke@redhat.com>
Wed, 22 Jun 2022 09:55:23 +0000 (15:25 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 6 Sep 2022 07:23:57 +0000 (12:53 +0530)
Internal directories: '_nogroup', '_index', '_legacy', '_deleting'
1. Internal directories should be filtered in 'subvolmegroup ls' command.
2. Internal directories should not be accepted as a group name.

Fixes: https://tracker.ceph.com/issues/55762
Signed-off-by: Nikhilkumar Shelke <nshelke@redhat.com>
(cherry picked from commit ce3fa7f1bcd9ca8a9e9e80ca33a15d0746ce7110)

src/pybind/mgr/volumes/fs/operations/group.py
src/pybind/mgr/volumes/fs/volume.py

index eba083c1d345280a978fd52c385929d4975385e1..c91969278022b1ddf195f97b1e3e4bd85576e601 100644 (file)
@@ -21,6 +21,8 @@ class Group(GroupTemplate):
     def __init__(self, fs, vol_spec, groupname):
         if groupname == Group.NO_GROUP_NAME:
             raise VolumeException(-errno.EPERM, "Operation not permitted for group '{0}' as it is an internal group.".format(groupname))
+        if groupname in vol_spec.INTERNAL_DIRS:
+            raise VolumeException(-errno.EINVAL, "'{0}' is an internal directory and not a valid group name.".format(groupname))
         self.fs = fs
         self.user_id = None
         self.group_id = None
index 74cda0aaa4f9deb126150632d41f4ca3580d6cfa..2e83712453bb7a1dab7f4cdfdc1d853f11eadf3e 100644 (file)
@@ -849,7 +849,7 @@ class VolumeClient(CephfsClient["Module"]):
         try:
             with open_volume(self, volname) as fs_handle:
                 volume_exists = True
-                groups = listdir(fs_handle, self.volspec.base_dir, filter_entries=[Trash.GROUP_NAME.encode('utf-8')])
+                groups = listdir(fs_handle, self.volspec.base_dir, filter_entries=[dir.encode('utf-8') for dir in self.volspec.INTERNAL_DIRS])
                 ret = 0, name_to_json(groups), ""
         except VolumeException as ve:
             if not ve.errno == -errno.ENOENT or not volume_exists: