diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-05-23 13:17:22 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-05-28 16:13:48 -0400 |
commit | 0672061deb58aac931912bed68d014247c581968 (patch) | |
tree | 5ef08865cb578ee3f46995809b9ac6c7eb3e13df /src/mongo/db/commands.cpp | |
parent | ee3fb776c7f36d59b593db7e4165b0611a7a503f (diff) | |
download | mongo-0672061deb58aac931912bed68d014247c581968.tar.gz |
SERVER-13961 Pass LockState to DBWrite and DBRead directly
This is part of the changes to move LockState be part of OperationContext
and not retrieved from TLS.
Diffstat (limited to 'src/mongo/db/commands.cpp')
-rw-r--r-- | src/mongo/db/commands.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index 524a7f916de..2d33d022da7 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -255,13 +255,15 @@ namespace mongo { return Status(ErrorCodes::Error(code), errmsg); } - Status Command::checkAuthForCommand(ClientBasic* client, + Status Command::checkAuthForCommand(OperationContext* txn, + ClientBasic* client, const std::string& dbname, const BSONObj& cmdObj) { std::vector<Privilege> privileges; this->addRequiredPrivileges(dbname, cmdObj, &privileges); - if (client->getAuthorizationSession()->isAuthorizedForPrivileges(privileges)) + if (client->getAuthorizationSession()->isAuthorizedForPrivileges(txn, privileges)) { return Status::OK(); + } return Status(ErrorCodes::Unauthorized, "unauthorized"); } @@ -274,7 +276,8 @@ namespace mongo { } } - static Status _checkAuthorizationImpl(Command* c, + static Status _checkAuthorizationImpl(OperationContext* txn, + Command* c, ClientBasic* client, const std::string& dbname, const BSONObj& cmdObj, @@ -285,7 +288,7 @@ namespace mongo { " may only be run against the admin database."); } if (client->getAuthorizationSession()->getAuthorizationManager().isAuthEnabled()) { - Status status = c->checkAuthForCommand(client, dbname, cmdObj); + Status status = c->checkAuthForCommand(txn, client, dbname, cmdObj); if (status == ErrorCodes::Unauthorized) { mmb::Document cmdToLog(cmdObj, mmb::Document::kInPlaceDisabled); c->redactForLogging(&cmdToLog); @@ -307,13 +310,14 @@ namespace mongo { return Status::OK(); } - Status Command::_checkAuthorization(Command* c, + Status Command::_checkAuthorization(OperationContext* txn, + Command* c, ClientBasic* client, const std::string& dbname, const BSONObj& cmdObj, bool fromRepl) { namespace mmb = mutablebson; - Status status = _checkAuthorizationImpl(c, client, dbname, cmdObj, fromRepl); + Status status = _checkAuthorizationImpl(txn, c, client, dbname, cmdObj, fromRepl); if (!status.isOK()) { log() << status << std::endl; } |