From: Sage Weil Date: Tue, 27 Sep 2011 19:54:44 +0000 (-0700) Subject: mon: auth: implement 'auth print-key ' X-Git-Tag: v0.37~125 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b690475c5ada607978f9170a96332c765a416f3c;p=ceph.git mon: auth: implement 'auth print-key ' Signed-off-by: Sage Weil --- diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index e38ae77855a1..db527d6c307c 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -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());