about summary refs log tree commit diff
path: root/src/ci
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2022-08-23 15:10:36 -0700
committerJosh Stone <jistone@redhat.com>2022-08-23 15:10:36 -0700
commit4eb748bf394aacdf96f6cf446cef8d781d3ab8b4 (patch)
tree9314fc668d079de0d75328f79ccdd928aef7d768 /src/ci
parenta1bea1551b8312b6abfbbf7d49bafac2e6ce8ee4 (diff)
downloadrust-4eb748bf394aacdf96f6cf446cef8d781d3ab8b4.tar.gz
rust-4eb748bf394aacdf96f6cf446cef8d781d3ab8b4.zip
Use `--userns=keep-id` when "docker" is really podman
Rootless podman creates a separate user namespace, where an inner
`LOCAL_USER_ID` will map to a different subuid range on the host.
The "keep-id" mode maps the current UID directly into the container.

This makes `src/ci/docker/run.sh` work better for testing container
images on systems running podman, where "docker" is just a shim.
Diffstat (limited to 'src/ci')
-rwxr-xr-xsrc/ci/docker/run.sh11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh
index 93b4f435d4d..69d4916e5a9 100755
--- a/src/ci/docker/run.sh
+++ b/src/ci/docker/run.sh
@@ -213,7 +213,16 @@ else
   args="$args --volume $HOME/.cargo:/cargo"
   args="$args --volume $HOME/rustsrc:$HOME/rustsrc"
   args="$args --volume /tmp/toolstate:/tmp/toolstate"
-  args="$args --env LOCAL_USER_ID=`id -u`"
+
+  id=$(id -u)
+  if [[ "$id" != 0 && "$(docker -v)" =~ ^podman ]]; then
+    # Rootless podman creates a separate user namespace, where an inner
+    # LOCAL_USER_ID will map to a different subuid range on the host.
+    # The "keep-id" mode maps the current UID directly into the container.
+    args="$args --env NO_CHANGE_USER=1 --userns=keep-id"
+  else
+    args="$args --env LOCAL_USER_ID=$id"
+  fi
 fi
 
 if [ "$dev" = "1" ]