示例#1
0
Status storeMongoBridgeOptions(const moe::Environment& params,
                               const std::vector<std::string>& args) {
    if (!params.count("port")) {
        return {ErrorCodes::BadValue, "Missing required option: --port"};
    }

    if (!params.count("dest")) {
        return {ErrorCodes::BadValue, "Missing required option: --dest"};
    }

    mongoBridgeGlobalParams.port = params["port"].as<int>();
    mongoBridgeGlobalParams.destUri = params["dest"].as<std::string>();

    if (!params.count("seed")) {
        std::unique_ptr<SecureRandom> seedSource{SecureRandom::create()};
        mongoBridgeGlobalParams.seed = seedSource->nextInt64();
    } else {
        mongoBridgeGlobalParams.seed = static_cast<int64_t>(params["seed"].as<long>());
    }

    if (params.count("verbose")) {
        std::string verbosity = params["verbose"].as<std::string>();
        if (std::any_of(verbosity.cbegin(), verbosity.cend(), [](char ch) { return ch != 'v'; })) {
            return {ErrorCodes::BadValue,
                    "The string for the --verbose option cannot contain characters other than 'v'"};
        }
        logger::globalLogDomain()->setMinimumLoggedSeverity(
            logger::LogSeverity::Debug(verbosity.length()));
    }

    return Status::OK();
}
示例#2
0
    Status handlePreValidationMongoShellOptions(const moe::Environment& params,
                                                const std::vector<std::string>& args) {
        if (params.count("help")) {
            std::cout << getMongoShellHelp(args[0], moe::startupOptions) << std::endl;
            ::_exit(EXIT_CLEAN);
        }
        if (params.count("version")) {
            cout << "MongoDB shell version: " << mongo::versionString << endl;
            ::_exit(EXIT_CLEAN);
        }
        if (params.count("quiet")) {
            mongo::serverGlobalParams.quiet = true;
        }
#ifdef MONGO_SSL
        Status ret = storeSSLClientOptions(params);
        if (!ret.isOK()) {
            return ret;
        }
#endif
        if (params.count("ipv6")) {
            mongo::enableIPv6();
        }
        if (params.count("verbose")) {
            logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(1));
        }

        return Status::OK();
    }
