close
Skip to content

Preserve environment variables explicitly passed to Context.sudo.#845

Merged
bitprophet merged 1 commit into
pyinvoke:mainfrom
jeamland:sudo-preserve-explicit-env
Mar 18, 2022
Merged

Preserve environment variables explicitly passed to Context.sudo.#845
bitprophet merged 1 commit into
pyinvoke:mainfrom
jeamland:sudo-preserve-explicit-env

Conversation

@jeamland
Copy link
Copy Markdown
Contributor

sudo, by default, will not pass environment variables from the context in which it is invoked to the context in creates to run actual commands in. This is almost certainly the correct thing to do but unfortunately also means that any environment variables that are explicitly passed via the env= kwarg also get removed.

This change adds a --preserve-env= argument to the internal sudo invocation that will ensure that arguments passed via the env= kwarg are presented to the interior command while still ensuring that the rest of the outer environment stays outside.

sudo, by default, will not pass environment variables from the
context in which it is invoked to the context in creates to run
actual commands in. This is almost certainly the correct thing
to do but unfortunately also means that any environment variables
that are explicitly passed via the env= kwarg also get removed.

This change adds a --preserve-env= argument to the internal sudo
invocation that will ensure that arguments passed via the env=
kwarg are presented to the interior command while still ensuring
that the rest of the outer environment stays outside.
bitprophet added a commit that referenced this pull request Mar 18, 2022
@bitprophet bitprophet merged commit bf0d5bd into pyinvoke:main Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants