From: Varsha Rao Date: Thu, 15 Apr 2021 11:12:35 +0000 (+0530) Subject: mgr/nfs: check for invalid chars in cluster id X-Git-Tag: v16.2.5~105^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bd1b5616fc967647d75d504fc8636b43fb693626;p=ceph.git mgr/nfs: check for invalid chars in cluster id Signed-off-by: Varsha Rao (cherry picked from commit 07e7263936191f6be07d7e03be2de16aa8bffd58) --- diff --git a/src/pybind/mgr/nfs/cluster.py b/src/pybind/mgr/nfs/cluster.py index 8694194e5ce..da52d79b648 100644 --- a/src/pybind/mgr/nfs/cluster.py +++ b/src/pybind/mgr/nfs/cluster.py @@ -1,6 +1,7 @@ import logging import socket import json +import re from ceph.deployment.service_spec import NFSServiceSpec, PlacementSpec @@ -59,6 +60,11 @@ class NFSCluster: @cluster_setter def create_nfs_cluster(self, cluster_id, placement): try: + invalid_str = re.search('[^A-Za-z0-9-_.]', cluster_id) + if invalid_str: + raise NFSInvalidOperation(f"cluster id {cluster_id} is invalid. " + f"{invalid_str.group()} is char not permitted") + pool_list = [p['pool_name'] for p in self.mgr.get_osdmap().dump().get('pools', [])] if self.pool_name not in pool_list: diff --git a/src/pybind/mgr/nfs/module.py b/src/pybind/mgr/nfs/module.py index c82d5b3a9d8..e4761a7d225 100644 --- a/src/pybind/mgr/nfs/module.py +++ b/src/pybind/mgr/nfs/module.py @@ -9,8 +9,6 @@ from .cluster import NFSCluster log = logging.getLogger(__name__) -goodchars = '[A-Za-z0-9-_.]' - class Module(orchestrator.OrchestratorClientMixin, MgrModule): MODULE_OPTIONS = []