From 3da3871e653ba2cfdaa2183da5bbf9fc563e817e Mon Sep 17 00:00:00 2001 From: Spencer T Brody Date: Tue, 12 Jul 2011 16:07:23 -0400 Subject: [PATCH] Make tools fail if they connect to a db requiring authentication but don't supply any credentials: SERVER-2867 --- tools/tool.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/tool.cpp b/tools/tool.cpp index 86e4c8df615..22228e66999 100644 --- a/tools/tool.cpp +++ b/tools/tool.cpp @@ -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 ) )