diff options
-rw-r--r-- | db/security.cpp | 7 | ||||
-rw-r--r-- | db/security_common.h | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/db/security.cpp b/db/security.cpp index ae1477002a7..05165cb689e 100644 --- a/db/security.cpp +++ b/db/security.cpp @@ -83,6 +83,9 @@ namespace mongo { string systemUsers = dbname + ".system.users"; // OCCASIONALLY Helpers::ensureIndex(systemUsers.c_str(), userPattern, false, "user_1"); { + mongolock lk(false); + Client::Context c(systemUsers, dbpath, &lk, false); + BSONObjBuilder b; b << "user" << user; BSONObj query = b.done(); @@ -101,10 +104,10 @@ namespace mongo { AuthenticationInfo *ai = cc().getAuthenticationInfo(); if ( readOnly ) { - ai->authorizeReadOnly( cc().database()->name.c_str() , user ); + ai->authorizeReadOnly( dbname.c_str() , user ); } else { - ai->authorize( cc().database()->name.c_str() , user ); + ai->authorize( dbname.c_str() , user ); } } diff --git a/db/security_common.h b/db/security_common.h index 2f2565f3ce0..c9a3e3a8933 100644 --- a/db/security_common.h +++ b/db/security_common.h @@ -57,7 +57,7 @@ namespace mongo { virtual bool slaveOk() const { return true; } - virtual LockType locktype() const { return READ; } + virtual LockType locktype() const { return NONE; } virtual void help(stringstream& ss) const { ss << "internal"; } CmdAuthenticate() : Command("authenticate") {} bool run(const string& dbname , BSONObj& cmdObj, int options, string& errmsg, BSONObjBuilder& result, bool fromRepl); |