summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2015-02-27 10:14:27 -0500
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-02-27 11:25:42 -0500
commitd849d158c195d9f3e43090111306968cc3f435d8 (patch)
treea705d5d7ffa851ef043412eeb7cd72939830bf78
parent7007e0e571b859f3aed79a61c6821cc552fb2685 (diff)
downloadmongo-d849d158c195d9f3e43090111306968cc3f435d8.tar.gz
SERVER-17403 Fix StageDebugCmd command registration
(cherry picked from commit 7d588bd39adc253e0b32df0049569888d392159b)
-rw-r--r--src/mongo/db/exec/stagedebug_cmd.cpp21
1 files 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<Privilege>* 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