summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristina <kristina@10gen.com>2012-01-12 16:02:19 -0800
committerKristina <kristina@10gen.com>2012-01-12 16:02:19 -0800
commit86e26ee445a85c72d16d2864c2f33e4f6dbaa3fd (patch)
treea3b267e5e4c595eb645ed3c9635f2d40abfcd573
parent3aaea5262d761e0bb6bfef5351cfbfca7af06ec2 (diff)
downloadmongo-86e26ee445a85c72d16d2864c2f33e4f6dbaa3fd.tar.gz
"authenticate" command should not take read lock unless necessary SERVER-4673
-rw-r--r--db/security.cpp7
-rw-r--r--db/security_common.h2
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);