示例#3
0
bool handlePreValidationMongodOptions(const moe::Environment& params,
                                      const std::vector<std::string>& args) {
    if (params.count("help") && params["help"].as<bool>() == true) {
        printMongodHelp(moe::startupOptions);
        return false;
    }
    if (params.count("version") && params["version"].as<bool>() == true) {
        setPlainConsoleLogger();
        auto&& vii = VersionInfoInterface::instance();
        log() << mongodVersion(vii);
        vii.logBuildInfo();
        return false;
    }
    if (params.count("sysinfo") && params["sysinfo"].as<bool>() == true) {
        setPlainConsoleLogger();
        sysRuntimeInfo();
        return false;
    }

    if (params.count("master") || params.count("slave")) {
        severe() << "Master/slave replication is no longer supported";
        return false;
    }

    return true;
}
示例#4
0
Status validateSSLMongoShellOptions(const moe::Environment& params) {
    // Users must specify either a CAFile or allowInvalidCertificates if ssl=true.
    if (params.count("ssl") && params["ssl"].as<bool>() == true && !params.count("ssl.CAFile") &&
        !params.count("ssl.allowInvalidCertificates")) {
        return Status(ErrorCodes::BadValue,
                      "need to either provide sslCAFile or specify sslAllowInvalidCertificates");
    }
    return Status::OK();
}
示例#5
0
Status storeMongoShellOptions() {
    if ( params.count( "quiet" ) ) {
        mongo::cmdLine.quiet = true;
    }
#ifdef MONGO_SSL
    if ( params.count( "ssl" ) ) {
        mongo::cmdLine.sslOnNormalPorts = true;
    }
    if (params.count("ssl.PEMKeyFile")) {
        mongo::cmdLine.sslPEMKeyFile = params["ssl.PEMKeyFile"].as<std::string>();
    }
    if (params.count("ssl.PEMKeyPassword")) {
        mongo::cmdLine.sslPEMKeyPassword = params["ssl.PEMKeyPassword"].as<std::string>();
    }
    if (params.count("ssl.CAFile")) {
        mongo::cmdLine.sslCAFile = params["ssl.CAFile"].as<std::string>();
    }
    if (params.count("ssl.CRLFile")) {
        mongo::cmdLine.sslCRLFile = params["ssl.CRLFile"].as<std::string>();
    }
    if (params.count( "ssl.FIPSMode")) {
        mongo::cmdLine.sslFIPSMode = true;
    }
#endif
    if ( params.count( "ipv6" ) ) {
        mongo::enableIPv6();
    }
    if ( params.count( "verbose" ) ) {
        logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(1));
    }
    return Status::OK();
}
    Status WiredTigerGlobalOptions::store(const moe::Environment& params,
                                          const std::vector<std::string>& args) {

        // WiredTiger storage engine options
        if (params.count("storage.wiredTiger.engineConfig.cacheSizeGB")) {
            wiredTigerGlobalOptions.cacheSizeGB =
                params["storage.wiredTiger.engineConfig.cacheSizeGB"].as<int>();
        }
        if (params.count("storage.syncPeriodSecs")) {
            wiredTigerGlobalOptions.checkpointDelaySecs =
                static_cast<size_t>(params["storage.syncPeriodSecs"].as<double>());
        }
        if (params.count("storage.wiredTiger.engineConfig.statisticsLogDelaySecs")) {
            wiredTigerGlobalOptions.statisticsLogDelaySecs =
                params["storage.wiredTiger.engineConfig.statisticsLogDelaySecs"].as<int>();
        }
        if (params.count("storage.wiredTiger.engineConfig.journalCompressor")) {
            wiredTigerGlobalOptions.journalCompressor =
                params["storage.wiredTiger.engineConfig.journalCompressor"].as<std::string>();
        }
        if (params.count("storage.wiredTiger.engineConfig.directoryForIndexes")) {
            wiredTigerGlobalOptions.directoryForIndexes =
                params["storage.wiredTiger.engineConfig.directoryForIndexes"].as<bool>();
        }
        if (params.count("storage.wiredTiger.engineConfig.configString")) {
            wiredTigerGlobalOptions.engineConfig =
                params["storage.wiredTiger.engineConfig.configString"].as<std::string>();
            log() << "Engine custom option: " << wiredTigerGlobalOptions.engineConfig;
        }

        // WiredTiger collection options
        if (params.count("storage.wiredTiger.collectionConfig.blockCompressor")) {
            wiredTigerGlobalOptions.collectionBlockCompressor =
                params["storage.wiredTiger.collectionConfig.blockCompressor"].as<std::string>();
        }
        if (params.count("storage.wiredTiger.collectionConfig.configString")) {
            wiredTigerGlobalOptions.collectionConfig =
                params["storage.wiredTiger.collectionConfig.configString"].as<std::string>();
            log() << "Collection custom option: " << wiredTigerGlobalOptions.collectionConfig;
        }

        // WiredTiger index options
        if (params.count("storage.wiredTiger.indexConfig.prefixCompression")) {
            wiredTigerGlobalOptions.useIndexPrefixCompression =
                params["storage.wiredTiger.indexConfig.prefixCompression"].as<bool>();
        }
        if (params.count("storage.wiredTiger.indexConfig.configString")) {
            wiredTigerGlobalOptions.indexConfig =
                params["storage.wiredTiger.indexConfig.configString"].as<std::string>();
            log() << "Index custom option: " << wiredTigerGlobalOptions.indexConfig;
        }

        return Status::OK();
    }
