From 73b23c525bb63550160955c18d4a59d5d0d46389 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Sun, 1 Sep 2019 17:39:38 +0200 Subject: [PATCH] Failsafe home dir obtaining + When estimating $INSTALL_HOME, assure grep can only match user names, to avoid possible wrong multi-line value + Remove possible trailing slash from $INSTALL_HOME, to avoid double slash in "$INSTALL_HOME/ovpns" + Avoid "cat | grep ", since grep can process files directly Signed-off-by: MichaIng --- auto_install/install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/auto_install/install.sh b/auto_install/install.sh index bedbb8e..ed30c10 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -1131,8 +1131,9 @@ confOVPN() { # verify server name to strengthen security $SUDO sed -i "s/SRVRNAME/${SERVER_NAME}/" /etc/openvpn/easy-rsa/pki/Default.txt - INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6) - if [ ! -d "$INSTALL_HOME/ovpns" ]; then + INSTALL_HOME=$(grep -m1 "^${INSTALL_USER}:" /etc/passwd | cut -d: -f6) + INSTALL_HOME=${INSTALL_HOME%/} # remove possible trailing slash + if [ ! -d "$INSTALL_HOME/ovpns" ]; then $SUDO mkdir "$INSTALL_HOME/ovpns" fi $SUDO chmod 0777 -R "$INSTALL_HOME/ovpns"