Skip to content

Commit 0b9d6fa

Browse files
authored
Applies necessary capabilities to scamper binary (#162)
scamper needs numerous capabilities in order to function. This commits applies those capabilities to the scamper binary so that the container processes can run as non-root.
1 parent fb1a150 commit 0b9d6fa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN chmod +x ./configure && \
2828
# Create an image for traceroute-caller and the tools that it calls.
2929
FROM ubuntu:22.04
3030
RUN apt-get update && \
31-
apt-get install -y python3-pip tini && \
31+
apt-get install -y libcap2-bin python3-pip tini && \
3232
apt-get clean && \
3333
rm -rf /var/lib/apt/lists/*
3434
# Create /var/empty to avoid a race condition in scamper that results
@@ -41,6 +41,15 @@ COPY --from=build_caller /go/bin/traceroute-caller /
4141
# Copy the dynamically-linked scamper binary and its associated libraries.
4242
COPY --from=build_tracers /scamper /usr/local
4343

44+
# Give the scamper binary all the needed capabilities so that the container
45+
# processes can run as non-root.
46+
# DAC_OVERRIDE: Could not connect to "/var/local/tcpinfoeventsocket/tcpevents.sock" (error: dial unix /var/local/tcpinfoeventsocket/tcpevents.sock: connect: permission denied)
47+
# SYS_CHROOT: scamper_privsep_init: could not chroot to /var/empty: Operation not permitted
48+
# NET_RAW: to be able to talk ICMP
49+
# SETGID: scamper_privsep_init: could not setgroups: Operation not permitted
50+
# SETUID: scamper_privsep_init: could not setuid: Operation not permitted
51+
RUN setcap cap_dac_override,cap_net_raw,cap_setgid,cap_setuid,cap_sys_chroot=ep /usr/local/bin/scamper
52+
4453
# Install fast-mda-traceroute from PyPI.
4554
# We build pycaracal from source to avoid pulling precompiled binaries.
4655
RUN pip3 install --upgrade pip wheel setuptools

0 commit comments

Comments
 (0)