示例#7
0
bool handlePreValidationMongoShellOptions(const moe::Environment& params,
                                          const std::vector<std::string>& args) {
    if (params.count("help")) {
        std::cout << getMongoShellHelp(args[0], moe::startupOptions) << std::endl;
        return false;
    }
    if (params.count("version")) {
        cout << "MongoDB shell version: " << mongo::versionString << endl;
        return false;
    }
    return true;
}
示例#8
0
    Status handlePreValidationMongosOptions(const moe::Environment& params,
                                            const std::vector<std::string>& args) {
        if (params.count("help")) {
            printMongosHelp(serverOptions);
            ::_exit(EXIT_SUCCESS);
        }
        if (params.count("version")) {
            printShardingVersionInfo(true);
            ::_exit(EXIT_SUCCESS);
        }

        return Status::OK();
    }
示例#9
0
 Status storeSSLClientOptions(const moe::Environment& params) {
     if (params.count("ssl") && params["ssl"].as<bool>() == true) {
         sslGlobalParams.sslMode.store(SSLGlobalParams::SSLMode_requireSSL);
     }
     if (params.count("ssl.PEMKeyFile")) {
         sslGlobalParams.sslPEMKeyFile = params["ssl.PEMKeyFile"].as<std::string>();
     }
     if (params.count("ssl.PEMKeyPassword")) {
         sslGlobalParams.sslPEMKeyPassword = params["ssl.PEMKeyPassword"].as<std::string>();
     }
     if (params.count("ssl.CAFile")) {
         sslGlobalParams.sslCAFile = params["ssl.CAFile"].as<std::string>();
     }
     if (params.count("ssl.CRLFile")) {
         sslGlobalParams.sslCRLFile = params["ssl.CRLFile"].as<std::string>();
     }
     if (params.count("net.ssl.allowInvalidHostnames")) {
         sslGlobalParams.sslAllowInvalidHostnames =
             params["net.ssl.allowInvalidHostnames"].as<bool>();
     }
     if (params.count("ssl.allowInvalidCertificates")) {
         sslGlobalParams.sslAllowInvalidCertificates = true;
     }
     if (params.count("ssl.FIPSMode")) {
         sslGlobalParams.sslFIPSMode = true;
     }
     return Status::OK();
 }
示例#10
0
    Status storeSASLOptions(const moe::Environment& params) {

        bool haveAuthenticationMechanisms = false;
        bool haveHostName = false;
        bool haveServiceName = false;
        bool haveAuthdPath = false;

        // Check our setParameter options first so that these values can be properly overridden via
        // the command line even though the options have different names.
        if (params.count("setParameter")) {
            std::map<std::string, std::string> parameters =
                params["setParameter"].as<std::map<std::string, std::string> >();
            for (std::map<std::string, std::string>::iterator parametersIt = parameters.begin();
                 parametersIt != parameters.end(); parametersIt++) {
                if (parametersIt->first == "authenticationMechanisms") {
                    haveAuthenticationMechanisms = true;
                }
                else if (parametersIt->first == "saslHostName") {
                    haveHostName = true;
                }
                else if (parametersIt->first == "saslServiceName") {
                    haveServiceName = true;
                }
                else if (parametersIt->first == "saslauthdPath") {
                    haveAuthdPath = true;
                }
            }
        }

        if (params.count("security.authenticationMechanisms") &&
            !haveAuthenticationMechanisms) {
            saslGlobalParams.authenticationMechanisms =
                params["security.authenticationMechanisms"].as<std::vector<std::string> >();
        }
        if (params.count("security.sasl.hostName") && !haveHostName) {
            saslGlobalParams.hostName =
                params["security.sasl.hostName"].as<std::string>();
        }
        if (params.count("security.sasl.serviceName") && !haveServiceName) {
            saslGlobalParams.serviceName =
                params["security.sasl.serviceName"].as<std::string>();
        }
        if (params.count("security.sasl.saslauthdSocketPath") && !haveAuthdPath) {
            saslGlobalParams.authdPath =
                params["security.sasl.saslauthdSocketPath"].as<std::string>();
        }

        return Status::OK();
    }
