]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: 'auth caps <name> [svc value [svc2 value2 [...]]]'
authorSage Weil <sage.weil@dreamhost.com>
Wed, 18 May 2011 01:32:03 +0000 (18:32 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Wed, 18 May 2011 01:49:39 +0000 (18:49 -0700)
Avoid having to futz with cauthtool if possible.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/mon/AuthMonitor.cc

index 96f2832a9f23f8dc4e63f2a96bc2711542a9738f..c618d3759021f99f26e8be7f975141bd2fcf06d2 100644 (file)
@@ -445,6 +445,7 @@ bool AuthMonitor::preprocess_command(MMonCommand *m)
   if (m->cmd.size() > 1) {
     if (m->cmd[1] == "add" ||
         m->cmd[1] == "del" ||
+       m->cmd[1] == "caps" ||
         m->cmd[1] == "list") {
       return false;
     }
@@ -588,6 +589,33 @@ bool AuthMonitor::prepare_command(MMonCommand *m)
       paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));
       return true;
     }
+    else if (m->cmd[1] == "caps" && m->cmd.size() >= 3) {
+      KeyServerData::Incremental auth_inc;
+      if (!auth_inc.name.from_str(m->cmd[2])) {
+       ss << "bad entity name";
+       rs = -EINVAL;
+       goto done;
+      }
+      if (!mon->key_server.contains(auth_inc.name)) {
+        ss << "couldn't find entry " << auth_inc.name;
+        rs = -ENOENT;
+        goto done;
+      }
+      mon->key_server.get_auth(auth_inc.name, auth_inc.auth);
+
+      map<string,bufferlist> newcaps;
+      for (unsigned i=3; i+1<m->cmd.size(); i++)
+       ::encode(m->cmd[i+1], newcaps[m->cmd[i]]);
+
+      auth_inc.op = KeyServerData::AUTH_INC_ADD;
+      auth_inc.auth.caps = newcaps;
+      push_cephx_inc(auth_inc);
+
+      ss << "updated caps for " << auth_inc.name;
+      getline(ss, rs);
+      paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));
+      return true;     
+    }
     else if (m->cmd[1] == "del" && m->cmd.size() >= 3) {
       string name = m->cmd[2];
       KeyServerData::Incremental auth_inc;