Skip to content

Commit 20236bf

Browse files
committed
Revert "simplify entrypoint for both root and non-root invocation"
This reverts commit eba24b2. Signed-off-by: Travis Cotton <trcotton@lanl.gov>
1 parent 10dc367 commit 20236bf

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ podman run --rm \
1818
--cap-add=SETGID \
1919
--security-opt seccomp=unconfined \
2020
--security-opt label=disable \
21+
--userns=keep-id \
2122
-v /opt/workdir/images/test-rocky-9.5.yaml:/home/builder/config.yaml \
2223
ghcr.io/openchami/image-build:latest \
2324
image-build --config config.yaml --log-level DEBUG

entrypoint.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
# Only su if running as root
5-
if [[ "$(id -u)" == "0" ]]; then
6-
exec su - builder -c "buildah unshare $*"
7-
else
8-
exec buildah unshare "$@"
9-
fi
4+
# Only do this if you really need to override inside-container subuid/gid behavior
5+
# Usually not needed unless you're testing mapping features
6+
if [[ -w /etc/subuid && -w /etc/subgid ]]; then
7+
echo "builder:1001:${USERNS_RANGE:-65536}" > /etc/subuid
8+
echo "builder:1001:${USERNS_RANGE:-65536}" > /etc/subgid
9+
fi
10+
11+
# Make sure builder owns its homedir (optional if baked into image)
12+
chown -R builder /home/builder || true
13+
14+
# Run buildah directly
15+
exec buildah unshare "$@"
16+

0 commit comments

Comments
 (0)