File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed
Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -29,11 +29,10 @@ COPY --from=linux-libc-ubi9-content --chown=0:0 /checode-linux-libc/ubi9 /mnt/ro
2929RUN mkdir -p /mnt/rootfs/projects && mkdir -p /mnt/rootfs/home/che && mkdir -p /mnt/rootfs/bin/
3030RUN 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 \
3131 && cat /mnt/rootfs/etc/group | sed s#root:x:0:#root:x:0:0,\$ {USER_ID}:#g > /mnt/rootfs/home/che/.group.template
32- RUN for f in "/mnt/rootfs/bin/" "/mnt/rootfs/home/che" "/mnt/rootfs/etc/group" "/mnt/rootfs/projects" ; do\
32+ RUN for f in "/mnt/rootfs/bin/" "/mnt/rootfs/home/che" "/mnt/rootfs/etc/passwd" "/mnt/rootfs/etc/ group" "/mnt/rootfs/projects" ; do\
3333 chgrp -R 0 ${f} && \
3434 chmod -R g+rwX ${f}; \
3535 done
36- RUN chmod -R g-w /mnt/rootfs/etc/passwd
3736
3837COPY --from=machine-exec --chown=0:0 /go/bin/che-machine-exec /mnt/rootfs/bin/machine-exec
3938COPY --chmod=755 /build/scripts/*.sh /mnt/rootfs/
Original file line number Diff line number Diff line change @@ -58,6 +58,14 @@ get_openssl_version() {
5858 fi
5959}
6060
61+ # Boilerplate code for arbitrary user support
62+ if ! whoami > /dev/null 2>&1 ; then
63+ if [ -w /etc/passwd ]; then
64+ echo " ${USER_NAME:- user} :x:$( id -u) :0:${USER_NAME:- user} user:${HOME} :/bin/bash" >> /etc/passwd
65+ echo " ${USER_NAME:- user} :x:$( id -u) :" >> /etc/group
66+ fi
67+ fi
68+
6169# list checode
6270ls -la /checode/
6371
Original file line number Diff line number Diff line change 1313export USER_ID=$( id -u)
1414export GROUP_ID=$( id -g)
1515
16+ if ! grep -Fq " ${USER_ID} " /etc/passwd; then
17+ # current user is an arbitrary
18+ # user (its uid is not in the
19+ # container /etc/passwd). Let's fix that
20+ cat ${HOME} /.passwd.template | \
21+ sed " s/\$ {USER_ID}/${USER_ID} /g" | \
22+ sed " s/\$ {GROUP_ID}/${GROUP_ID} /g" | \
23+ sed " s/\$ {HOME}/\/che-vscode/g" > /etc/passwd
24+
25+ cat ${HOME} /.group.template | \
26+ sed " s/\$ {USER_ID}/${USER_ID} /g" | \
27+ sed " s/\$ {GROUP_ID}/${GROUP_ID} /g" | \
28+ sed " s/\$ {HOME}/\/che-vscode/g" > /etc/group
29+ fi
30+
1631if [ -z " $CODE_HOST " ]; then
1732 CODE_HOST=" 127.0.0.1"
1833fi
You can’t perform that action at this time.
0 commit comments