mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-18 19:00:15 +00:00
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 <file> | grep <pattern>", since grep can process files directly + Avoid "VAR=$(cat file)", since "VAR=$(<file)" has the same result without using a slow external command Signed-off-by: MichaIng <micha@dietpi.com>
This commit is contained in:
parent
51333a9313
commit
d79dc3db61
1 changed files with 3 additions and 2 deletions
|
@ -8,7 +8,7 @@ KEY=".key"
|
|||
CA="ca.crt"
|
||||
TA="ta.key"
|
||||
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
|
||||
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
||||
INSTALL_USER=$(</etc/pivpn/INSTALL_USER)
|
||||
|
||||
helpFunc() {
|
||||
echo "::: Create a client ovpn profile, optional nopass"
|
||||
|
@ -403,7 +403,8 @@ if [ $RESPONSE == "y" ] || [ $RESPONSE == "Y" ]; then
|
|||
fi
|
||||
|
||||
# Copy the .ovpn profile to the home directory for convenient remote access
|
||||
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
|
||||
cp "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT" "$INSTALL_HOME/ovpns/$NAME$FILEEXT"
|
||||
chown "$INSTALL_USER" "$INSTALL_HOME/ovpns/$NAME$FILEEXT"
|
||||
chmod 640 "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT"
|
||||
|
|
Loading…
Reference in a new issue