Runs openvpn as non-root user

This commit is contained in:
Quentin McGaw
2018-09-21 11:39:00 +02:00
parent 706050619d
commit 6929947611
3 changed files with 12 additions and 8 deletions

View File

@@ -25,7 +25,8 @@ RUN apk add -q --progress --no-cache --update openvpn ca-certificates iptables i
unzip -q openvpn-tcp.zip -d /openvpn-tcp-normal && \ unzip -q openvpn-tcp.zip -d /openvpn-tcp-normal && \
unzip -q openvpn-strong-tcp.zip -d /openvpn-tcp-strong && \ unzip -q openvpn-strong-tcp.zip -d /openvpn-tcp-strong && \
apk del -q --progress --purge build-dependencies && \ apk del -q --progress --purge build-dependencies && \
rm -rf /*.zip /var/cache/apk/* /etc/unbound/unbound.conf rm -rf /*.zip /var/cache/apk/* /etc/unbound/unbound.conf && \
addgroup -S nonrootusers && adduser -S nonrootuser -G nonrootusers
COPY unbound.conf /etc/unbound/unbound.conf COPY unbound.conf /etc/unbound/unbound.conf
COPY entrypoint.sh / COPY entrypoint.sh /
ENTRYPOINT /entrypoint.sh ENTRYPOINT /entrypoint.sh

View File

@@ -226,4 +226,5 @@ For more containers, add more `--link pia:xxx` and modify *nginx.conf* according
- More iptables restrictions - More iptables restrictions
- Rework readme with unbound required for VPN - Rework readme with unbound required for VPN
- Block malicious websites with Unbound - Block malicious websites with Unbound
- Add checks when launching PIA $?

View File

@@ -84,17 +84,19 @@ printf "DONE"
############################################ ############################################
# SUMMARY # SUMMARY
############################################ ############################################
printf "\n * Starting OpenVPN using the following parameters:" printf "\nStarting OpenVPN using the following parameters:"
printf "\n * Domain: $PIADOMAIN" printf "\n * Domain: $PIADOMAIN"
printf "\n * Port: $PORT" printf "\n * Port: $PORT"
printf "\n * Protocol: $PROTOCOL" printf "\n * Protocol: $PROTOCOL"
printf "\n * Encryption: $ENCRYPTION\n" printf "\n * Encryption: $ENCRYPTION"
############################################ ############################################
# OPENVPN LAUNCH # OPENVPN LAUNCH
############################################ ############################################
# RUN AS OTHER USER TODO
cd /openvpn-$PROTOCOL-$ENCRYPTION cd /openvpn-$PROTOCOL-$ENCRYPTION
printf "\nSwitching from root to nonrootuser..."
su -l nonrootuser
printf "DONE\n"
openvpn --config "$REGION.ovpn" --auth-user-pass /auth.conf openvpn --config "$REGION.ovpn" --auth-user-pass /auth.conf
############################################ ############################################