Add a config parameter: Disable reduce prvilege of deamon

This commit is contained in:
Edouard DUPIN 2019-03-30 13:47:23 +01:00
parent dbab08e92a
commit 7c82b535d7

View File

@ -105,6 +105,7 @@ usage() {
echo " -T Encrypt packets with the given cipher algorithm instead of the default one (tls-cipher)." echo " -T Encrypt packets with the given cipher algorithm instead of the default one (tls-cipher)."
echo " -z Enable comp-lzo compression." echo " -z Enable comp-lzo compression."
echo " -S Change status folder. Default '/tmp'" echo " -S Change status folder. Default '/tmp'"
echo " -R Disable the reduce the OpenVPN daemon's privileges after initialization."
} }
process_route_config() { process_route_config() {
@ -169,12 +170,13 @@ OVPN_SERVER=192.168.255.0/24
OVPN_SERVER_URL='' OVPN_SERVER_URL=''
OVPN_TLS_CIPHER='' OVPN_TLS_CIPHER=''
OVPN_STATUS_PATH='/tmp' OVPN_STATUS_PATH='/tmp'
OVPN_DISABLE_REDUCE_DEAMON_S_PRIVILEGES=0
# Import existing configuration if present # Import existing configuration if present
[ -r "$OVPN_ENV" ] && source "$OVPN_ENV" [ -r "$OVPN_ENV" ] && source "$OVPN_ENV"
# Parse arguments # Parse arguments
while getopts ":a:e:E:C:T:r:s:du:bcp:n:k:DNm:f:tz2S:" opt; do while getopts ":a:e:E:C:T:r:s:du:bcp:n:k:DNm:f:tz2S:R" opt; do
case $opt in case $opt in
a) a)
OVPN_AUTH="$OPTARG" OVPN_AUTH="$OPTARG"
@ -258,6 +260,9 @@ while getopts ":a:e:E:C:T:r:s:du:bcp:n:k:DNm:f:tz2S:" opt; do
S) S)
OVPN_STATUS_PATH="$OPTARG" OVPN_STATUS_PATH="$OPTARG"
;; ;;
R)
OVPN_DISABLE_REDUCE_DEAMON_S_PRIVILEGES=1
;;
\?) \?)
set +x set +x
echo "Invalid option: -$OPTARG" >&2 echo "Invalid option: -$OPTARG" >&2
@ -341,10 +346,15 @@ port 1194
dev $OVPN_DEVICE$OVPN_DEVICEN dev $OVPN_DEVICE$OVPN_DEVICEN
status $OVPN_STATUS_PATH/openvpn-status.log status $OVPN_STATUS_PATH/openvpn-status.log
user nobody
group nogroup
EOF EOF
if [ "${OVPN_DISABLE_REDUCE_DEAMON_S_PRIVILEGES}" == "1" ]; then
echo "Disable 'user' and 'group'"
else
echo "user nobody" >> "$conf"
echo "group nogroup" >> "$conf"
fi
if [ "${OVPN_DISABLE_PUSH_BLOCK_DNS}" == "1" ]; then if [ "${OVPN_DISABLE_PUSH_BLOCK_DNS}" == "1" ]; then
echo "Disable default push of 'block-outside-dns'" echo "Disable default push of 'block-outside-dns'"
else else