Skip to content

Commit 79443c1

Browse files
authored
release-image: Remap UID within the image before handling $DOCKER_USER (#2223)
If do not update the UID within the passwd database to match whatever uid the container is being ran as, then sudo will not work when renaming the user to match $DOCKER_USER as it will complain about the current user being non-existent.
1 parent 7093f99 commit 79443c1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ci/release-image/entrypoint.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/bin/sh
22
set -eu
33

4-
if [ "${DOCKER_USER-}" ] && [ "$DOCKER_USER" != "$USER" ]; then
4+
# We do this first to ensure sudo works below when renaming the user.
5+
# Otherwise the current container UID may not exist in the passwd database.
6+
eval "$(fixuid -q)"
7+
8+
if [ "${DOCKER_USER-}" ]; then
59
echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
610
# Unfortunately we cannot change $HOME as we cannot move any bind mounts
711
# nor can we bind mount $HOME into a new home as that requires a privileged container.
@@ -11,7 +15,6 @@ if [ "${DOCKER_USER-}" ] && [ "$DOCKER_USER" != "$USER" ]; then
1115
USER="$DOCKER_USER"
1216

1317
sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
14-
sudo sed -i "s/coder/$DOCKER_USER/g" /etc/fixuid/config.yml
1518
fi
1619

17-
dumb-init fixuid -q /usr/bin/code-server "$@"
20+
dumb-init /usr/bin/code-server "$@"

0 commit comments

Comments
 (0)