Build ping and su standalone
This allows the binaries to be set SUID so they can be run by unprivileged users
This commit is contained in:
parent
196dce995d
commit
6eb5c1e704
23
Dockerfile
23
Dockerfile
@ -72,8 +72,25 @@ WORKDIR /tmp/busybox
|
|||||||
# Download and build busybox from source
|
# Download and build busybox from source
|
||||||
RUN curl -fL https://busybox.net/downloads/busybox-${BUSYB_VER}.tar.bz2 \
|
RUN curl -fL https://busybox.net/downloads/busybox-${BUSYB_VER}.tar.bz2 \
|
||||||
| tar xj --strip-components=1 && \
|
| tar xj --strip-components=1 && \
|
||||||
|
# Use minimal configuration for standalone applets
|
||||||
|
make allnoconfig && \
|
||||||
|
sed -i -e 's/# CONFIG_PING is not set/CONFIG_PING=y/' \
|
||||||
|
-e 's/# CONFIG_FEATURE_FANCY_PING is not set/CONFIG_FEATURE_FANCY_PING=y/' \
|
||||||
|
-e 's/# CONFIG_SU is not set/CONFIG_SU=y/' \
|
||||||
|
.config && \
|
||||||
|
# Build ping and su
|
||||||
|
./make_single_applets.sh && \
|
||||||
|
cp busybox_PING "${PREFIX}/bin/ping" && \
|
||||||
|
cp busybox_SU "${PREFIX}/bin/su" && \
|
||||||
|
\
|
||||||
# Use default configuration
|
# Use default configuration
|
||||||
make defconfig && \
|
make defconfig && \
|
||||||
|
# Disable `busybox --install` function
|
||||||
|
sed -i -e 's/CONFIG_INSTALLER=y/# CONFIG_INSTALLER is not set/' \
|
||||||
|
-e 's/CONFIG_PING=y/# CONFIG_PING is not set/' \
|
||||||
|
-e 's/CONFIG_SU=y/# CONFIG_SU is not set/' \
|
||||||
|
.config && \
|
||||||
|
\
|
||||||
make -j "$(nproc)" && \
|
make -j "$(nproc)" && \
|
||||||
cp busybox "${PREFIX}/bin" && \
|
cp busybox "${PREFIX}/bin" && \
|
||||||
# "Install" busybox, creating symlinks to all binaries it provides
|
# "Install" busybox, creating symlinks to all binaries it provides
|
||||||
@ -112,7 +129,9 @@ RUN ${PREFIX}/sbin/ldconfig -r ${PREFIX} && \
|
|||||||
# Add default skeleton configuration files
|
# Add default skeleton configuration files
|
||||||
COPY skel/ .
|
COPY skel/ .
|
||||||
RUN install -dm 1777 tmp && \
|
RUN install -dm 1777 tmp && \
|
||||||
chroot . chmod 775 usr/bin/* sbin/*
|
chroot . chmod 755 usr/bin/* sbin/* && \
|
||||||
|
# Ensure ping and su have correct permissions
|
||||||
|
chroot . chmod 4755 usr/bin/ping usr/bin/su
|
||||||
|
|
||||||
# =============
|
# =============
|
||||||
|
|
||||||
@ -139,6 +158,8 @@ WORKDIR /
|
|||||||
SHELL ["/bin/sh", "-exc"]
|
SHELL ["/bin/sh", "-exc"]
|
||||||
|
|
||||||
COPY --from=builder /output/ /
|
COPY --from=builder /output/ /
|
||||||
|
# Workaround for Docker bug (not retaining setuid bit)
|
||||||
|
RUN chmod 4755 usr/bin/ping usr/bin/su
|
||||||
|
|
||||||
ENV ENV="/etc/profile"
|
ENV ENV="/etc/profile"
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
|
||||||
|
Loading…
Reference in New Issue
Block a user