]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: add validation function for share login names
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 6 May 2024 20:35:18 +0000 (16:35 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 19 Jun 2024 13:29:42 +0000 (09:29 -0400)
Add a validation function that will be used for a future share login
control attribute.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/smb/validation.py

index bd7c6f211cd81b0dd678cb39c0c74d1acf5167f0..d0890d2fc09e2e78991c347c9a9808145b24b85a 100644 (file)
@@ -103,3 +103,12 @@ def clean_custom_options(
     if opts is None:
         return None
     return {k: v for k, v in opts.items() if k != CUSTOM_CAUTION_KEY}
+
+
+def check_access_name(name: str) -> None:
+    if ' ' in name or '\t' in name or '\n' in name:
+        raise ValueError(
+            'login name may not contain spaces, tabs, or newlines'
+        )
+    if len(name) > 128:
+        raise ValueError('login name may not exceed 128 characters')