Skip to content

Commit

Permalink
mds: sort GID lists in MDSAuthCaps
Browse files Browse the repository at this point in the history
Fixes: http://tracker.ceph.com/issues/17368

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
  • Loading branch information
gregsfortytwo committed Sep 26, 2016
1 parent 6da13e9 commit fa54c8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/mds/MDSAuthCaps.cc
Expand Up @@ -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) {
Expand Down Expand Up @@ -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!
Expand Down
2 changes: 1 addition & 1 deletion src/test/mds/TestMDSAuthCaps.cc
Expand Up @@ -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
Expand Down

0 comments on commit fa54c8a

Please sign in to comment.