From: Sage Weil Date: Sun, 12 Aug 2018 18:29:00 +0000 (-0500) Subject: osd/OSDCap: remove auid from grammar X-Git-Tag: v14.0.1~431^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0ce73796fdb3feabf42d46d86ec9d234fee4c2ce;p=ceph.git osd/OSDCap: remove auid from grammar This is an incompatible change: old caps that include auid will no longer parse. Signed-off-by: Sage Weil --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 250e9cc7c19c..ea333b62ec92 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -100,7 +100,7 @@ bool is_osd_writable(const OSDCapGrant& grant, const std::string* pool_name) { auto& match = grant.match; if (match.is_match_all()) { return true; - } else if (pool_name != nullptr && match.auid < 0 && + } else if (pool_name != nullptr && !match.pool_namespace.pool_name.empty() && match.pool_namespace.pool_name == *pool_name) { return true; diff --git a/src/osd/OSDCap.cc b/src/osd/OSDCap.cc index d482da727f0e..ee1e947b088c 100644 --- a/src/osd/OSDCap.cc +++ b/src/osd/OSDCap.cc @@ -85,10 +85,6 @@ ostream& operator<<(ostream &out, const OSDCapPoolTag &pt) ostream& operator<<(ostream& out, const OSDCapMatch& m) { - if (m.auid != -1LL) { - out << "auid " << m.auid << " "; - } - if (!m.pool_namespace.pool_name.empty() || m.pool_namespace.nspace) { out << m.pool_namespace; } @@ -193,9 +189,7 @@ bool OSDCapMatch::is_match(const string& pn, const string& ns, bool OSDCapMatch::is_match_all() const { - if (auid >= 0) { - return false; - } else if (!pool_namespace.is_match_all()) { +if (!pool_namespace.is_match_all()) { return false; } else if (!pool_tag.is_match_all()) { return false; @@ -338,9 +332,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(string(), "rbd_children"), OSDCapSpec(osd_rwxa_t(OSD_CAP_CLS_R))); - profile_grants.emplace_back(OSDCapMatch({}, "rbd_mirroring"), + profile_grants.emplace_back(OSDCapMatch(string(), "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 | @@ -437,8 +431,7 @@ struct OSDCapParser : qi::grammar >> (lit('=') | spaces) >> estr >> -char_('*')); - // match := [pool[=] [namespace[=]] | auid <123>] [object_prefix ] - auid %= (spaces >> lit("auid") >> spaces >> int_); + // match := [pool[=] [namespace[=]]] [object_prefix ] object_prefix %= -(spaces >> lit("object_prefix") >> spaces >> str); pooltag %= (spaces >> lit("tag") >> spaces >> str // application @@ -448,7 +441,6 @@ struct OSDCapParser : qi::grammar match = ( pooltag [_val = phoenix::construct(_1)] | (nspace >> pooltag) [_val = phoenix::construct(_1, _2)] | - (auid >> object_prefix) [_val = phoenix::construct(_1, _2)] | (pool_name >> nspace >> object_prefix) [_val = phoenix::construct(_1, _2, _3)] | (pool_name >> object_prefix) [_val = phoenix::construct(_1, _2)] ); @@ -499,7 +491,6 @@ struct OSDCapParser : qi::grammar qi::rule unquoted_word; qi::rule str, estr, network_str; qi::rule wildcard; - qi::rule auid; qi::rule class_name; qi::rule method_name; qi::rule capspec; diff --git a/src/osd/OSDCap.h b/src/osd/OSDCap.h index 7f4bc0ff0308..2bb4e21ca1a4 100644 --- a/src/osd/OSDCap.h +++ b/src/osd/OSDCap.h @@ -119,8 +119,6 @@ ostream& operator<<(ostream& out, const OSDCapPoolTag& pt); struct OSDCapMatch { typedef std::map > app_map_t; - // auid and pool_name/nspace are mutually exclusive - int64_t auid = CEPH_AUTH_UID_DEFAULT; OSDCapPoolNamespace pool_namespace; OSDCapPoolTag pool_tag; std::string object_prefix; @@ -135,8 +133,6 @@ struct OSDCapMatch { OSDCapMatch(const std::string& pl, const std::string& ns, const std::string& pre) : pool_namespace(pl, ns), object_prefix(pre) {} - OSDCapMatch(uint64_t auid, const std::string& pre) - : auid(auid), object_prefix(pre) {} OSDCapMatch(const std::string& dummy, const std::string& app, const std::string& key, const std::string& val) : pool_tag(app, key, val) {} @@ -148,7 +144,6 @@ struct OSDCapMatch { * * @param pool_name pool name * @param nspace_name namespace name - * @param pool_auid pool's auid * @param object object name * @return true if we match, false otherwise */ diff --git a/src/test/osd/osdcap.cc b/src/test/osd/osdcap.cc index f87234f37c80..55dd0e526e38 100644 --- a/src/test/osd/osdcap.cc +++ b/src/test/osd/osdcap.cc @@ -34,12 +34,10 @@ const char *parse_good[] = { "allow pool taco object_prefix obj_with_underscores_and_no_quotes wx", "allow rwx pool 'weird name'", "allow rwx pool \"weird name with ''s\"", - "allow rwx auid 123", "allow rwx pool foo, allow r pool bar", "allow rwx pool foo ; allow r pool bar", "allow rwx pool foo ;allow r pool bar", "allow rwx pool foo; allow r pool bar", - "allow auid 123 rwx", "allow pool foo rwx, allow pool bar r", "allow pool foo.froo.foo rwx, allow pool bar r", "allow pool foo rwx ; allow pool bar r", @@ -61,7 +59,6 @@ const char *parse_good[] = { " allow pool foo rwx; allow pool bar r ", " allow wx pool taco", "\tallow\nwx\tpool \n taco\t", - "allow r pool foo object_prefix blah ; allow w auid 5", "allow class-read object_prefix rbd_children, allow pool libvirt-pool-test rwx", "allow class-read object_prefix rbd-children, allow pool libvirt_pool_test rwx", "allow pool foo namespace nfoo rwx, allow pool bar namespace=nbar r", @@ -122,6 +119,9 @@ const char *parse_bad[] = { "allow rwx auid 123 namespace asdf", "allow wwx pool ''", "allow rwx tag application key value", + "allow rwx auid 123", + "allow auid 123 rwx", + "allow r pool foo object_prefix blah ; allow w auid 5", 0 };