diff --git a/src/mds/MDSAuthCaps.cc b/src/mds/MDSAuthCaps.cc index e0a095d639004..0fc1dc09e6cea 100644 --- a/src/mds/MDSAuthCaps.cc +++ b/src/mds/MDSAuthCaps.cc @@ -210,7 +210,9 @@ bool MDSAuthCaps::is_capable(const std::string &inode_path, std::set_intersection(i->match.gids.begin(), i->match.gids.end(), caller_gid_list->begin(), caller_gid_list->end(), std::back_inserter(gids)); + std::sort(gids.begin(), gids.end()); } + // Spec is non-allowing if caller asked for set pool but spec forbids it if (mask & MAY_SET_POOL) { @@ -290,6 +292,9 @@ bool MDSAuthCaps::parse(CephContext *c, const std::string& str, ostream *err) bool r = qi::phrase_parse(iter, end, g, ascii::space, *this); cct = c; // set after parser self-assignment if (r && iter == end) { + for (auto& grant : grants) { + std::sort(grant.match.gids.begin(), grant.match.gids.end()); + } return true; } else { // Make sure no grants are kept after parsing failed! diff --git a/src/test/mds/TestMDSAuthCaps.cc b/src/test/mds/TestMDSAuthCaps.cc index 575910ead58e5..eb2cb43bd7c11 100644 --- a/src/test/mds/TestMDSAuthCaps.cc +++ b/src/test/mds/TestMDSAuthCaps.cc @@ -119,7 +119,7 @@ TEST(MDSAuthCaps, AllowAll) { TEST(MDSAuthCaps, AllowUid) { MDSAuthCaps cap(g_ceph_context); - ASSERT_TRUE(cap.parse(g_ceph_context, "allow * uid=10 gids=10,11,12; allow * uid=12 gids=10,12", NULL)); + ASSERT_TRUE(cap.parse(g_ceph_context, "allow * uid=10 gids=10,11,12; allow * uid=12 gids=12,10", NULL)); ASSERT_FALSE(cap.allow_all()); // uid/gid must be valid