]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: auth: implement 'auth print-key <name>'
authorSage Weil <sage@newdream.net>
Tue, 27 Sep 2011 19:54:44 +0000 (12:54 -0700)
committerSage Weil <sage@newdream.net>
Tue, 27 Sep 2011 20:06:02 +0000 (13:06 -0700)
Signed-off-by: Sage Weil <sage@newdream.net>
src/mon/AuthMonitor.cc

index e38ae77855a10671fa2887b518e928f25b7eb98d..db527d6c307cbd0a380b442daec55ea6b77e620d 100644 (file)
@@ -495,7 +495,25 @@ bool AuthMonitor::preprocess_command(MMonCommand *m)
          r = 0;
        }
       }
-    } else {
+    }
+    else if ((m->cmd[1] == "print-key" || m->cmd[1] == "print_key") &&
+            m->cmd.size() == 3) {
+      EntityName ename;
+      if (!ename.from_str(m->cmd[2])) {
+       ss << "failed to identify entity name from " << m->cmd[2];
+       r = -ENOENT;
+       goto done;
+      }
+      EntityAuth auth;
+      if (!mon->key_server.get_auth(ename, auth)) {
+       ss << "don't have " << ename;
+       r = -ENOENT;
+       goto done;
+      }
+      ss << auth.key;
+      r = 0;      
+    }
+    else {
       auth_usage(ss);
       r = -EINVAL;
     }
@@ -504,6 +522,7 @@ bool AuthMonitor::preprocess_command(MMonCommand *m)
     r = -EINVAL;
   }
 
+ done:
   string rs;
   getline(ss, rs, '\0');
   mon->reply_command(m, r, rs, rdata, paxos->get_version());