From: Shinobu Kinjo Date: Sat, 4 Nov 2017 00:53:31 +0000 (+0900) Subject: mgr/DaemonServer: [Cleanup] Remove redundant code X-Git-Tag: v12.2.13~128^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c8c02b96bdee9c2a8b5f8af11aaff8616c42f537;p=ceph.git mgr/DaemonServer: [Cleanup] Remove redundant code Signed-off-by: Shinobu Kinjo (cherry picked from commit e1b4c9de677a9041ba9dfba37d1b37999842789a) --- diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index aba28f1f158..256148e4e19 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()