ADD: run rss2email as non root user

This commit is contained in:
Dominik Meyer 2024-01-23 09:34:15 +01:00
parent 77125cdb30
commit 39336edcf6
Signed by: byterazor
GPG Key ID: EABDA0FD5981BC97
3 changed files with 23 additions and 10 deletions

View File

@ -29,4 +29,19 @@ ADD scripts/entryPoint.sh /entryPoint.sh
RUN chmod +x /entryPoint.sh RUN chmod +x /entryPoint.sh
RUN chmod +x /createMSMTPconfig.sh RUN chmod +x /createMSMTPconfig.sh
# we use msmtp as a dropin replacement for sendmail
RUN rm /usr/sbin/sendmail
RUN ln -s /usr/bin/msmtp /usr/sbin/sendmail
# add a user for running rss2email in the container
RUN addgroup rss2email && adduser -D -G rss2email rss2email
RUN mkdir -p /home/rss2email/.rss2email/
# ensure a homedirectory for the user exists and has correct access rights
RUN mkdir -p /home/rss2email && chown rss2email.rss2email /home/rss2email
# run everything as the rss2email user
USER rss2email
ENTRYPOINT ["/sbin/tini", "--", "/entryPoint.sh"] ENTRYPOINT ["/sbin/tini", "--", "/entryPoint.sh"]

View File

@ -44,7 +44,12 @@ else
MSMTP_SMTP_PASS="dummy" MSMTP_SMTP_PASS="dummy"
fi fi
cat > /etc/msmtprc <<EOF if [ -z $XDG_CONFIG_HOME ]; then
XDG_CONFIG_HOME=/home/rssemail/.config
fi
mkdir -p $XDG_CONFIG_HOME/msmtp/
cat > $XDG_CONFIG_HOME/msmtp/config <<EOF
defaults defaults
auth ${MSMTP_SMTP_AUTH} auth ${MSMTP_SMTP_AUTH}
tls ${MSMTP_SMTP_TLS} tls ${MSMTP_SMTP_TLS}
@ -57,10 +62,3 @@ from ${MSMTP_SMTP_FROM}
user ${MSMTP_SMTP_USER} user ${MSMTP_SMTP_USER}
password ${MSMTP_SMTP_PASS} password ${MSMTP_SMTP_PASS}
EOF EOF
chmod 600 /etc/msmtprc
# we use msmtp as a dropin replacement for sendmail
rm /usr/sbin/sendmail
ln -s /usr/bin/msmtp /usr/sbin/sendmail

View File

@ -13,7 +13,7 @@ if [ -z ${FEEDS} ]; then
exit 255 exit 255
fi fi
mkdir -p ~/.rss2email/
echo ${FEEDS} > ~/.rss2email/feeds.txt echo -e ${FEEDS} > ~/.rss2email/feeds.txt
/app/rss2email daemon ${RECIPIENTS} /app/rss2email daemon ${RECIPIENTS}