Skip to content

Commit 0e90958

Browse files
authored
Merge pull request ceph#51814 from idryomov/wip-61382
osd/OSDCap: allow rbd.metadata_list method under rbd-read-only profile Reviewed-by: Mykola Golub <[email protected]>
2 parents e0a4088 + b580cda commit 0e90958

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

src/osd/OSDCap.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ void OSDCapGrant::expand_profile()
344344
OSDCapSpec(osd_rwxa_t(OSD_CAP_CLS_R)));
345345
profile_grants.emplace_back(OSDCapMatch(string(), "rbd_mirroring"),
346346
OSDCapSpec(osd_rwxa_t(OSD_CAP_CLS_R)));
347-
profile_grants.emplace_back(OSDCapMatch(profile.pool_namespace.pool_name),
347+
profile_grants.emplace_back(OSDCapMatch(profile.pool_namespace.pool_name,
348+
"", "rbd_info"),
348349
OSDCapSpec("rbd", "metadata_list"));
349350
profile_grants.emplace_back(OSDCapMatch(profile.pool_namespace),
350351
OSDCapSpec(osd_rwxa_t(OSD_CAP_R |
@@ -353,6 +354,9 @@ void OSDCapGrant::expand_profile()
353354
}
354355
if (profile.name == "rbd-read-only") {
355356
// RBD read-only grant
357+
profile_grants.emplace_back(OSDCapMatch(profile.pool_namespace.pool_name,
358+
"", "rbd_info"),
359+
OSDCapSpec("rbd", "metadata_list"));
356360
profile_grants.emplace_back(OSDCapMatch(profile.pool_namespace),
357361
OSDCapSpec(osd_rwxa_t(OSD_CAP_R |
358362
OSD_CAP_CLS_R)));

src/test/osd/osdcap.cc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,49 @@ TEST(OSDCap, AllowProfile) {
13381338
{{"rbd", "child_detach", true, true, true}}, addr));
13391339
ASSERT_FALSE(cap.is_capable("abc", "", {}, "rbd_header.ABC", false, false,
13401340
{{"rbd", "other function", true, true, true}}, addr));
1341+
1342+
cap.grants.clear();
1343+
ASSERT_TRUE(cap.parse("profile rbd pool pool1 namespace ns1", nullptr));
1344+
ASSERT_TRUE(cap.is_capable("pool1", "", {}, "rbd_info", false, false,
1345+
{{"rbd", "metadata_list", true, false, true}},
1346+
addr));
1347+
ASSERT_TRUE(cap.is_capable("pool1", "ns1", {}, "rbd_info", false, false,
1348+
{{"rbd", "metadata_list", true, false, true}},
1349+
addr));
1350+
ASSERT_FALSE(cap.is_capable("pool1", "ns2", {}, "rbd_info", false, false,
1351+
{{"rbd", "metadata_list", true, false, true}},
1352+
addr));
1353+
ASSERT_FALSE(cap.is_capable("pool2", "", {}, "rbd_info", false, false,
1354+
{{"rbd", "metadata_list", true, false, true}},
1355+
addr));
1356+
ASSERT_FALSE(cap.is_capable("pool1", "", {}, "asdf", false, false,
1357+
{{"rbd", "metadata_list", true, false, true}},
1358+
addr));
1359+
ASSERT_FALSE(cap.is_capable("pool1", "", {}, "rbd_info", false, false,
1360+
{{"rbd", "other_method", true, false, true}},
1361+
addr));
1362+
1363+
cap.grants.clear();
1364+
ASSERT_TRUE(cap.parse("profile rbd-read-only pool pool1 namespace ns1",
1365+
nullptr));
1366+
ASSERT_TRUE(cap.is_capable("pool1", "", {}, "rbd_info", false, false,
1367+
{{"rbd", "metadata_list", true, false, true}},
1368+
addr));
1369+
ASSERT_TRUE(cap.is_capable("pool1", "ns1", {}, "rbd_info", false, false,
1370+
{{"rbd", "metadata_list", true, false, true}},
1371+
addr));
1372+
ASSERT_FALSE(cap.is_capable("pool1", "ns2", {}, "rbd_info", false, false,
1373+
{{"rbd", "metadata_list", true, false, true}},
1374+
addr));
1375+
ASSERT_FALSE(cap.is_capable("pool2", "", {}, "rbd_info", false, false,
1376+
{{"rbd", "metadata_list", true, false, true}},
1377+
addr));
1378+
ASSERT_FALSE(cap.is_capable("pool1", "", {}, "asdf", false, false,
1379+
{{"rbd", "metadata_list", true, false, true}},
1380+
addr));
1381+
ASSERT_FALSE(cap.is_capable("pool1", "", {}, "rbd_info", false, false,
1382+
{{"rbd", "other_method", true, false, true}},
1383+
addr));
13411384
}
13421385

13431386
TEST(OSDCap, network) {

0 commit comments

Comments
 (0)