Skip to content

Commit a4f9e6d

Browse files
committed
Make the container to run with the UID and GID of the user running pattern.sh
This allows us to drop the /root bind mount and it will also show any errors related to paths in the proper folder. E.g. any permission problem of KUBECONFIG files won't be shown as /root/kubeconfig (inside the container) but as the proper path inside the /home folder. Tested on F38, F39, RHEL8.9 and RHEL9.2
1 parent 4ea84d1 commit a4f9e6d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

scripts/pattern-util.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ fi
2525
# $HOME is mounted as itself for any files that are referenced with absolute paths
2626
# $HOME is mounted to /root because the UID in the container is 0 and that's where SSH looks for credentials
2727

28-
# Do not quote the ${KUBECONF_ENV} below, otherwise we will pass '' to podman
29-
# which will be confused
28+
# We do not rely on bash's $UID and $GID because on MacOSX $GID is not set
29+
MYUID=$(id -u)
30+
MYGID=$(id -g)
3031
podman run -it --rm --pull=newer \
3132
--security-opt label=disable \
33+
--user "${MYUID}:${MYGID}" \
34+
--userns "keep-id:uid=${MYUID},gid=${MYGID}" \
3235
-e EXTRA_HELM_OPTS \
3336
-e KUBECONFIG \
3437
-v "${HOME}":"${HOME}" \
3538
-v "${HOME}":/pattern-home \
36-
-v "${HOME}":/root \
3739
-w "$(pwd)" \
3840
"$PATTERN_UTILITY_CONTAINER" \
3941
$@

0 commit comments

Comments
 (0)