From c8c02b96bdee9c2a8b5f8af11aaff8616c42f537 Mon Sep 17 00:00:00 2001 From: Shinobu Kinjo Date: Sat, 4 Nov 2017 09:53:31 +0900 Subject: [PATCH] mgr/DaemonServer: [Cleanup] Remove redundant code Signed-off-by: Shinobu Kinjo (cherry picked from commit e1b4c9de677a9041ba9dfba37d1b37999842789a) --- src/mgr/DaemonServer.cc | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index aba28f1f15827..256148e4e1925 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -726,29 +726,27 @@ bool DaemonServer::handle_command(MCommand *m) // lookup command const MonCommand *mgr_cmd = _get_mgrcommand(prefix, mgr_commands); _generate_command_map(cmdctx->cmdmap, param_str_map); + + bool is_allowed; if (!mgr_cmd) { MonCommand py_command = {"", "", "py", "rw", "cli"}; - if (!_allowed_command(session.get(), py_command.module, prefix, cmdctx->cmdmap, - param_str_map, &py_command)) { - dout(1) << " access denied" << dendl; - ss << "access denied; does your client key have mgr caps?" - " See http://docs.ceph.com/docs/master/mgr/administrator/#client-authentication"; - cmdctx->reply(-EACCES, ss); - return true; - } + is_allowed = _allowed_command(session.get(), py_command.module, + prefix, cmdctx->cmdmap, param_str_map, &py_command); } else { // validate user's permissions for requested command - if (!_allowed_command(session.get(), mgr_cmd->module, prefix, cmdctx->cmdmap, - param_str_map, mgr_cmd)) { + is_allowed = _allowed_command(session.get(), mgr_cmd->module, + prefix, cmdctx->cmdmap, param_str_map, mgr_cmd); + } + if (!is_allowed) { dout(1) << " access denied" << dendl; audit_clog->info() << "from='" << session->inst << "' " << "entity='" << session->entity_name << "' " << "cmd=" << m->cmd << ": access denied"; - ss << "access denied' does your client key have mgr caps?" - " See http://docs.ceph.com/docs/master/mgr/administrator/#client-authentication"; + ss << "access denied' does your client key have mgr caps? " + "See http://docs.ceph.com/docs/master/mgr/administrator/" + "#client-authentication"; cmdctx->reply(-EACCES, ss); return true; - } } audit_clog->debug() -- 2.39.5