From 51333a93131219448a1b7def1b7660e12151d2eb Mon Sep 17 00:00:00 2001 From: MichaIng Date: Sun, 1 Sep 2019 17:41:44 +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 --- scripts/uninstall.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index ecd2765..d9b972b 100755 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -2,7 +2,8 @@ # PiVPN: Uninstall Script INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER) -INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6) +INSTALL_HOME=$(grep -m1 "^${INSTALL_USER}:" /etc/passwd | cut -d: -f6) +INSTALL_HOME=${INSTALL_HOME%/} # remove possible trailing slash PLAT=$(cat /etc/pivpn/DET_PLATFORM) NO_UFW=$(cat /etc/pivpn/NO_UFW) OLD_UFW=$(cat /etc/pivpn/NO_UFW)