]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: scope .smb pool read cap to its own namespace 70218/head
authorAvan Thakkar <athakkar@redhat.com>
Wed, 15 Jul 2026 11:11:11 +0000 (16:41 +0530)
committerAvan Thakkar <athakkar@redhat.com>
Wed, 15 Jul 2026 11:22:00 +0000 (16:52 +0530)
Scope the .smb pool read cap to the same namespace already
used by the adjacent cluster-meta rwx cap.

Fixes: https://tracker.ceph.com/issues/78235
Signed-off-by: Avan Thakkar <athakkar@redhat.com>
src/pybind/mgr/cephadm/services/smb.py
src/pybind/mgr/cephadm/tests/services/test_smb.py

index 15fba27bddadc95295eb9f9839e9da9db0255fe0..d2f15c7624f67addf6c79f45443a545fbea53b07 100644 (file)
@@ -390,10 +390,12 @@ class SMBService(CephService):
         logger.debug(
             'found smb pool in uri [pool=%r, ns=%r]: %r', pool, ns, uri
         )
-        # enhanced caps for smb pools to be used for ctdb mgmt
+        # enhanced caps for smb pools to be used for ctdb mgmt.
+        # scoped to this cluster's own namespace given cluster id acts as
+        # a namespace so that a cluster's samba containers can't read
+        # other clusters' config/join/user objects sharing the same pool.
         return [
-            # TODO - restrict this read access to the namespace too?
-            f'allow r pool={pool}',
+            f'allow r pool={pool} namespace={ns}',
             # the x perm is needed to lock the cluster meta object
             f'allow rwx pool={pool} namespace={ns} object_prefix cluster.meta.',
         ]
index f11357718643ed83409ccfe53e1da6decddd56c6..c305d35ca133e23001e37d57b034579f113ff8a0 100644 (file)
@@ -237,3 +237,28 @@ def test_smb_get_dependencies(cephadm_module):
         'smb+field:features=domain',
         'smb+field:rgw_creds_uri=rados:mon-config-key:smb/config/foxtrot/config.smb.rgw',
     ]
+
+
+def test_pool_caps_from_uri(cephadm_module):
+    from cephadm.services.smb import SMBService
+
+    smb_service = SMBService(cephadm_module)
+
+    # objects living in the shared .smb pool must be scoped to the
+    # cluster's own namespace.
+    assert smb_service._pool_caps_from_uri(
+        'rados://.smb/foxtrot/config.json'
+    ) == [
+        'allow r pool=.smb namespace=foxtrot',
+        'allow rwx pool=.smb namespace=foxtrot object_prefix cluster.meta.',
+    ]
+
+    # the empty-namespace uri shape that RADOSConfigEntry.uri can produce
+    # (rados://<pool>//<key>) must still scope the read cap consistently
+    # with the existing rwx cap.
+    assert smb_service._pool_caps_from_uri(
+        'rados://.smb//config.smb'
+    ) == [
+        'allow r pool=.smb namespace=',
+        'allow rwx pool=.smb namespace= object_prefix cluster.meta.',
+    ]