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

https interface for user management #648

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed substition of user&group in Dockerfile, use OPENVPN in lighttpd
config as well
  • Loading branch information
nanda committed Mar 30, 2021
commit 7cf65db78318ebd3bc3fb1ec7b0fea0385493939
21 changes: 11 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,27 @@ RUN echo "http:https://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/reposi
ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin && \
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/*

ENV OVPN_USER=openvpn
ENV OVPN_GROUP=openvpn
# Needed by scripts
ENV OPENVPN=/etc/openvpn
ENV EASYRSA=/usr/share/easy-rsa \
EASYRSA_CRL_DAYS=3650 \
EASYRSA_PKI=$OPENVPN/pki \
OVPN_USER=openvpn \
OVPN_GROUP=openvpn

ADD ./lighttpd/htdocs/ /var/www/localhost/htdocs/
ADD ./lighttpd/config/* /etc/lighttpd/
RUN sed -i /etc/lighttpd/lighttpd.conf -e 's/server\.username.*/server.username\ =\ "$OVPN_USER"/' -e 's/server\.groupname.*/server.groupname\ =\ "$OVPN_GROUP"/' && \
chown -R ${OVPN_USER}:${OVPN_GROUP} /var/www/localhost/htdocs /etc/lighttpd /var/log/lighttpd
RUN OPENVPN=$(echo $OPENVPN | sed -e 's/\//\\\//g') && sed -i /etc/lighttpd/lighttpd.conf -e 's/server\.username.*/server.username\ =\ "'$OVPN_USER'"/' \
-e 's/server\.groupname.*/server.groupname\ =\ "'$OVPN_GROUP'"/' \
-e 's/^var\.ovpndir.*$/var.ovpndir\ =\ "'${OPENVPN}'"/' && \
chown -R ${OVPN_USER}:${OVPN_GROUP} /var/www/localhost/htdocs /etc/lighttpd /var/log/lighttpd

ADD ./bin /usr/local/bin
RUN chmod 755 /usr/local/bin/* && chown root:${OVPN_GROUP} /usr/local/bin/*

# Add support for OTP authentication using a PAM module
ADD ./otp/openvpn /etc/pam.d/

# Needed by scripts
ENV OPENVPN=/etc/openvpn
ENV EASYRSA=/usr/share/easy-rsa \
EASYRSA_CRL_DAYS=3650 \
EASYRSA_PKI=$OPENVPN/pki

VOLUME ["/etc/openvpn"]
VOLUME ["/var/log"]

Expand Down
2 changes: 2 additions & 0 deletions bin/ovpn_genconfig
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ OVPN_SERVER=192.168.255.0/24
OVPN_SERVER_URL=''
OVPN_TLS_CIPHER=''
OVPN_HTTPS_ADMIN=0
OVPN_USER=openvpn
OVPN_GROUP=openvpn

# Import existing configuration if present
[ -r "$OVPN_ENV" ] && source "$OVPN_ENV"
Expand Down
5 changes: 4 additions & 1 deletion bin/ovpn_run
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ addArg "--config" "$OPENVPN/openvpn.conf"

source "$OPENVPN/ovpn_env.sh"

[ -n "${OVPN_USER}" ] && addArg "--user" "${OVPN_USER}"
[ -n "${OVPN_GROUP}" ] && addArg "--group" "${OVPN_GROUP}"

mkdir -p /dev/net
if [ ! -c /dev/net/tun ]; then
mknod /dev/net/tun c 10 200
Expand Down Expand Up @@ -111,7 +114,7 @@ fi

# TODO: ovpn user
echo "Running 'openvpn ${ARGS[@]} ${USER_ARGS[@]}'"
exec openvpn --user ${OVPN_USER} -- group "${OVPN_GROUP}" ${ARGS[@]} ${USER_ARGS[@]}
exec openvpn ${ARGS[@]} ${USER_ARGS[@]}

echo "shutting down https admin iface"
[ "$OVPN_HTTPS_ADMIN" = 1 ] && [ -f /var/run/lighttpd.pid ] && kill -TERM $(cat /var/run/lighttpd.pid)
Expand Down
7 changes: 4 additions & 3 deletions lighttpd/config/lighttpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
var.basedir = "/var/www/localhost"
var.logdir = "/var/log/lighttpd"
var.statedir = "/var/lib/lighttpd"
var.ovpndir = "/etc/openvpn"
# }}}

# {{{ modules
Expand Down Expand Up @@ -151,8 +152,8 @@ url.access-deny = ("~", ".inc")
# see ssl.txt
#
ssl.engine = "enable"
ssl.pemfile = "/etc/openvpn/http/server.pem"
ssl.privkey = "/etc/openvpn/http/server.key"
ssl.pemfile = var.ovpndir + "/http/server.pem"
ssl.privkey = var.ovpndir + "/http/server.key"
# }}}

# {{{ mod_status
Expand Down Expand Up @@ -182,7 +183,7 @@ url.access-deny = ("~", ".inc")
# see authentication.txt
#
auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/etc/openvpn/http/htpasswd"
auth.backend.htpasswd.userfile = var.ovpndir + "/http/htpasswd"

auth.require = ( "" =>
# (
Expand Down