Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ownership on /captures #37

Merged
merged 1 commit into from
May 4, 2024
Merged
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ RUN apt update \
&& apt install -y git libglib2.0-0 speex libspeex1 libspeexdsp1 libc-ares2 libxml2 \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /captures /usr/local/bin /usr/local/share/wireshark/
RUN mkdir -p /captures /usr/local/bin /usr/local/share/wireshark/ \
&& chown -R node: /captures

COPY --from=intermediate /usr/src/wireshark/build/run/sharkd /usr/local/bin/sharkd
COPY --from=intermediate /usr/src/wireshark/build/run/colorfilters /usr/local/share/wireshark/colorfilters
Expand All @@ -39,7 +40,6 @@ ENV SHARKD_SOCKET=/captures/sharkd.sock
COPY --chown=node . /usr/src/node-webshark
COPY --from=intermediate /usr/src/web /usr/src/node-webshark/web

USER node
VOLUME /captures

WORKDIR /usr/src/node-webshark/api
Expand Down
10 changes: 9 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@
# sharkd daemon fails to start if the socket already exists
rm "$SHARKD_SOCKET"

exec npm start
dir_owner=$(stat -c "%U:%G" "${CAPTURES_PATH}")

if [ "x${dir_owner}" = "xroot:root" ]; then
# assume CAPTURES_PATH owned by root:root is unintentional
# (probably created by docker-compose)
chown node: "${CAPTURES_PATH}"
fi

exec su node -c "npm start"