From d849d158c195d9f3e43090111306968cc3f435d8 Mon Sep 17 00:00:00 2001 From: Jason Rassi Date: Fri, 27 Feb 2015 10:14:27 -0500 Subject: SERVER-17403 Fix StageDebugCmd command registration (cherry picked from commit 7d588bd39adc253e0b32df0049569888d392159b) --- src/mongo/db/exec/stagedebug_cmd.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/mongo/db/exec/stagedebug_cmd.cpp b/src/mongo/db/exec/stagedebug_cmd.cpp index d93a4637a41..61af015d428 100644 --- a/src/mongo/db/exec/stagedebug_cmd.cpp +++ b/src/mongo/db/exec/stagedebug_cmd.cpp @@ -26,6 +26,7 @@ * it in the license file. */ +#include "mongo/base/init.h" #include "mongo/db/auth/action_set.h" #include "mongo/db/auth/action_type.h" #include "mongo/db/auth/privilege.h" @@ -94,18 +95,16 @@ namespace mongo { public: StageDebugCmd() : Command("stageDebug") { } - // Boilerplate for commands virtual bool isWriteCommandForConfigServer() const { return false; } - bool slaveOk() const { return true; } - bool slaveOverrideOk() const { return true; } + bool slaveOk() const { return false; } + bool slaveOverrideOk() const { return false; } void help(std::stringstream& h) const { } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, std::vector* out) { - ActionSet actions; - actions.addAction(ActionType::find); - out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions)); + // Command is testing-only, and can only be enabled at command line. Hence, no auth + // check needed. } bool run(OperationContext* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, @@ -448,6 +447,14 @@ namespace mongo { return NULL; } } - } stageDebugCmd; + }; + + MONGO_INITIALIZER(RegisterStageDebugCmd)(InitializerContext* context) { + if (Command::testCommandsEnabled) { + // Leaked intentionally: a Command registers itself when constructed. + new StageDebugCmd(); + } + return Status::OK(); + } } // namespace mongo -- cgit v1.2.1