From 3ee0a4d91917dd93d2de9426711a9f6a5b982cf5 Mon Sep 17 00:00:00 2001 From: Amirsaman Memaripour Date: Mon, 9 Nov 2020 17:50:00 +0000 Subject: SERVER-52714 Fix the lifetime of ImpersonationSessionGuard in ExecCommandDatabase --- src/mongo/db/service_entry_point_common.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 _scopedMetrics; + boost::optional _impersonationSessionGuard; std::unique_ptr _scoped; }; @@ -1377,7 +1378,7 @@ Future 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); -- cgit v1.2.1