示例#11
0
bool handlePreValidationMongoShellOptions(const moe::Environment& params,
                                          const std::vector<std::string>& args) {
    auto&& vii = VersionInfoInterface::instance();
    if (params.count("version") || params.count("help")) {
        setPlainConsoleLogger();
        log() << mongoShellVersion(vii);
        if (params.count("help")) {
            log() << getMongoShellHelp(args[0], moe::startupOptions);
        } else {
            vii.logBuildInfo();
        }
        return false;
    }
    return true;
}
示例#12
0
 bool handlePreValidationBSONDumpOptions(const moe::Environment& params) {
     if (params.count("help")) {
         printBSONDumpHelp(&std::cout);
         return false;
     }
     return true;
 }
示例#13
0
    Status storeMongoRestoreOptions(const moe::Environment& params,
                                    const std::vector<std::string>& args) {
        Status ret = storeGeneralToolOptions(params, args);
        if (!ret.isOK()) {
            return ret;
        }

        ret = storeBSONToolOptions(params, args);
        if (!ret.isOK()) {
            return ret;
        }

        mongoRestoreGlobalParams.restoreDirectory = getParam("dir");
        mongoRestoreGlobalParams.drop = hasParam("drop");
        mongoRestoreGlobalParams.keepIndexVersion = hasParam("keepIndexVersion");
        mongoRestoreGlobalParams.restoreOptions = !hasParam("noOptionsRestore");
        mongoRestoreGlobalParams.restoreIndexes = !hasParam("noIndexRestore");
        mongoRestoreGlobalParams.w = getParam( "w" , 0 );
        mongoRestoreGlobalParams.oplogReplay = hasParam("oplogReplay");
        mongoRestoreGlobalParams.oplogLimit = getParam("oplogLimit", "");

        // Make the default db "" if it was not explicitly set
        if (!params.count("db")) {
            toolGlobalParams.db = "";
        }

        return Status::OK();
    }
示例#14
0
 bool handlePreValidationMongoImportOptions(const moe::Environment& params) {
     if (params.count("help")) {
         printMongoImportHelp(&std::cout);
         return true;
     }
     return false;
 }
示例#15
0
    Status storeBSONDumpOptions(const moe::Environment& params,
                                const std::vector<std::string>& args) {
        Status ret = storeGeneralToolOptions(params, args);
        if (!ret.isOK()) {
            return ret;
        }

        ret = storeBSONToolOptions(params, args);
        if (!ret.isOK()) {
            return ret;
        }

        // BSONDump never has a db connection
        toolGlobalParams.noconnection = true;

        bsonDumpGlobalParams.type = getParam("type");
        bsonDumpGlobalParams.file = getParam("file");

        // Make the default db "" if it was not explicitly set
        if (!params.count("db")) {
            toolGlobalParams.db = "";
        }

        // bsondump always outputs data to stdout, so we can't send messages there
        toolGlobalParams.canUseStdout = false;

        return Status::OK();
    }
示例#16
0
 Status handlePreValidationMongoTopOptions(const moe::Environment& params) {
     if (params.count("help")) {
         printMongoTopHelp(&std::cout);
         ::_exit(0);
     }
     return Status::OK();
 }
示例#17
0
bool handlePreValidationTestFrameworkOptions(const moe::Environment& params,
                                             const std::vector<std::string>& args) {
    if (params.count("help")) {
        std::cout << getTestFrameworkHelp(args[0], moe::startupOptions) << std::endl;
        return false;
    }

    if (params.count("list")) {
        std::vector<std::string> suiteNames = mongo::unittest::getAllSuiteNames();
        for (std::vector<std::string>::const_iterator i = suiteNames.begin(); i != suiteNames.end();
             ++i) {
            std::cout << *i << std::endl;
        }
        return false;
    }

    return true;
}
示例#18
0
bool handlePreValidationMongoStatOptions(const moe::Environment& params) {
    if (!handlePreValidationGeneralToolOptions(params)) {
        return false;
    }
    if (params.count("help")) {
        printMongoStatHelp(&std::cout);
        return false;
    }
    return true;
}
示例#19
0
    bool handlePreValidationMongosOptions(const moe::Environment& params,
                                            const std::vector<std::string>& args) {
        if (params.count("help")) {
            printMongosHelp(moe::startupOptions);
            return false;
        }
        if (params.count("version")) {
            printShardingVersionInfo(true);
            return false;
        }
        if ( params.count( "test" ) ) {
            ::mongo::logger::globalLogDomain()->setMinimumLoggedSeverity(
                    ::mongo::logger::LogSeverity::Debug(5));
            StartupTest::runTests();
            return false;
        }

        return true;
    }
示例#20
0
    Status handlePreValidationMongodOptions(const moe::Environment& params,
                                            const std::vector<std::string>& args) {
        if (params.count("help")) {
            printMongodHelp(serverOptions);
            ::_exit(EXIT_SUCCESS);
        }
        if (params.count("version")) {
            cout << mongodVersion() << endl;
            printGitVersion();
            printOpenSSLVersion();
            ::_exit(EXIT_SUCCESS);
        }
        if (params.count("sysinfo")) {
            sysRuntimeInfo();
            ::_exit(EXIT_SUCCESS);
        }

        return Status::OK();
    }
示例#21
0
bool handlePreValidationMongodOptions(const moe::Environment& params,
                                      const std::vector<std::string>& args) {
    if (params.count("help")) {
        printMongodHelp(moe::startupOptions);
        return false;
    }
    if (params.count("version")) {
        cout << mongodVersion() << endl;
        printGitVersion();
        printOpenSSLVersion();
        return false;
    }
    if (params.count("sysinfo")) {
        sysRuntimeInfo();
        return false;
    }

    return true;
}
    Status storeMongoBridgeOptions(const moe::Environment& params,
                                   const std::vector<std::string>& args) {

        if (!params.count("port")) {
            return Status(ErrorCodes::BadValue, "Missing required option: \"--port\"");
        }

        if (!params.count("dest")) {
            return Status(ErrorCodes::BadValue, "Missing required option: \"--dest\"");
        }

        mongoBridgeGlobalParams.port = params["port"].as<int>();
        mongoBridgeGlobalParams.destUri = params["dest"].as<std::string>();

        if (params.count("delay")) {
            mongoBridgeGlobalParams.delay = params["delay"].as<int>();
        }

        return Status::OK();
    }
示例#23
0
Status storeSASLSSPIOptions(const moe::Environment& params) {
    if (params.count("security.sspiHostnameCanonicalization")) {
        if (params["security.sspiHostnameCanonicalization"].as<std::string>() == "none") {
            saslSSPIGlobalParams.canonicalization = HostnameCanonicalizationMode::kNone;
        } else if (params["security.sspiHostnameCanonicalization"].as<std::string>() == "forward") {
            saslSSPIGlobalParams.canonicalization = HostnameCanonicalizationMode::kForward;
        } else if (params["security.sspiHostnameCanonicalization"].as<std::string>() ==
                   "forwardAndReverse") {
            saslSSPIGlobalParams.canonicalization =
                HostnameCanonicalizationMode::kForwardAndReverse;
        } else {
            return Status(ErrorCodes::InvalidOptions,
                          "Unrecognized sspiHostnameCanonicalization option");
        }
    }
    if (params.count("security.sspiRealmOverride")) {
        saslSSPIGlobalParams.realmOverride = params["security.sspiRealmOverride"].as<std::string>();
    }
    return Status::OK();
}
    Status validateServerOptions(const moe::Environment& params) {
        if (params.count("verbose")) {
            std::string verbosity = params["verbose"].as<std::string>();

            // Skip this for backwards compatibility.  See SERVER-11471.
            if (verbosity != "true") {
                for (std::string::iterator iterator = verbosity.begin();
                    iterator != verbosity.end(); iterator++) {
                    if (*iterator != 'v') {
                        return Status(ErrorCodes::BadValue,
                                      "The \"verbose\" option string cannot contain any characters "
                                      "other than \"v\"");
                    }
                }
            }
        }

#ifdef _WIN32
        if (params.count("install") || params.count("reinstall")) {
            if (params.count("logpath") &&
                !boost::filesystem::path(params["logpath"].as<string>()).is_absolute()) {
                return Status(ErrorCodes::BadValue,
                    "logpath requires an absolute file path with Windows services");
            }

            if (params.count("config") &&
                !boost::filesystem::path(params["config"].as<string>()).is_absolute()) {
                return Status(ErrorCodes::BadValue,
                    "config requires an absolute file path with Windows services");
            }

            if (params.count("processManagement.pidFilePath") &&
                !boost::filesystem::path(
                    params["processManagement.pidFilePath"].as<string>()).is_absolute()) {
                return Status(ErrorCodes::BadValue,
                    "pidFilePath requires an absolute file path with Windows services");
            }

            if (params.count("security.keyFile") &&
                !boost::filesystem::path(params["security.keyFile"].as<string>()).is_absolute()) {
                return Status(ErrorCodes::BadValue,
                    "keyFile requires an absolute file path with Windows services");
            }

        }
#endif

#ifdef MONGO_SSL
        Status ret = validateSSLServerOptions(params);
        if (!ret.isOK()) {
            return ret;
        }
#endif

        return Status::OK();
    }
示例#25
0
    Status validateSSLServerOptions(const moe::Environment& params) {
#ifdef _WIN32
        if (params.count("install") || params.count("reinstall")) {
            if (params.count("net.ssl.PEMKeyFile") &&
                !boost::filesystem::path(params["net.ssl.PEMKeyFile"].as<string>()).is_absolute()) {
                return Status(ErrorCodes::BadValue,
                    "PEMKeyFile requires an absolute file path with Windows services");
            }

            if (params.count("net.ssl.clusterFile") &&
                !boost::filesystem::path(
                    params["net.ssl.clusterFile"].as<string>()).is_absolute()) {
                return Status(ErrorCodes::BadValue,
                    "clusterFile requires an absolute file path with Windows services");
            }

            if (params.count("net.ssl.CAFile") &&
                !boost::filesystem::path(params["net.ssl.CAFile"].as<string>()).is_absolute()) {
                return Status(ErrorCodes::BadValue,
                    "CAFile requires an absolute file path with Windows services");
            }

            if (params.count("net.ssl.CRLFile") &&
                !boost::filesystem::path(params["net.ssl.CRLFile"].as<string>()).is_absolute()) {
                return Status(ErrorCodes::BadValue,
                    "CRLFile requires an absolute file path with Windows services");
            }

        }
#endif

        return Status::OK();
    }
