From: Jason Dillaman Date: Tue, 30 Jan 2018 01:52:14 +0000 (-0500) Subject: osd/OSDCap: rbd-read-only profile now permits use of clone class methods X-Git-Tag: v13.0.2~327^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=01198184db6e9f2647bc11ddfca7ad8c743e5406;p=ceph.git osd/OSDCap: rbd-read-only profile now permits use of clone class methods Signed-off-by: Jason Dillaman --- diff --git a/src/osd/OSDCap.cc b/src/osd/OSDCap.cc index cd1b747d692..368b59ffdda 100644 --- a/src/osd/OSDCap.cc +++ b/src/osd/OSDCap.cc @@ -320,9 +320,9 @@ void OSDCapGrant::expand_profile() if (profile.name == "rbd") { // RBD read-write grant - profile_grants.emplace_back(OSDCapMatch("", "", "rbd_children"), + profile_grants.emplace_back(OSDCapMatch({}, "rbd_children"), OSDCapSpec(osd_rwxa_t(OSD_CAP_CLS_R))); - profile_grants.emplace_back(OSDCapMatch("", "", "rbd_mirroring"), + profile_grants.emplace_back(OSDCapMatch({}, "rbd_mirroring"), OSDCapSpec(osd_rwxa_t(OSD_CAP_CLS_R))); profile_grants.emplace_back(OSDCapMatch(profile.pool_namespace), OSDCapSpec(osd_rwxa_t(OSD_CAP_R | @@ -334,6 +334,12 @@ void OSDCapGrant::expand_profile() profile_grants.emplace_back(OSDCapMatch(profile.pool_namespace), OSDCapSpec(osd_rwxa_t(OSD_CAP_R | OSD_CAP_CLS_R))); + profile_grants.emplace_back(OSDCapMatch(profile.pool_namespace, + "rbd_header."), + OSDCapSpec("rbd", "child_attach")); + profile_grants.emplace_back(OSDCapMatch(profile.pool_namespace, + "rbd_header."), + OSDCapSpec("rbd", "child_detach")); } } diff --git a/src/osd/OSDCap.h b/src/osd/OSDCap.h index eeb3835aa14..af969bfd3a0 100644 --- a/src/osd/OSDCap.h +++ b/src/osd/OSDCap.h @@ -129,6 +129,8 @@ struct OSDCapMatch { OSDCapMatch() {} OSDCapMatch(const OSDCapPoolTag& pt) : pool_tag(pt) {} OSDCapMatch(const OSDCapPoolNamespace& pns) : pool_namespace(pns) {} + OSDCapMatch(const OSDCapPoolNamespace& pns, const std::string& pre) + : pool_namespace(pns), object_prefix(pre) {} OSDCapMatch(const std::string& pl, const std::string& pre) : pool_namespace(pl), object_prefix(pre) {} OSDCapMatch(const std::string& pl, const std::string& ns, diff --git a/src/test/osd/osdcap.cc b/src/test/osd/osdcap.cc index 2a06eb4702e..4486299efb0 100644 --- a/src/test/osd/osdcap.cc +++ b/src/test/osd/osdcap.cc @@ -1285,5 +1285,12 @@ TEST(OSDCap, AllowProfile) { ASSERT_FALSE(cap.is_capable("foo", "", 0, {}, "rbd_children", true, false, {})); ASSERT_TRUE(cap.is_capable("abc", "", 0, {}, "asdf", true, false, {{"rbd", "", true, false, true}})); + ASSERT_FALSE(cap.is_capable("abc", "", 0, {}, "asdf", true, true, {})); + ASSERT_TRUE(cap.is_capable("abc", "", 0, {}, "rbd_header.ABC", false, false, + {{"rbd", "child_attach", true, true, true}})); + ASSERT_TRUE(cap.is_capable("abc", "", 0, {}, "rbd_header.ABC", false, false, + {{"rbd", "child_detach", true, true, true}})); + ASSERT_FALSE(cap.is_capable("abc", "", 0, {}, "rbd_header.ABC", false, false, + {{"rbd", "other function", true, true, true}})); }