From 5678d3975f9a27b993181f055b724a49474faeea Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 17 Mar 2025 16:11:56 -0400 Subject: [PATCH] mgr/smb: add support for converting/filtering passwords in ceph smb show Add a new --password-filter option for `ceph smb show` that can hide or obscure (using base64) passwords in the resources returned. Signed-off-by: John Mulligan --- src/pybind/mgr/smb/module.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pybind/mgr/smb/module.py b/src/pybind/mgr/smb/module.py index 17c6db14b512b..a10642611baf4 100644 --- a/src/pybind/mgr/smb/module.py +++ b/src/pybind/mgr/smb/module.py @@ -21,6 +21,7 @@ from . import ( from .enums import ( AuthMode, JoinSourceType, + PasswordFilter, ShowResults, SMBClustering, UserGroupSourceType, @@ -340,6 +341,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): self, resource_names: Optional[List[str]] = None, results: ShowResults = ShowResults.COLLAPSED, + password_filter: PasswordFilter = PasswordFilter.NONE, ) -> Simplified: """Show resources fetched from the local config store based on resource type or resource type and id(s). @@ -351,6 +353,10 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): resources = self._handler.matching_resources(resource_names) except handler.InvalidResourceMatch as err: raise cli.InvalidInputValue(str(err)) from err + if password_filter is not PasswordFilter.NONE: + op = (PasswordFilter.NONE, password_filter) + log.debug('Password filtering for smb show: %r', op) + resources = [r.convert(op) for r in resources] if len(resources) == 1 and results is ShowResults.COLLAPSED: return resources[0].to_simplified() return {"resources": [r.to_simplified() for r in resources]} -- 2.39.5