Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bbae4a5

Browse files
committedOct 22, 2020
release-image: Remap UID within the image before handling $DOCKER_USER
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 bbae4a5

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)
Please sign in to comment.