Skip to content

Commit

Permalink
Fix environment block creation (#7401)
Browse files Browse the repository at this point in the history
This fixes a regression in environment variable loading introduced as part
of the new environment block creation that prevents some system-defined,
volatile environment variables from being defined.

## References
#7243 (comment)

## Validation Steps Performed
Manually verified locally.

Closes #7399

(cherry picked from commit 64f10a0)
  • Loading branch information
nathpete-msft authored and DHowett committed Aug 25, 2020
1 parent 7967e17 commit 7886f16
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/types/Environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "precomp.h"
#include "inc/Environment.hpp"
#include "wil/token_helpers.h"

using namespace ::Microsoft::Console::Utils;

Expand All @@ -14,7 +15,8 @@ using namespace ::Microsoft::Console::Utils;
EnvironmentBlockPtr Microsoft::Console::Utils::CreateEnvironmentBlock()
{
void* newEnvironmentBlock{ nullptr };
if (!::CreateEnvironmentBlock(&newEnvironmentBlock, GetCurrentProcessToken(), FALSE))
auto processToken{ wil::open_current_access_token(TOKEN_QUERY | TOKEN_DUPLICATE) };
if (!::CreateEnvironmentBlock(&newEnvironmentBlock, processToken.get(), FALSE))
{
return nullptr;
}
Expand Down

0 comments on commit 7886f16

Please sign in to comment.