mirror of
https://github.com/pivpn/pivpn.git
synced 2025-01-19 02:54:29 +00:00
Properly determine user's home directory
Code assumes that the specified user directory is under /home. This code parses the /etc/passwd file in order to determine what that user's proper home directory is.
This commit is contained in:
parent
8e3a951524
commit
8b40035bf5
4 changed files with 13 additions and 9 deletions
|
@ -1055,10 +1055,11 @@ confOVPN() {
|
||||||
# verify server name to strengthen security
|
# verify server name to strengthen security
|
||||||
$SUDO sed -i "s/SRVRNAME/${SERVER_NAME}/" /etc/openvpn/easy-rsa/pki/Default.txt
|
$SUDO sed -i "s/SRVRNAME/${SERVER_NAME}/" /etc/openvpn/easy-rsa/pki/Default.txt
|
||||||
|
|
||||||
if [ ! -d "/home/$pivpnUser/ovpns" ]; then
|
INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6)
|
||||||
$SUDO mkdir "/home/$pivpnUser/ovpns"
|
if [ ! -d "$INSTALL_HOME/ovpns" ]; then
|
||||||
|
$SUDO mkdir "$INSTALL_HOME/ovpns"
|
||||||
fi
|
fi
|
||||||
$SUDO chmod 0777 -R "/home/$pivpnUser/ovpns"
|
$SUDO chmod 0777 -R "$INSTALL_HOME/ovpns"
|
||||||
}
|
}
|
||||||
|
|
||||||
confLogging() {
|
confLogging() {
|
||||||
|
|
|
@ -269,15 +269,16 @@ echo "tls-auth Private Key found: $TA"
|
||||||
} > "${NAME}${FILEEXT}"
|
} > "${NAME}${FILEEXT}"
|
||||||
|
|
||||||
# Copy the .ovpn profile to the home directory for convenient remote access
|
# Copy the .ovpn profile to the home directory for convenient remote access
|
||||||
cp "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT" "/home/$INSTALL_USER/ovpns/$NAME$FILEEXT"
|
INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6)
|
||||||
chown "$INSTALL_USER" "/home/$INSTALL_USER/ovpns/$NAME$FILEEXT"
|
cp "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT" "$INSTALL_HOME/ovpns/$NAME$FILEEXT"
|
||||||
|
chown "$INSTALL_HOME" "$INSTALL_HOME/ovpns/$NAME$FILEEXT"
|
||||||
chmod o-r "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT"
|
chmod o-r "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT"
|
||||||
chmod o-r "/home/$INSTALL_USER/ovpns/$NAME$FILEEXT"
|
chmod o-r "$INSTALL_HOME/ovpns/$NAME$FILEEXT"
|
||||||
printf "\n\n"
|
printf "\n\n"
|
||||||
printf "========================================================\n"
|
printf "========================================================\n"
|
||||||
printf "\e[1mDone! %s successfully created!\e[0m \n" "$NAME$FILEEXT"
|
printf "\e[1mDone! %s successfully created!\e[0m \n" "$NAME$FILEEXT"
|
||||||
printf "%s was copied to:\n" "$NAME$FILEEXT"
|
printf "%s was copied to:\n" "$NAME$FILEEXT"
|
||||||
printf " /home/%s/ovpns\n" "$INSTALL_USER"
|
printf " %s/ovpns\n" "$INSTALL_HOME"
|
||||||
printf "for easy transfer. Please use this profile only on one\n"
|
printf "for easy transfer. Please use this profile only on one\n"
|
||||||
printf "device and create additional profiles for other devices.\n"
|
printf "device and create additional profiles for other devices.\n"
|
||||||
printf "========================================================\n\n"
|
printf "========================================================\n\n"
|
||||||
|
|
|
@ -104,6 +104,7 @@ fi
|
||||||
|
|
||||||
cd /etc/openvpn/easy-rsa || exit
|
cd /etc/openvpn/easy-rsa || exit
|
||||||
|
|
||||||
|
INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6)
|
||||||
for (( ii = 0; ii < ${#CERTS_TO_REVOKE[@]}; ii++)); do
|
for (( ii = 0; ii < ${#CERTS_TO_REVOKE[@]}; ii++)); do
|
||||||
printf "\n::: Revoking certificate '"%s"'.\n" "${CERTS_TO_REVOKE[ii]}"
|
printf "\n::: Revoking certificate '"%s"'.\n" "${CERTS_TO_REVOKE[ii]}"
|
||||||
./easyrsa --batch revoke "${CERTS_TO_REVOKE[ii]}"
|
./easyrsa --batch revoke "${CERTS_TO_REVOKE[ii]}"
|
||||||
|
@ -113,7 +114,7 @@ for (( ii = 0; ii < ${#CERTS_TO_REVOKE[@]}; ii++)); do
|
||||||
rm -rf "pki/reqs/${CERTS_TO_REVOKE[ii]}.req"
|
rm -rf "pki/reqs/${CERTS_TO_REVOKE[ii]}.req"
|
||||||
rm -rf "pki/private/${CERTS_TO_REVOKE[ii]}.key"
|
rm -rf "pki/private/${CERTS_TO_REVOKE[ii]}.key"
|
||||||
rm -rf "pki/issued/${CERTS_TO_REVOKE[ii]}.crt"
|
rm -rf "pki/issued/${CERTS_TO_REVOKE[ii]}.crt"
|
||||||
rm -rf "/home/${INSTALL_USER}/ovpns/${CERTS_TO_REVOKE[ii]}.ovpn"
|
rm -rf "${INSTALL_HOME}/ovpns/${CERTS_TO_REVOKE[ii]}.ovpn"
|
||||||
rm -rf "/etc/openvpn/easy-rsa/pki/${CERTS_TO_REVOKE[ii]}.ovpn"
|
rm -rf "/etc/openvpn/easy-rsa/pki/${CERTS_TO_REVOKE[ii]}.ovpn"
|
||||||
cp /etc/openvpn/easy-rsa/pki/crl.pem /etc/openvpn/crl.pem
|
cp /etc/openvpn/easy-rsa/pki/crl.pem /etc/openvpn/crl.pem
|
||||||
done
|
done
|
||||||
|
|
|
@ -17,6 +17,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
||||||
|
INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6)
|
||||||
PLAT=$(cat /etc/pivpn/DET_PLATFORM)
|
PLAT=$(cat /etc/pivpn/DET_PLATFORM)
|
||||||
NO_UFW=$(cat /etc/pivpn/NO_UFW)
|
NO_UFW=$(cat /etc/pivpn/NO_UFW)
|
||||||
PORT=$(cat /etc/pivpn/INSTALL_PORT)
|
PORT=$(cat /etc/pivpn/INSTALL_PORT)
|
||||||
|
@ -83,7 +84,7 @@ echo ":::"
|
||||||
echo "::: Removing pivpn system files..."
|
echo "::: Removing pivpn system files..."
|
||||||
$SUDO rm -rf /opt/pivpn &> /dev/null
|
$SUDO rm -rf /opt/pivpn &> /dev/null
|
||||||
$SUDO rm -rf /etc/.pivpn &> /dev/null
|
$SUDO rm -rf /etc/.pivpn &> /dev/null
|
||||||
$SUDO rm -rf /home/$INSTALL_USER/ovpns &> /dev/null
|
$SUDO rm -rf $INSTALL_HOME/ovpns &> /dev/null
|
||||||
|
|
||||||
$SUDO rm -rf /var/log/*pivpn* &> /dev/null
|
$SUDO rm -rf /var/log/*pivpn* &> /dev/null
|
||||||
$SUDO rm -rf /var/log/*openvpn* &> /dev/null
|
$SUDO rm -rf /var/log/*openvpn* &> /dev/null
|
||||||
|
|
Loading…
Reference in a new issue