diff options
author | Sage Weil <sage@inktank.com> | 2012-05-22 18:54:10 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-06-08 17:22:10 -0700 |
commit | 4551808fa00b812fee6e0c196fd333eca0b06de9 (patch) | |
tree | 5df35d34d092c19f4787f493e435459026d0c330 /src/mon | |
parent | b2793c426e744612222c874dff2d857588164b54 (diff) | |
download | ceph-4551808fa00b812fee6e0c196fd333eca0b06de9.tar.gz |
mon: add 'auth get-or-create' variant that outputs a keyring
This is more convenient when you're creating daemons, since you want to
write out a keyring file for them. This lets you do it in a single
command.
Signed-off-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'src/mon')
-rw-r--r-- | src/mon/AuthMonitor.cc | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index df7ce553220..d9b698aefd5 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -431,6 +431,7 @@ bool AuthMonitor::preprocess_command(MMonCommand *m) if (m->cmd.size() > 1) { if (m->cmd[1] == "add" || m->cmd[1] == "del" || + m->cmd[1] == "get-or-create" || m->cmd[1] == "get-or-create-key" || m->cmd[1] == "caps") { return false; @@ -628,7 +629,9 @@ 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] == "get-or-create-key" && m->cmd.size() >= 3) { + else if ((m->cmd[1] == "get-or-create-key" || + m->cmd[1] == "get-or-create") && + m->cmd.size() >= 3) { // auth get-or-create <name> [mon osdcapa osd osdcapb ...] EntityName entity; if (!entity.from_str(m->cmd[2])) { @@ -652,7 +655,13 @@ bool AuthMonitor::prepare_command(MMonCommand *m) } } - ss << entity_auth.key; + if (m->cmd[1] == "get-or-create-key") { + ss << entity_auth.key; + } else { + KeyRing kr; + kr.add(entity, entity_auth.key); + kr.encode_plaintext(rdata); + } err = 0; goto done; } @@ -683,9 +692,16 @@ bool AuthMonitor::prepare_command(MMonCommand *m) push_cephx_inc(auth_inc); - ss << auth_inc.auth.key; + if (m->cmd[1] == "get-or-create-key") { + ss << auth_inc.auth.key; + } else { + KeyRing kr; + kr.add(entity, auth_inc.auth.key); + kr.encode_plaintext(rdata); + } + getline(ss, rs); - paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version())); + paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, rdata, paxos->get_version())); return true; } else if (m->cmd[1] == "caps" && m->cmd.size() >= 3) { |