]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonCap: simplify rwx match logic
authorSage Weil <sage@inktank.com>
Sat, 20 Jul 2013 04:48:26 +0000 (21:48 -0700)
committerSage Weil <sage@inktank.com>
Sat, 20 Jul 2013 05:32:23 +0000 (22:32 -0700)
Make this a positive check instead of double negative.

Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/MonCap.cc
src/mon/Monitor.cc

index 1114ca3b9da35ac245cae5a505d19bd35ae6a1c6..8e35b775247c11ffdc436366691cfc63e8b92ba9 100644 (file)
@@ -261,15 +261,21 @@ bool MonCap::is_capable(CephContext *cct,
     if (cct)
       ldout(cct, 20) << " allow so far " << allow << ", doing grant " << *p << dendl;
 
-    if (p->is_allow_all())
+    if (p->is_allow_all()) {
+      if (cct)
+       ldout(cct, 20) << " allow all" << dendl;
       return true;
+    }
 
     // check enumerated caps
     allow = allow | p->get_allowed(cct, name, service, command, command_args);
-    if (!((op_may_read && !(allow & MON_CAP_R)) ||
-         (op_may_write && !(allow & MON_CAP_W)) ||
-         (op_may_exec && !(allow & MON_CAP_X))))
+    if ((!op_may_read || (allow & MON_CAP_R)) &&
+       (!op_may_write || (allow & MON_CAP_W)) &&
+       (!op_may_exec || (allow & MON_CAP_X))) {
+      if (cct)
+       ldout(cct, 20) << " match" << dendl;
       return true;
+    }
   }
   return false;
 }
index 8b38adf449d7c9ea575b0989a414b162b6a64dec..7e484e8db6b1767a78d706fed8ecc5530b2d5dfe 100644 (file)
@@ -1523,8 +1523,10 @@ bool Monitor::_allowed_command(MonSession *s, map<string, cmd_vartype>& cmd)
 {
   bool retval = false;
 
-  if (s->caps.is_allow_all())
+  if (s->caps.is_allow_all()) {
+    dout(10) << __func__ << " allow_all" << dendl;
     return true;
+  }
 
   string prefix;
   cmd_getval(g_ceph_context, cmd, "prefix", prefix);
@@ -1542,6 +1544,7 @@ bool Monitor::_allowed_command(MonSession *s, map<string, cmd_vartype>& cmd)
     retval = true; 
   }
 
+  dout(10) << __func__ << " = " << retval << dendl;
   return retval;
 }