Skip to content

Commit 48c180d

Browse files
committed
fix: Manually create testssl user and home
BusyBox `adduser` was reading config from `/etc` that unnecessarily populates the home folder with various dot files. Alternative approach is to create the user and home folder manually. This avoids some extra files like the `-` suffixed backup copies from `adduser`.
1 parent 1392987 commit 48c180d

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

Dockerfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ EOF
7070
FROM scratch
7171
ARG INSTALL_ROOT
7272
COPY --link --from=builder ${INSTALL_ROOT} /
73+
RUN <<EOF
74+
# Create user:
75+
echo 'testssl:x:1000:1000::/home/testssl:/bin/bash' >> /etc/passwd
76+
echo 'testssl:x:1000:' >> /etc/group
77+
echo 'testssl:!::0:::::' >> /etc/shadow
7378

74-
# zypper package `busybox-adduser` fails to install with `--installroot`,
75-
# while the `shadow` package is too heavy just to add a user.
76-
#
77-
# Temporarily bind mount the `/bin` dir from another image that already
78-
# has the `adduser` command, and it'll update `/etc/{group,passwd,shadow}` for us:
79-
# Absolute path provided as some base images PATH would use those binaries instead,
80-
# `adduser` varies in supported args, so this should avoid any surprises:
81-
RUN --mount=type=bind,from=busybox:latest,source=/bin,target=/bin <<EOF
82-
/bin/adduser -D -s /bin/bash testssl
83-
/bin/ln -s /home/testssl/testssl.sh /usr/local/bin/
79+
# Create user home with SGID set:
80+
install --mode 2755 --owner testssl --group testssl --directory /home/testssl
81+
82+
# Add relative symlink to point to content that will COPY later:
83+
ln -sr /home/testssl/testssl.sh /usr/local/bin/
8484
EOF
8585

8686
USER testssl

0 commit comments

Comments
 (0)