summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-10-26 12:16:21 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-11-15 15:10:12 -0500
commit44d1618dd7eeb2560571b14ba5cece69a93dcaff (patch)
treefc84a330a86dcabb48f8d27754ffd679558364cb /test
parent230f0b622e391b78626f150471fce5c198048ed8 (diff)
downloadpodman-44d1618dd7eeb2560571b14ba5cece69a93dcaff.tar.gz
podman-44d1618dd7eeb2560571b14ba5cece69a93dcaff.tar.bz2
podman-44d1618dd7eeb2560571b14ba5cece69a93dcaff.zip
Add --unsetenv & --unsetenv-all to remove def environment variables
Podman adds a few environment variables by default, and currently there is no way to get rid of them from your container. This option will allow you to specify which defaults you don't want. --unsetenv-all will remove all default environment variables. Default environment variables can come from podman builtin, containers.conf or from the container image. Fixes: https://github.com/containers/podman/issues/11836 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/system/030-run.bats22
-rw-r--r--test/system/250-systemd.bats8
2 files changed, 28 insertions, 2 deletions
diff --git a/test/system/030-run.bats b/test/system/030-run.bats
index 2c8d08b99..ba21cd21d 100644
--- a/test/system/030-run.bats
+++ b/test/system/030-run.bats
@@ -736,4 +736,26 @@ EOF
is "$output" "$random_1" "output matches STDIN"
}
+@test "podman run defaultenv" {
+ run_podman run --rm $IMAGE printenv
+ is "$output" ".*TERM=xterm" "output matches TERM"
+ is "$output" ".*container=podman" "output matches container=podman"
+
+ run_podman run --unsetenv=TERM --rm $IMAGE printenv
+ is "$output" ".*container=podman" "output matches container=podman"
+ run grep TERM <<<$output
+ is "$output" "" "unwanted TERM environment variable despite --unsetenv=TERM"
+
+ run_podman run --unsetenv-all --rm $IMAGE /bin/printenv
+ run grep TERM <<<$output
+ is "$output" "" "unwanted TERM environment variable despite --unsetenv-all"
+ run grep container <<<$output
+ is "$output" "" "unwanted container environment variable despite --unsetenv-all"
+ run grep PATH <<<$output
+ is "$output" "" "unwanted PATH environment variable despite --unsetenv-all"
+
+ run_podman run --unsetenv-all --env TERM=abc --rm $IMAGE /bin/printenv
+ is "$output" ".*TERM=abc" "missing TERM environment variable despite TERM being set on commandline"
+}
+
# vim: filetype=sh
diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats
index 1c778a5e3..e997ab6f9 100644
--- a/test/system/250-systemd.bats
+++ b/test/system/250-systemd.bats
@@ -174,10 +174,14 @@ function check_listen_env() {
if is_remote; then
is "$output" "$stdenv" "LISTEN Environment did not pass: $context"
else
- is "$output" "$stdenv
+ out=$(for o in $output; do echo $o; done| sort)
+ std=$(echo "$stdenv
LISTEN_PID=1
LISTEN_FDS=1
-LISTEN_FDNAMES=listen_fdnames" "LISTEN Environment passed: $context"
+LISTEN_FDNAMES=listen_fdnames" | sort)
+ echo "<$out>"
+ echo "<$std>"
+ is "$out" "$std" "LISTEN Environment passed: $context"
fi
}