virgl/ci: make crosvm-runner pass variables in a secure way
authorGuilherme Gallo <guilherme.gallo@collabora.com>
Fri, 14 Jan 2022 21:43:08 +0000 (18:43 -0300)
committerMarge Bot <emma+marge@anholt.net>
Thu, 27 Jan 2022 18:28:48 +0000 (18:28 +0000)
commit2d75fd1e0ac06c65d83e053c58bf266732db3de4
tree180946e5777adb8b89aac735f486efd1aeec65d1
parent7380d8e285f76b6d5273a8cc272eb0f1bfcb6c0a
virgl/ci: make crosvm-runner pass variables in a secure way

crosvm-runner.sh was using `export -p` to create an environment script
for the virtualized system, but this command will dump every declared
environment variable in the system, which includes Gitlab's CI variables
with sensitive data, such as passwords and auth tokens.

Replacing `export -p` to `generate-env.sh`, which only exports the
necessary variables for Mesa CI jobs.

Extra changes:

* Stop changing ${PWD} variable programmatically in scripts. ${PWD} is a
variable used by most prolific coreutils and bash commands, such as `cd`
and `pwd`, besides it is set by subshells [1]; changing this variable
may lead to complex situations.
As drop-in replacement for ${PWD}, use ${DEQP_BIN_DIR} to flag that
there is a special folder where dEQP should be run.
* Double quote path and array variables. See: https://github.com/koalaman/shellcheck/wiki/SC2086
* Do not export variables directly from commands output. See: https://github.com/koalaman/shellcheck/wiki/SC2155

[1]
```
$ cd /tmp
$ export PWD=test; bash -c 'echo $PWD'
/tmp
```

v2:
- Revert $DEQP_BIN_DIR quoting in crosvm-runner.sh and crosvm-init.sh
- Log all the passed variables to stdout, to help with debugging when
  new variable are needed to be put in `generate-env.sh`

v3:
- Revert $DEQP_BIN_DIR quoting leftovers

Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com>
Reviewed-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14626>
.gitlab-ci/common/generate-env.sh
.gitlab-ci/crosvm-init.sh
.gitlab-ci/crosvm-runner.sh