From db779f4e521b276211935cdeb4f623bb2f27ab8b Mon Sep 17 00:00:00 2001 From: Simon Ungar Felding Date: Fri, 6 Dec 2024 12:27:01 +0100 Subject: [PATCH] add (backwards compatible) support for running rootless --- build/Dockerfile | 4 ++++ build/entrypoint.sh | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index b2f01f4..d995d47 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -11,9 +11,13 @@ RUN bash build.sh FROM debian:sid-slim LABEL maintainer="Xiaonan Shen " +# These are only exported if running as root EXPOSE 25/tcp EXPOSE 143/tcp +EXPOSE 1025/tcp +EXPOSE 1143/tcp + # Install dependencies and protonmail bridge RUN apt-get update \ && apt-get install -y --no-install-recommends socat pass libsecret-1-0 ca-certificates \ diff --git a/build/entrypoint.sh b/build/entrypoint.sh index 1931087..330c9e2 100644 --- a/build/entrypoint.sh +++ b/build/entrypoint.sh @@ -23,8 +23,13 @@ else # socat will make the conn appear to come from 127.0.0.1 # ProtonMail Bridge currently expects that. # It also allows us to bind to the real ports :) - socat TCP-LISTEN:25,fork TCP:127.0.0.1:1025 & - socat TCP-LISTEN:143,fork TCP:127.0.0.1:1143 & + if [[ $(id -u) == 0 ]]; then + socat TCP-LISTEN:25,fork TCP:127.0.0.1:1025 & + socat TCP-LISTEN:143,fork TCP:127.0.0.1:1143 & + fi + + socat TCP-LISTEN:1025,fork TCP:127.0.0.1:1025 & + socat TCP-LISTEN:1143,fork TCP:127.0.0.1:1143 & # Start protonmail # Fake a terminal, so it does not quit because of EOF...