mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-20 03:40:17 +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
d79dc3db61
commit
04c1c2dae2
1 changed files with 4 additions and 3 deletions
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# PiVPN: revoke client script
|
# PiVPN: revoke client script
|
||||||
|
|
||||||
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
INSTALL_USER=$(</etc/pivpn/INSTALL_USER)
|
||||||
PLAT=$(cat /etc/pivpn/DET_PLATFORM)
|
PLAT=$(</etc/pivpn/DET_PLATFORM)
|
||||||
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
|
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
|
||||||
|
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
|
@ -104,7 +104,8 @@ fi
|
||||||
|
|
||||||
cd /etc/openvpn/easy-rsa || exit
|
cd /etc/openvpn/easy-rsa || exit
|
||||||
|
|
||||||
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
|
||||||
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]}"
|
||||||
|
|
Loading…
Reference in a new issue