From: Nikhilkumar Shelke Date: Wed, 22 Jun 2022 09:55:23 +0000 (+0530) Subject: mgr/volumes: filter internal directories in 'subvolumegroup ls' command X-Git-Tag: v18.0.0~322^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ce3fa7f1bcd9ca8a9e9e80ca33a15d0746ce7110;p=ceph.git mgr/volumes: filter internal directories in 'subvolumegroup ls' command 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 --- diff --git a/src/pybind/mgr/volumes/fs/operations/group.py b/src/pybind/mgr/volumes/fs/operations/group.py index dac744a306cfe..8b40610332dce 100644 --- a/src/pybind/mgr/volumes/fs/operations/group.py +++ b/src/pybind/mgr/volumes/fs/operations/group.py @@ -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 diff --git a/src/pybind/mgr/volumes/fs/volume.py b/src/pybind/mgr/volumes/fs/volume.py index faa969c52a724..cef35ad1546da 100644 --- a/src/pybind/mgr/volumes/fs/volume.py +++ b/src/pybind/mgr/volumes/fs/volume.py @@ -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: