diff options
author | Shaun Verch <shaun.verch@10gen.com> | 2013-08-17 16:11:06 -0400 |
---|---|---|
committer | Shaun Verch <shaun.verch@10gen.com> | 2013-09-05 13:49:34 -0400 |
commit | 19013c4049d2dc018128c5bf2e63781fb5499b0e (patch) | |
tree | a06b82a7ddec8f23cc4b464c3d1d8802f9e714c1 /src/mongo | |
parent | 3de119ff3e2acd33d54a6190cbaefe38b13366e0 (diff) | |
download | mongo-19013c4049d2dc018128c5bf2e63781fb5499b0e.tar.gz |
SERVER-8510 Remove all uses of boost direct storage and remove custom boost modifications
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/cmdline.cpp | 69 | ||||
-rw-r--r-- | src/mongo/db/db.cpp | 11 | ||||
-rw-r--r-- | src/mongo/dbtests/framework.cpp | 25 | ||||
-rw-r--r-- | src/mongo/shell/dbshell.cpp | 54 | ||||
-rw-r--r-- | src/mongo/tools/tool.cpp | 25 | ||||
-rw-r--r-- | src/mongo/util/password.h | 34 |
6 files changed, 142 insertions, 76 deletions
diff --git a/src/mongo/db/cmdline.cpp b/src/mongo/db/cmdline.cpp index 40db88584de..16e89d4c861 100644 --- a/src/mongo/db/cmdline.cpp +++ b/src/mongo/db/cmdline.cpp @@ -85,8 +85,8 @@ namespace { ("config,f", po::value<string>(), "configuration file specifying additional options") ("verbose,v", "be more verbose (include multiple times for more verbosity e.g. -vvvvv)") ("quiet", "quieter output") - ("port", po::value<int>(&cmdLine.port), portInfoBuilder.str().c_str()) - ("bind_ip", po::value<string>(&cmdLine.bind_ip), "comma separated list of ip addresses to listen on - all local ips by default") + ("port", po::value<int>(), portInfoBuilder.str().c_str()) + ("bind_ip", po::value<string>(), "comma separated list of ip addresses to listen on - all local ips by default") ("maxConns",po::value<int>(), maxConnInfoBuilder.str().c_str()) ("logpath", po::value<string>() , "log file to send write to instead of stdout - has to be a file, not directory" ) ("logappend" , "append to logpath instead of over-writing" ) @@ -97,7 +97,7 @@ namespace { ("setParameter", po::value< std::vector<std::string> >()->composing(), "Set a configurable parameter") ("httpinterface", "enable http interface") - ("clusterAuthMode", po::value<std::string>(&cmdLine.clusterAuthMode), + ("clusterAuthMode", po::value<std::string>(), "Authentication mode used for cluster authentication." " Alternatives are (keyfile|sendKeyfile|sendX509|x509)") #ifndef _WIN32 @@ -112,15 +112,16 @@ namespace { #ifdef MONGO_SSL ssl_options.add_options() ("sslOnNormalPorts" , "use ssl on configured ports" ) - ("sslPEMKeyFile" , po::value<string>(&cmdLine.sslPEMKeyFile), "PEM file for ssl" ) - ("sslPEMKeyPassword" , new PasswordValue(&cmdLine.sslPEMKeyPassword) , "PEM file password" ) - ("sslClusterFile", po::value<string>(&cmdLine.sslClusterFile), + ("sslPEMKeyFile" , po::value<string>(), "PEM file for ssl" ) + ("sslPEMKeyPassword" , po::value<string>()->implicit_value(""), + "PEM file password" ) + ("sslClusterFile", po::value<string>(), "Key file for internal SSL authentication" ) - ("sslClusterPassword", new PasswordValue(&cmdLine.sslClusterPassword), + ("sslClusterPassword", po::value<string>()->implicit_value(""), "Internal authentication key file password" ) - ("sslCAFile", po::value<std::string>(&cmdLine.sslCAFile), + ("sslCAFile", po::value<std::string>(), "Certificate Authority file for SSL") - ("sslCRLFile", po::value<std::string>(&cmdLine.sslCRLFile), + ("sslCRLFile", po::value<std::string>(), "Certificate Revocation List file for SSL") ("sslWeakCertificateValidation", "allow client to connect without presenting a certificate") ("sslFIPSMode", "activate FIPS 140-2 mode at startup") @@ -133,9 +134,9 @@ namespace { ("objcheck", "inspect client data for validity on receipt (DEFAULT)") ("noobjcheck", "do NOT inspect client data for validity on receipt") ("traceExceptions", "log stack traces for every exception") - ("enableExperimentalIndexStatsCmd", po::bool_switch(&cmdLine.experimental.indexStatsCmdEnabled), + ("enableExperimentalIndexStatsCmd", po::bool_switch(), "EXPERIMENTAL (UNSUPPORTED). Enable command computing aggregate statistics on indexes.") - ("enableExperimentalStorageDetailsCmd", po::bool_switch(&cmdLine.experimental.storageDetailsCmdEnabled), + ("enableExperimentalStorageDetailsCmd", po::bool_switch(), "EXPERIMENTAL (UNSUPPORTED). Enable command computing aggregate statistics on storage.") ; } @@ -254,8 +255,6 @@ namespace { po::store( po::parse_config_file( ss , all ) , params ); f.close(); } - - po::notify(params); } catch (po::error &e) { cout << "error command line: " << e.what() << endl; @@ -326,6 +325,25 @@ namespace { } } + if (params.count("enableExperimentalIndexStatsCmd")) { + cmdLine.experimental.indexStatsCmdEnabled = true; + } + if (params.count("enableExperimentalStorageDetailsCmd")) { + cmdLine.experimental.storageDetailsCmdEnabled = true; + } + + if (params.count("port")) { + cmdLine.port = params["port"].as<int>(); + } + + if (params.count("bind_ip")) { + cmdLine.bind_ip = params["bind_ip"].as<std::string>(); + } + + if (params.count("clusterAuthMode")) { + cmdLine.clusterAuthMode = params["clusterAuthMode"].as<std::string>(); + } + if (params.count("quiet")) { cmdLine.quiet = true; } @@ -458,6 +476,31 @@ namespace { } #ifdef MONGO_SSL + + if (params.count("sslPEMKeyFile")) { + cmdLine.sslPEMKeyFile = params["sslPEMKeyFile"].as<string>(); + } + + if (params.count("sslPEMKeyPassword")) { + cmdLine.sslPEMKeyPassword = params["sslPEMKeyPassword"].as<string>(); + } + + if (params.count("sslClusterFile")) { + cmdLine.sslClusterFile = params["sslClusterFile"].as<string>(); + } + + if (params.count("sslClusterPassword")) { + cmdLine.sslClusterPassword = params["sslClusterPassword"].as<string>(); + } + + if (params.count("sslCAFile")) { + cmdLine.sslCAFile = params["sslCAFile"].as<std::string>(); + } + + if (params.count("sslCRLFile")) { + cmdLine.sslCRLFile = params["sslCRLFile"].as<std::string>(); + } + if (params.count("sslWeakCertificateValidation")) { cmdLine.sslWeakCertificateValidation = true; } diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 938ac920e9c..b3f11d5b7dc 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -860,9 +860,9 @@ static void buildOptionsDescriptions(po::options_description *pVisible, #if defined(__linux__) ("shutdown", "kill a running server (for init scripts)") #endif - ("slowms",po::value<int>(&cmdLine.slowMS)->default_value(100), "value of slow for profile and console log" ) + ("slowms",po::value<int>()->default_value(100), "value of slow for profile and console log" ) ("smallfiles", "use a smaller default file size") - ("syncdelay",po::value<double>(&cmdLine.syncdelay)->default_value(60), "seconds between disk syncs (0=never, but not recommended)") + ("syncdelay",po::value<double>()->default_value(60), "seconds between disk syncs (0=never, but not recommended)") ("sysinfo", "print some diagnostic system information") ("upgrade", "upgrade db if needed") ; @@ -979,6 +979,13 @@ static void processCommandLineOptions(const std::vector<std::string>& argv) { dbpath = dbpath.erase(dbpath.size()-1); } #endif + if ( params.count("slowms")) { + cmdLine.slowMS = params["slowms"].as<int>(); + } + + if ( params.count("syncdelay")) { + cmdLine.syncdelay = params["syncdelay"].as<double>(); + } if ( params.count("directoryperdb")) { directoryperdb = true; diff --git a/src/mongo/dbtests/framework.cpp b/src/mongo/dbtests/framework.cpp index 4a5a3afe0af..e66b72fd0b1 100644 --- a/src/mongo/dbtests/framework.cpp +++ b/src/mongo/dbtests/framework.cpp @@ -108,7 +108,7 @@ namespace mongo { shell_options.add_options() ("help,h", "show this usage information") - ("dbpath", po::value<string>(&dbpathSpec)->default_value(default_dbpath), + ("dbpath", po::value<string>()->default_value(default_dbpath), "db data path for this test run. NOTE: the contents of this " "directory will be overwritten if it already exists") ("debug", "run tests with verbose output") @@ -119,9 +119,9 @@ namespace mongo { ("useNewQueryFramework", "use the new query framework") ("dur", "enable journaling (currently the default)") ("nodur", "disable journaling") - ("seed", po::value<unsigned long long>(&seed), "random number seed") - ("runs", po::value<int>(&runsPerTest), "number of times to run each test") - ("perfHist", po::value<unsigned>(&perfHist), "number of back runs of perf stats to display") + ("seed", po::value<unsigned long long>(), "random number seed") + ("runs", po::value<int>(), "number of times to run each test") + ("perfHist", po::value<unsigned>(), "number of back runs of perf stats to display") ; hidden_options.add_options() @@ -143,7 +143,6 @@ namespace mongo { po::store(po::command_line_parser(argc, argv).options(cmdline_options). positional(positional_options). style(command_line_style).run(), params); - po::notify(params); } catch (po::error &e) { cout << "ERROR: " << e.what() << endl << endl; @@ -160,6 +159,22 @@ namespace mongo { mongo::enableNewQueryFramework(); } + if (params.count("dbpath")) { + dbpathSpec = params["dbpath"].as<string>(); + } + + if (params.count("seed")) { + seed = params["seed"].as<unsigned long long>(); + } + + if (params.count("runs")) { + runsPerTest = params["runs"].as<int>(); + } + + if (params.count("perfHist")) { + perfHist = params["perfHist"].as<unsigned>(); + } + bool nodur = false; if( params.count("nodur") ) { nodur = true; diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp index b16b4085bd3..8f964ec5a95 100644 --- a/src/mongo/shell/dbshell.cpp +++ b/src/mongo/shell/dbshell.cpp @@ -700,16 +700,17 @@ int _main( int argc, char* argv[], char **envp ) { ( "nodb", "don't connect to mongod on startup - no 'db address' arg expected" ) ( "norc", "will not run the \".mongorc.js\" file on start up" ) ( "quiet", "be less chatty" ) - ( "port", po::value<string>( &port ), "port to connect to" ) - ( "host", po::value<string>( &dbhost ), "server to connect to" ) - ( "eval", po::value<string>( &script ), "evaluate javascript" ) - ( "username,u", po::value<string>(&username), "username for authentication" ) - ( "password,p", new mongo::PasswordValue( &password ), "password for authentication" ) + ( "port", po::value<string>(), "port to connect to" ) + ( "host", po::value<string>(), "server to connect to" ) + ( "eval", po::value<string>(), "evaluate javascript" ) + ( "username,u", po::value<string>(), "username for authentication" ) + ( "password,p", po::value<string>()->implicit_value(""), + "password for authentication" ) ("authenticationDatabase", - po::value<string>(&authenticationDatabase)->default_value(""), + po::value<string>()->default_value(""), "user source (defaults to dbname)" ) ("authenticationMechanism", - po::value<string>(&authenticationMechanism)->default_value("MONGODB-CR"), + po::value<string>()->default_value("MONGODB-CR"), "authentication mechanism") ( "help,h", "show this usage information" ) ( "version", "show version information" ) @@ -717,12 +718,10 @@ int _main( int argc, char* argv[], char **envp ) { ( "ipv6", "enable IPv6 support (disabled by default)" ) #ifdef MONGO_SSL ( "ssl", "use SSL for all connections" ) - ( "sslCAFile", po::value<std::string>(&sslCAFile), "Certificate Authority for SSL" ) - ( "sslPEMKeyFile", po::value<std::string>(&sslPEMKeyFile), "PEM certificate/key file for SSL" ) - ( "sslPEMKeyPassword", po::value<std::string>(&sslPEMKeyFile), - "password for key in PEM file for SSL" ) - ( "sslCRLFile", po::value<std::string>(&sslCRLFile), - "Certificate Revocation List file for SSL") + ( "sslCAFile", po::value<std::string>(), "Certificate Authority for SSL" ) + ( "sslPEMKeyFile", po::value<std::string>(), "PEM certificate/key file for SSL" ) + ( "sslPEMKeyPassword", po::value<std::string>(), "password for key in PEM file for SSL" ) + ( "sslCRLFile", po::value<std::string>(), "Certificate Revocation List file for SSL") ( "sslFIPSMode", "activate FIPS 140-2 mode at startup") #endif ; @@ -752,7 +751,6 @@ int _main( int argc, char* argv[], char **envp ) { po::store(po::command_line_parser(argc, argv).options(cmdline_options). positional(positional_options). style(command_line_style).run(), params); - po::notify( params ); } catch ( po::error &e ) { cout << "ERROR: " << e.what() << endl << endl; @@ -760,6 +758,34 @@ int _main( int argc, char* argv[], char **envp ) { return mongo::EXIT_BADOPTIONS; } + if (params.count("port")) { + port = params["port"].as<string>(); + } + + if (params.count("host")) { + dbhost = params["host"].as<string>(); + } + + if (params.count("eval")) { + script = params["eval"].as<string>(); + } + + if (params.count("username,u")) { + username = params["username,u"].as<string>(); + } + + if (params.count("password,p")) { + password = params["password,p"].as<string>(); + } + + if (params.count("authenticationDatabase")) { + authenticationDatabase = params["authenticationDatabase"].as<string>(); + } + + if (params.count("authenticationMechanism")) { + authenticationMechanism = params["authenticationMechanism"].as<string>(); + } + // hide password from ps output for ( int i = 0; i < (argc-1); ++i ) { if ( !strcmp(argv[i], "-p") || !strcmp( argv[i], "--password" ) ) { diff --git a/src/mongo/tools/tool.cpp b/src/mongo/tools/tool.cpp index 858f67d81b5..8a67ba50d91 100644 --- a/src/mongo/tools/tool.cpp +++ b/src/mongo/tools/tool.cpp @@ -71,12 +71,12 @@ namespace mongo { #endif ("username,u",po::value<string>(), "username" ) - ("password,p", new PasswordValue( &_password ), "password" ) + ("password,p",po::value<string>()->implicit_value(""), "password" ) ("authenticationDatabase", - po::value<string>(&_authenticationDatabase)->default_value(""), + po::value<string>()->default_value(""), "user source (defaults to dbname)" ) ("authenticationMechanism", - po::value<string>(&_authenticationMechanism)->default_value("MONGODB-CR"), + po::value<string>()->default_value("MONGODB-CR"), "authentication mechanism") ; @@ -149,8 +149,6 @@ namespace mongo { options(all_options). positional( _positonalOptions ). style(command_line_style).run() , _params ); - - po::notify( _params ); } catch (po::error &e) { cerr << "ERROR: " << e.what() << endl << endl; @@ -158,6 +156,15 @@ namespace mongo { ::_exit(EXIT_BADOPTIONS); } + // Set authentication parameters + if ( _params.count( "authenticationDatabase" ) ) { + _authenticationDatabase = _params["authenticationDatabase"].as<string>(); + } + + if ( _params.count( "authenticationMechanism" ) ) { + _authenticationMechanism = _params["authenticationMechanism"].as<string>(); + } + // hide password from ps output for (int i=0; i < (argc-1); ++i) { if (!strcmp(argv[i], "-p") || !strcmp(argv[i], "--password")) { @@ -207,9 +214,11 @@ namespace mongo { if ( _params.count( "username" ) ) _username = _params["username"].as<string>(); - if ( _params.count( "password" ) - && ( _password.empty() ) ) { - _password = askPassword(); + if ( _params.count( "password" ) ) { + _password = _params["password"].as<string>(); + if ( _password.empty() ) { + _password = askPassword(); + } } if (_params.count("ipv6")) diff --git a/src/mongo/util/password.h b/src/mongo/util/password.h index 519f712ee7e..2712f26ac2e 100644 --- a/src/mongo/util/password.h +++ b/src/mongo/util/password.h @@ -22,40 +22,6 @@ namespace mongo { - struct PasswordValue : public boost::program_options::typed_value<std::string> { - - PasswordValue( std::string* val ) - : boost::program_options::typed_value<std::string>( val ) { } - - unsigned min_tokens() const { - return 0; - } - - unsigned max_tokens() const { - return 1; - } - - bool is_required() const { - return false; - } - - void xparse( boost::any& value_store, - const std::vector<std::string>& new_tokens ) const { - if ( !value_store.empty() ) -#if BOOST_VERSION >= 104200 - boost::throw_exception( boost::program_options::validation_error( boost::program_options::validation_error::multiple_values_not_allowed ) ); -#else - boost::throw_exception( boost::program_options::validation_error( "multiple values not allowed" ) ); -#endif - else if ( !new_tokens.empty() ) - boost::program_options::typed_value<std::string>::xparse - (value_store, new_tokens); - else - value_store = std::string(); - } - - }; - std::string askPassword(); } |