Skip to content

Commit

Permalink
SERVER-9983 Do not needlessly lock when looking up privileges for the…
Browse files Browse the repository at this point in the history
… __system@local user.

Uncorrected, this can cause replica set heartbeats to stall behind operations
that hold the read lock for a long time.
  • Loading branch information
Andy Schwerin committed Jun 21, 2013
1 parent d2b8eab commit 23344f8
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/mongo/db/auth/authorization_manager.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -394,9 +394,21 @@ namespace {
_authenticatedPrincipals.add(principal); _authenticatedPrincipals.add(principal);
if (!principal->isImplicitPrivilegeAcquisitionEnabled()) if (!principal->isImplicitPrivilegeAcquisitionEnabled())
return; return;

const std::string dbname = principal->getName().getDB().toString();
if (dbname == StringData("local", StringData::LiteralTag()) &&
principal->getName().getUser() == internalSecurity.user) {

// Grant full access to internal user
ActionSet allActions;
allActions.addAllActions();
acquirePrivilege(Privilege(PrivilegeSet::WILDCARD_RESOURCE, allActions),
principal->getName());
return;
}

_acquirePrivilegesForPrincipalFromDatabase(ADMIN_DBNAME, principal->getName()); _acquirePrivilegesForPrincipalFromDatabase(ADMIN_DBNAME, principal->getName());
principal->markDatabaseAsProbed(ADMIN_DBNAME); principal->markDatabaseAsProbed(ADMIN_DBNAME);
const std::string dbname = principal->getName().getDB().toString();
_acquirePrivilegesForPrincipalFromDatabase(dbname, principal->getName()); _acquirePrivilegesForPrincipalFromDatabase(dbname, principal->getName());
principal->markDatabaseAsProbed(dbname); principal->markDatabaseAsProbed(dbname);
} }
Expand Down Expand Up @@ -491,13 +503,6 @@ namespace {
<< principal.getDB(), << principal.getDB(),
0); 0);
} }
if (principal.getUser() == internalSecurity.user) {
// Grant full access to internal user
ActionSet allActions;
allActions.addAllActions();
return acquirePrivilege(Privilege(PrivilegeSet::WILDCARD_RESOURCE, allActions),
principal);
}
return buildPrivilegeSet(dbname, principal, privilegeDocument, &_acquiredPrivileges); return buildPrivilegeSet(dbname, principal, privilegeDocument, &_acquiredPrivileges);
} }


Expand Down

0 comments on commit 23344f8

Please sign in to comment.