summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmirsaman Memaripour <amirsaman.memaripour@mongodb.com>2020-11-09 17:50:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-09 22:10:08 +0000
commit3ee0a4d91917dd93d2de9426711a9f6a5b982cf5 (patch)
treed25293536462be014bca083bbe9554d7a1061048
parent54364b43839b4b181ed41fb98205f3d7d5831923 (diff)
downloadmongo-3ee0a4d91917dd93d2de9426711a9f6a5b982cf5.tar.gz
SERVER-52714 Fix the lifetime of ImpersonationSessionGuard in ExecCommandDatabase
-rw-r--r--src/mongo/db/service_entry_point_common.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index 2cc05fc5080..ab449e2b9a7 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -664,6 +664,7 @@ private:
LogicalTime _startOperationTime;
OperationSessionInfoFromClient _sessionOptions;
boost::optional<ResourceConsumption::ScopedMetricsCollector> _scopedMetrics;
+ boost::optional<ImpersonationSessionGuard> _impersonationSessionGuard;
std::unique_ptr<PolymorphicScoped> _scoped;
};
@@ -1377,7 +1378,7 @@ Future<void> ExecCommandDatabase::_initiateCommand() try {
"Skipping command execution for help request");
}
- ImpersonationSessionGuard guard(opCtx);
+ _impersonationSessionGuard.emplace(opCtx);
_invocation->checkAuthorization(opCtx, request);
const bool iAmPrimary = replCoord->canAcceptWritesForDatabase_UNSAFE(opCtx, dbname);