summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-08-28 09:19:29 -0400
committerGitHub <noreply@github.com>2020-08-28 09:19:29 -0400
commitcf6d9fe4e66895791418793341c67030fd12c455 (patch)
tree3be6b21d0de72876b139d93a202c7f06c21d7336 /test
parentb1d6ea26ff5dea97be9ac7f65486c3ebdfe80eac (diff)
parent4060b771577356c6966d9af6b92dc5c85c20b84a (diff)
downloadpodman-cf6d9fe4e66895791418793341c67030fd12c455.tar.gz
podman-cf6d9fe4e66895791418793341c67030fd12c455.tar.bz2
podman-cf6d9fe4e66895791418793341c67030fd12c455.zip
Merge pull request #7464 from edsantiago/bats
BATS: fix corner case in --userns=keep-id test
Diffstat (limited to 'test')
-rw-r--r--test/system/030-run.bats15
-rw-r--r--test/system/070-build.bats2
2 files changed, 14 insertions, 3 deletions
diff --git a/test/system/030-run.bats b/test/system/030-run.bats
index 34afd5bae..198c8881d 100644
--- a/test/system/030-run.bats
+++ b/test/system/030-run.bats
@@ -294,11 +294,22 @@ echo $rand | 0 | $rand
run_podman run -d --userns=keep-id $IMAGE sh -c 'while ! test -e /stop; do sleep 0.1; done'
cid="$output"
+ # Assign a UID that is (a) not in our image /etc/passwd and (b) not
+ # the same as that of the user running the test script; this guarantees
+ # that the added passwd entry will be what we expect.
+ #
+ # For GID, we have to use one that already exists in the container. And
+ # unfortunately, 'adduser' requires a string name. We use 999:ping
+ local uid=4242
+ if [[ $uid == $(id -u) ]]; then
+ uid=4343
+ fi
+
gecos="$(random_string 6) $(random_string 8)"
- run_podman exec --user root $cid adduser -D -g "$gecos" -s /bin/sh newuser3
+ run_podman exec --user root $cid adduser -u $uid -G ping -D -g "$gecos" -s /bin/sh newuser3
is "$output" "" "output from adduser"
run_podman exec $cid tail -1 /etc/passwd
- is "$output" "newuser3:x:1000:1000:$gecos:/home/newuser3:/bin/sh" \
+ is "$output" "newuser3:x:$uid:999:$gecos:/home/newuser3:/bin/sh" \
"newuser3 added to /etc/passwd in container"
run_podman exec $cid touch /stop
diff --git a/test/system/070-build.bats b/test/system/070-build.bats
index 0e6e97d40..997699ecb 100644
--- a/test/system/070-build.bats
+++ b/test/system/070-build.bats
@@ -12,7 +12,7 @@ load helpers
rand_content=$(random_string 50)
tmpdir=$PODMAN_TMPDIR/build-test
- run mkdir -p $tmpdir || die "Could not mkdir $tmpdir"
+ mkdir -p $tmpdir
dockerfile=$tmpdir/Dockerfile
cat >$dockerfile <<EOF
FROM $IMAGE