Status storeMessageCompressionOptions(const moe::Environment& params) {
    std::vector<std::string> restrict;
    if (params.count("net.compression.compressors")) {
        auto compressorListStr = params["net.compression.compressors"].as<std::string>();
        if (compressorListStr != kDisabledConfigValue) {
            boost::algorithm::split(restrict, compressorListStr, boost::is_any_of(", "));
        }
    }

    auto& compressorFactory = MessageCompressorRegistry::get();
    compressorFactory.setSupportedCompressors(std::move(restrict));

    return Status::OK();
}
示例#27
0
Status storeMongoStatOptions(const moe::Environment& params,
                             const std::vector<std::string>& args) {
    Status ret = storeGeneralToolOptions(params, args);
    if (!ret.isOK()) {
        return ret;
    }

    if (hasParam("http")) {
        mongoStatGlobalParams.http = true;
        toolGlobalParams.noconnection = true;
    }

    if (hasParam("host") && getParam("host").find(',') != string::npos) {
        toolGlobalParams.noconnection = true;
        mongoStatGlobalParams.many = true;
    }

    if (hasParam("discover")) {
        mongoStatGlobalParams.discover = true;
        mongoStatGlobalParams.many = true;
    }

    mongoStatGlobalParams.showHeaders = !hasParam("noheaders");
    mongoStatGlobalParams.rowCount = getParam("rowcount", 0);
    mongoStatGlobalParams.sleep = getParam("sleep", 1);
    mongoStatGlobalParams.allFields = hasParam("all");

    // Make the default db "admin" if it was not explicitly set
    if (!params.count("db")) {
        toolGlobalParams.db = "admin";
    }

    // end of storage / start of validation

    if (mongoStatGlobalParams.sleep <= 0) {
        return Status(ErrorCodes::BadValue,
                      "Error parsing command line: --sleep must be greater than 0");
    }

    if (mongoStatGlobalParams.rowCount < 0) {
        return Status(ErrorCodes::BadValue,
                      "Error parsing command line: --rowcount (-n) can't be negative");
    }

    return Status::OK();
}
示例#28
0
    Status storeMongoTopOptions(const moe::Environment& params,
                                const std::vector<std::string>& args) {
        Status ret = storeGeneralToolOptions(params, args);
        if (!ret.isOK()) {
            return ret;
        }

        mongoTopGlobalParams.sleep = getParam("sleep", 1);
        mongoTopGlobalParams.useLocks = hasParam("locks");

        // Make the default db "admin" if it was not explicitly set
        if (!params.count("db")) {
            toolGlobalParams.db = "admin";
        }

        return Status::OK();
    }
示例#29
0
    Status storeMongoDumpOptions(const moe::Environment& params,
                                 const std::vector<std::string>& args) {
        Status ret = storeGeneralToolOptions(params, args);
        if (!ret.isOK()) {
            return ret;
        }

        mongoDumpGlobalParams.repair = hasParam("repair");
        if (mongoDumpGlobalParams.repair){
            if (!hasParam("dbpath")) {
                return Status(ErrorCodes::BadValue, "repair mode only works with --dbpath");
            }

            if (!hasParam("db")) {
                return Status(ErrorCodes::BadValue,
                              "repair mode only works on 1 db at a time right now");
            }
        }
        mongoDumpGlobalParams.query = getParam("query");
        mongoDumpGlobalParams.useOplog = hasParam("oplog");
        if (mongoDumpGlobalParams.useOplog) {
            if (hasParam("query") || hasParam("db") || hasParam("collection")) {
                return Status(ErrorCodes::BadValue, "oplog mode is only supported on full dumps");
            }
        }
        mongoDumpGlobalParams.outputDirectory = getParam("out");
        mongoDumpGlobalParams.snapShotQuery = false;
        if (!hasParam("query") && !hasParam("dbpath") && !hasParam("forceTableScan")) {
            mongoDumpGlobalParams.snapShotQuery = true;
        }

        // Make the default db "" if it was not explicitly set
        if (!params.count("db")) {
            toolGlobalParams.db = "";
        }

        if (mongoDumpGlobalParams.outputDirectory == "-") {
            // write output to standard error to avoid mangling output
            // must happen early to avoid sending junk to stdout
            toolGlobalParams.canUseStdout = false;
        }

        return Status::OK();
    }
    Status validateServerOptions(const moe::Environment& params) {
        if (params.count("verbose")) {
            std::string verbosity = params["verbose"].as<std::string>();

            // Skip this for backwards compatibility.  See SERVER-11471.
            if (verbosity != "true") {
                for (std::string::iterator iterator = verbosity.begin();
                    iterator != verbosity.end(); iterator++) {
                    if (*iterator != 'v') {
                        return Status(ErrorCodes::BadValue,
                                      "The \"verbose\" option string cannot contain any characters "
                                      "other than \"v\"");
                    }
                }
            }
        }

        return Status::OK();
    }