Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-11051) Ensure environment variables are not incorrectly munged in the PowerShell Host #128

Merged
merged 3 commits into from
May 11, 2021
Merged

(MODULES-11051) Ensure environment variables are not incorrectly munged in the PowerShell Host #128

merged 3 commits into from
May 11, 2021

Conversation

michaeltlombardi
Copy link
Contributor

This PR refactors the Reset-ProcessEnvironmentVariables function and calling in the PowerShell host init.ps1 script to cache the environment variables when the host is started up by just enumerating them and then using that cached array to reset them inside the host.

This ensures that the value of the environment variable matches those outside of the PowerShell Host instead of using expected inheritance; this resolves the issue where a Process scope environment variable does not match the expected User > Machine inheritance order, as with the TEMP variable under the System user.

This also simplifies the overall code. All existing unit tests continue to pass with this change.

This PR also includes a minor maintenance commit for syntax and style standardization in the init script.

This commit standardizes the code style and syntax used in the
init file for the PowerShell host. It does not change any of
the code functionality, merely its appearance for readability.
This commit refactors the Reset-ProcessEnvironmentVariables function
and calling in the PowerShell host init script to cache the
environment variables when the host is started up by just enumerating
them and then using that cached array to reset them inside the host.

This ensures that the value of the environment variable matches those
outside of the PowerShell Host instead of using expected inheritance;
this resolves the issue where a process scope environment variable does
not match the expected User > Machine inheritance order, as with the
TEMP variable under the System user.

This also simplifies the overall code. All existing unit tests continue
to pass with this change.
@michaeltlombardi michaeltlombardi requested a review from a team as a code owner May 10, 2021 20:26
@DavidS DavidS merged commit 15df463 into puppetlabs:main May 11, 2021
@michaeltlombardi michaeltlombardi deleted the MODULES-11051/main/refactor-pshost-env-reset branch May 24, 2021 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants