All tools (including shell) take -p should allow it to be blank and do password input SERVER-764

This commit is contained in:
Guillaume Delannoy
2010-05-04 10:47:20 -04:00
committed by Eliot Horowitz
parent ed7c6c5516
commit a8aab6f98a
3 changed files with 15 additions and 5 deletions

View File

@@ -30,6 +30,7 @@ jmp_buf jbuf;
#include "../util/unittest.h"
#include "../db/cmdline.h"
#include "utils.h"
#include "../util/password.h"
using namespace std;
using namespace boost::filesystem;
@@ -318,7 +319,8 @@ int _main(int argc, char* argv[]) {
("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", po::value<string>(&password), "password for authentication")
("password,p", new mongo::PasswordValue(&password),
"password for authentication")
("help,h", "show this usage information")
("version", "show version information")
("ipv6", "enable IPv6 support (disabled by default)")
@@ -419,6 +421,11 @@ int _main(int argc, char* argv[]) {
mongo::shellUtils::_dbConnect = ss.str();
if ( params.count( "password" )
&& ( password.empty() ) ) {
password = mongo::askPassword();
}
if ( username.size() && password.size() ){
stringstream ss;
ss << "if ( ! db.auth( \"" << username << "\" , \"" << password << "\" ) ){ throw 'login failed'; }";