]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: check for invalid chars in cluster id
authorVarsha Rao <varao@redhat.com>
Thu, 15 Apr 2021 11:12:35 +0000 (16:42 +0530)
committerVarsha Rao <varao@redhat.com>
Thu, 20 May 2021 05:39:05 +0000 (11:09 +0530)
Signed-off-by: Varsha Rao <varao@redhat.com>
(cherry picked from commit 07e7263936191f6be07d7e03be2de16aa8bffd58)

src/pybind/mgr/nfs/cluster.py
src/pybind/mgr/nfs/module.py

index 8694194e5ce9af6e46778721aa71f17b0147c788..da52d79b64846b55c0b59a8489439e368b495662 100644 (file)
@@ -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:
index c82d5b3a9d8c68437b605f55badf4f4753af403c..e4761a7d2255e5d9d059ae041adf10592f1b2d35 100644 (file)
@@ -9,8 +9,6 @@ from .cluster import NFSCluster
 
 log = logging.getLogger(__name__)
 
-goodchars = '[A-Za-z0-9-_.]'
-
 
 class Module(orchestrator.OrchestratorClientMixin, MgrModule):
     MODULE_OPTIONS = []