#include "messages/MMonSubscribe.h"
#include "messages/MMonSubscribeAck.h"
+#include "messages/MCommand.h"
+#include "messages/MCommandReply.h"
+
#include "messages/MAuthReply.h"
#include "messages/MTimeCheck2.h"
}
};
+void Monitor::handle_tell_command(MonOpRequestRef op)
+{
+ ceph_assert(op->is_type_command());
+ MCommand *m = static_cast<MCommand*>(op->get_req());
+ if (m->fsid != monmap->fsid) {
+ dout(0) << "handle_command on fsid " << m->fsid << " != " << monmap->fsid << dendl;
+ reply_command(op, -EPERM, "wrong fsid", 0);
+ return;
+ }
+ MonSession *session = op->get_session();
+ if (!session) {
+ dout(5) << __func__ << " dropping stray message " << *m << dendl;
+ return;
+ }
+ if (!session->caps.is_allow_all()) {
+ reply_tell_command(op, -EPERM, "insufficient caps");
+ }
+ // pass it to asok
+ cct->get_admin_socket()->queue_tell_command(m);
+}
+
void Monitor::handle_command(MonOpRequestRef op)
{
ceph_assert(op->is_type_command());
auto m = op->get_req<MMonCommand>();
if (m->fsid != monmap->fsid) {
- dout(0) << "handle_command on fsid " << m->fsid << " != " << monmap->fsid << dendl;
+ dout(0) << "handle_command on fsid " << m->fsid << " != " << monmap->fsid
+ << dendl;
reply_command(op, -EPERM, "wrong fsid", 0);
return;
}
}
if (m->cmd.empty()) {
- string rs = "No command supplied";
- reply_command(op, -EINVAL, rs, 0);
+ reply_command(op, -EINVAL, "no command specified", 0);
return;
}
send_reply(op, reply);
}
+void Monitor::reply_tell_command(
+ MonOpRequestRef op, int rc, const string &rs)
+{
+ MCommand *m = static_cast<MCommand*>(op->get_req());
+ ceph_assert(m->get_type() == MSG_COMMAND);
+ MCommandReply *reply = new MCommandReply(rc, rs);
+ reply->set_tid(m->get_tid());
+ m->get_connection()->send_message(reply);
+}
+
// ------------------------
// request/reply routing
case CEPH_MSG_PING:
handle_ping(op);
return;
+ case MSG_COMMAND:
+ op->set_type_command();
+ handle_tell_command(op);
+ return;
}
if (!op->get_session()->authenticated) {
void _quorum_status(Formatter *f, ostream& ss);
bool _add_bootstrap_peer_hint(std::string_view cmd, const cmdmap_t& cmdmap,
std::ostream& ss);
+ void handle_tell_command(MonOpRequestRef op);
void handle_command(MonOpRequestRef op);
void handle_route(MonOpRequestRef op);
void reply_command(MonOpRequestRef op, int rc, const string &rs, version_t version);
void reply_command(MonOpRequestRef op, int rc, const string &rs, bufferlist& rdata, version_t version);
+ void reply_tell_command(MonOpRequestRef op, int rc, const string &rs);
+
+
void handle_probe(MonOpRequestRef op);
/**