Make tools fail if they connect to a db requiring authentication but don't

supply any credentials: SERVER-2867
This commit is contained in:
Spencer T Brody
2011-07-12 16:07:23 -04:00
parent bcf0b72b4a
commit 3da3871e65

View File

@@ -380,8 +380,12 @@ namespace mongo {
if ( ! dbname.size() )
dbname = _db;
if ( ! ( _username.size() || _password.size() ) )
if ( ! ( _username.size() || _password.size() ) ) {
// Make sure that we don't need authentication to connect to this db
// findOne throws an AssertionException if it's not authenticated.
conn().findOne(getNS(), Query("{}"));
return;
}
string errmsg;
if ( _conn->auth( dbname , _username , _password , errmsg ) )