* Wrap funcs to flatten and upload env vars with new func prepareEnvVars.
While the wrapped funcs could be combined, keeping them separate
simplifies testing.
* Configure/refactor std and elevated PS to use new funcs to prepare,
upload and dot source env vars.
* Dot sourcing the env vars in this way avoids the need to embed them
directly in the command string. This avoids the need to escape the env
vars to ensure the command string is correctly parsed.
* Characters within the env vars that are special to PS (such as $'s
and backticks) will still need to be escaped to allow them to be
correctly interpreted by PS.
* The std and elevated PS commands now inject env vars into the remote
env via the same mechanism. This ensures consistent behaviour across the
two command types.
Fixes#5471
Revert so that we can merge a different branch that's had more recent work instead
This reverts commit ba518637d4, reversing
changes made to e56849c605.
Previously, the Ansible provisioner would look for the username from the
`USER` environment variable. Unfortunately, this is not always set -
particularly in Docker containers. It's very confusing to understand why
the error is happening.
Switched to using Go's built-in `os/user` package for retrieving the
current username. @rickard-von-essen had done this in 7369841, but
moved away from it in d59844f because, at the time, it wasn't possible
to use that library with cross-compilation. This was fixed in Go in
795e712b72
* Wrap funcs to flatten and upload env vars with new func prepareEnvVars.
While the wrapped funcs could be combined, keeping them separate
simplifies testing.
* Configure/refactor std and elevated PS to use new funcs to prepare,
upload and dot source env vars.
* Dot sourcing the env vars in this way avoids the need to embed them
directly in the command string. This avoids the need to escape the env
vars to ensure the command string is correctly parsed.
* Characters within the env vars that are special to PS (such as $'s
and backticks) will still need to be escaped to allow them to be
correctly interpreted by PS.
* The std and elevated PS commands now inject env vars into the remote
env via the same mechanism. This ensures consistent behaviour across the
two command types.
Fixes#5471