]> git.apps.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)
committerNikhilkumar Shelke <nshelke@redhat.com>
Fri, 5 Aug 2022 08:35:49 +0000 (14:05 +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>
src/pybind/mgr/volumes/fs/operations/group.py
src/pybind/mgr/volumes/fs/volume.py

index dac744a306cfe93f18e1ec73b5e8a132a1e6deb5..8b40610332dce36c8263e2e339f1af8fd32e9c67 100644 (file)
@@ -22,6 +22,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 faa969c52a724a2e0f708f67b7bc9e2cec7aa30f..cef35ad1546dab0e3a9d30caecf0882f106b1721 100644 (file)
@@ -864,7 +864,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: