summaryrefslogtreecommitdiff
path: root/src/mongo/db/dbcommands_generic.cpp
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@10gen.com>2012-10-08 17:48:05 -0400
committerAndy Schwerin <schwerin@10gen.com>2012-10-15 16:42:17 -0400
commit6e326668c3d65b4e9af779b3c667c5b2c09bfaf6 (patch)
treeb13638c7daa55f07b3c70037c68fba0676d3a7b6 /src/mongo/db/dbcommands_generic.cpp
parent5a28905a8359f336aaa9c6acffe96448ab88e2a1 (diff)
downloadmongo-6e326668c3d65b4e9af779b3c667c5b2c09bfaf6.tar.gz
SERVER-7332 Censor command line explicitly, change CmdLine::store to take a vector of strings.
This patch separates the process of censoring the process argv array (affecting the output of ps on linux) from the process of parsing the command line. It then changes CmdLine::store to take a vector of strings, instead of a mutable char**, for later use in the init system's command line processing role. Unit tests for the new censoring code, which is more throrough than the old, are included, and the "command" to get the contents of the command line is moved to dbcommands_generic, to make linking cmdline.cpp into unit tests easier.
Diffstat (limited to 'src/mongo/db/dbcommands_generic.cpp')
-rw-r--r--src/mongo/db/dbcommands_generic.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/db/dbcommands_generic.cpp b/src/mongo/db/dbcommands_generic.cpp
index ff128dbd1ff..aaba9d365a9 100644
--- a/src/mongo/db/dbcommands_generic.cpp
+++ b/src/mongo/db/dbcommands_generic.cpp
@@ -476,4 +476,20 @@ namespace mongo {
} getLogCmd;
+ class CmdGetCmdLineOpts : Command {
+ public:
+ CmdGetCmdLineOpts(): Command("getCmdLineOpts") {}
+ void help(stringstream& h) const { h << "get argv"; }
+ virtual LockType locktype() const { return NONE; }
+ virtual bool adminOnly() const { return true; }
+ virtual bool slaveOk() const { return true; }
+
+ virtual bool run(const string&, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
+ result.append("argv", CmdLine::getArgvArray());
+ result.append("parsed", CmdLine::getParsedOpts());
+ return true;
+ }
+
+ } cmdGetCmdLineOpts;
+
}