Permalink
Browse files

"authenticate" command should not take read lock unless necessary SER…

…VER-4673
  • Loading branch information...
1 parent 3aaea52 commit 86e26ee445a85c72d16d2864c2f33e4f6dbaa3fd @kchodorow kchodorow committed Jan 13, 2012
Showing with 6 additions and 3 deletions.
  1. +5 −2 db/security.cpp
  2. +1 −1 db/security_common.h
View
@@ -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 );
}
}
View
@@ -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);

0 comments on commit 86e26ee

Please sign in to comment.