mirror of
https://github.com/angristan/openvpn-install.git
synced 2024-11-22 00:39:03 +01:00
Fix home dir detection when using sudo as root
Close https://github.com/angristan/openvpn-install/issues/780
This commit is contained in:
parent
d1de5c64fe
commit
e965518dc7
@ -1084,12 +1084,20 @@ function newClient() {
|
|||||||
echo "Client $CLIENT added."
|
echo "Client $CLIENT added."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Home directory of the user, where the client configuration (.ovpn) will be written
|
# Home directory of the user, where the client configuration will be written
|
||||||
if [ -e "/home/$CLIENT" ]; then # if $1 is a user name
|
if [ -e "/home/${CLIENT_NAME}" ]; then
|
||||||
homeDir="/home/$CLIENT"
|
# if $1 is a user name
|
||||||
elif [ "${SUDO_USER}" ]; then # if not, use SUDO_USER
|
homeDir="/home/${CLIENT_NAME}"
|
||||||
homeDir="/home/${SUDO_USER}"
|
elif [ "${SUDO_USER}" ]; then
|
||||||
else # if not SUDO_USER, use /root
|
# if not, use SUDO_USER
|
||||||
|
if [ "${SUDO_USER}" == "root" ]; then
|
||||||
|
# If running sudo as root
|
||||||
|
homeDir="/root"
|
||||||
|
else
|
||||||
|
homeDir="/home/${SUDO_USER}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# if not SUDO_USER, use /root
|
||||||
homeDir="/root"
|
homeDir="/root"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user