From ca8ac9502bdfce888decd4b53669ef57858afcf6 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 25 Jul 2013 17:58:12 -0700 Subject: [PATCH] mon: translate caps=[k1,v1,k2,v2] into [caps_k1=v1, caps_k2=v2] The command matching needs key/value pairs. Signed-off-by: Sage Weil Reviewed-by: Dan Mick --- src/mon/Monitor.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index bd189f1430ce4..bf500dff218fc 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -1535,11 +1535,23 @@ bool Monitor::_allowed_command(MonSession *s, map& cmd) map strmap; for (map::const_iterator p = cmd.begin(); p != cmd.end(); ++p) { - if (p->first != "prefix") { - strmap[p->first] = cmd_vartype_stringify(p->second); + if (p->first == "prefix") + continue; + if (p->first == "caps") { + vector cv; + if (cmd_getval(g_ceph_context, cmd, "caps", cv) && + cv.size() % 2 == 0) { + for (unsigned i = 0; i < cv.size(); i += 2) { + string k = string("caps_") + cv[i]; + strmap[k] = cv[i + 1]; + } + continue; + } } + strmap[p->first] = cmd_vartype_stringify(p->second); } + dout(20) << __func__ << " strmap " << strmap << dendl; if (s->caps.is_capable(g_ceph_context, s->inst.name, "", prefix, strmap, false, false, true)) { retval = true; -- 2.39.5