Skip to content
Draft

TEST #582

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build/dockerfiles/assembly.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ COPY --from=linux-libc-ubi9-content --chown=0:0 /checode-linux-libc/ubi9 /mnt/ro
RUN mkdir -p /mnt/rootfs/projects && mkdir -p /mnt/rootfs/home/che && mkdir -p /mnt/rootfs/bin/
RUN cat /mnt/rootfs/etc/passwd | sed s#root:x.*#root:x:\${USER_ID}:\${GROUP_ID}::\${HOME}:/bin/bash#g > /mnt/rootfs/home/che/.passwd.template \
&& cat /mnt/rootfs/etc/group | sed s#root:x:0:#root:x:0:0,\${USER_ID}:#g > /mnt/rootfs/home/che/.group.template
RUN for f in "/mnt/rootfs/bin/" "/mnt/rootfs/home/che" "/mnt/rootfs/etc/group" "/mnt/rootfs/projects" ; do\
RUN for f in "/mnt/rootfs/bin/" "/mnt/rootfs/home/che" "/mnt/rootfs/etc/passwd" "/mnt/rootfs/etc/group" "/mnt/rootfs/projects" ; do\
chgrp -R 0 ${f} && \
chmod -R g+rwX ${f}; \
done
RUN chmod -R g-w /mnt/rootfs/etc/passwd

COPY --from=machine-exec --chown=0:0 /go/bin/che-machine-exec /mnt/rootfs/bin/machine-exec
COPY --chmod=755 /build/scripts/*.sh /mnt/rootfs/
Expand Down
8 changes: 8 additions & 0 deletions build/scripts/entrypoint-volume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ get_openssl_version() {
fi
}

# Boilerplate code for arbitrary user support
if ! whoami >/dev/null 2>&1; then
if [ -w /etc/passwd ]; then
echo "${USER_NAME:-user}:x:$(id -u):0:${USER_NAME:-user} user:${HOME}:/bin/bash" >> /etc/passwd
echo "${USER_NAME:-user}:x:$(id -u):" >> /etc/group
fi
fi

# list checode
ls -la /checode/

Expand Down
15 changes: 15 additions & 0 deletions build/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
export USER_ID=$(id -u)
export GROUP_ID=$(id -g)

if ! grep -Fq "${USER_ID}" /etc/passwd; then
# current user is an arbitrary
# user (its uid is not in the
# container /etc/passwd). Let's fix that
cat ${HOME}/.passwd.template | \
sed "s/\${USER_ID}/${USER_ID}/g" | \
sed "s/\${GROUP_ID}/${GROUP_ID}/g" | \
sed "s/\${HOME}/\/che-vscode/g" > /etc/passwd

cat ${HOME}/.group.template | \
sed "s/\${USER_ID}/${USER_ID}/g" | \
sed "s/\${GROUP_ID}/${GROUP_ID}/g" | \
sed "s/\${HOME}/\/che-vscode/g" > /etc/group
fi

if [ -z "$CODE_HOST" ]; then
CODE_HOST="127.0.0.1"
fi
Expand Down