]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osdcap: make caps additive
authorSage Weil <sage@inktank.com>
Thu, 14 Jun 2012 23:35:02 +0000 (16:35 -0700)
committerSage Weil <sage@inktank.com>
Thu, 14 Jun 2012 23:35:02 +0000 (16:35 -0700)
Make 'allow pool foo r, allow pool foo w, allow x' sufficient when you
require rwx for pool foo.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/OSDCap.cc

index 54715077621438fb8dca67e150a3ead5527e6f1e..fb30c31ecbb176e4590161dad450c395d4731ae9 100644 (file)
@@ -110,13 +110,15 @@ void OSDCap::set_allow_all()
 bool OSDCap::is_capable(const string& pool_name, int64_t pool_auid, const string& object,
                        bool op_may_read, bool op_may_write, bool op_may_exec) const
 {
+  rwxa_t allow = 0;
   for (vector<OSDCapGrant>::const_iterator p = grants.begin(); p != grants.end(); ++p) {
     if (p->match.is_match(pool_name, pool_auid, object)) {
-      if (op_may_read && !(p->spec.allow & OSD_CAP_R))
+      allow |= p->spec.allow;
+      if (op_may_read && !(allow & OSD_CAP_R))
        continue;
-      if (op_may_write && !(p->spec.allow & OSD_CAP_W))
+      if (op_may_write && !(allow & OSD_CAP_W))
        continue;
-      if (op_may_exec && !(p->spec.allow & OSD_CAP_X))
+      if (op_may_exec && !(allow & OSD_CAP_X))
        continue;
       return true;
     }