diff options
-rw-r--r-- | src/mongo/s/commands/cluster_enable_sharding_cmd.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_move_primary_cmd.cpp | 12 |
2 files changed, 6 insertions, 10 deletions
diff --git a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp index c32deffc98d..3c17bc7433e 100644 --- a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp +++ b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp @@ -85,10 +85,6 @@ namespace { } virtual std::string parseNs(const std::string& dbname, const BSONObj& cmdObj) const { - if (cmdObj.firstElement().type() != String) { - return ""; - } - return cmdObj.firstElement().str(); } diff --git a/src/mongo/s/commands/cluster_move_primary_cmd.cpp b/src/mongo/s/commands/cluster_move_primary_cmd.cpp index 1637452f90e..993731723a5 100644 --- a/src/mongo/s/commands/cluster_move_primary_cmd.cpp +++ b/src/mongo/s/commands/cluster_move_primary_cmd.cpp @@ -91,7 +91,7 @@ namespace { } virtual std::string parseNs(const std::string& dbname, const BSONObj& cmdObj) const { - return cmdObj.firstElement().valuestrsafe(); + return cmdObj.firstElement().str(); } virtual bool run(OperationContext* txn, @@ -101,15 +101,15 @@ namespace { std::string& errmsg, BSONObjBuilder& result) { - const string dbname = parseNs("admin", cmdObj); + const string dbname = parseNs("", cmdObj); - if (dbname.size() == 0) { - errmsg = "no db"; + if (dbname.empty() || !nsIsDbOnly(dbname)) { + errmsg = "invalid db name specified: " + dbname; return false; } - if (dbname == "config") { - errmsg = "can't move config db"; + if (dbname == "admin" || dbname == "config" || dbname == "local") { + errmsg = "can't move primary for " + dbname + " database"; return false; } |