d3vilh / openvpn-ui

Web User Interface for OpenVPN
MIT License
173 stars 39 forks source link

Bash script corrupts config files if VPN name clients has the same beginning #5

Closed shuricksumy closed 11 months ago

shuricksumy commented 11 months ago

STR:

  1. Create "admin" client
  2. Create "admin123" client
  3. Create "admin12345" client
  4. Revoke "admin"

Result: index.txt file is broken - rmclient.sh has issue Additionally, rmcert.sh is affected and cannot read properly CERT_SERIAL for such clients

POSSIBLE FIX: rmclient.sh

Fix index.txt by removing everything after pattern "/name=$1" in the line
sed -i'.bak' "s/\/name=${1}\/.*//" /usr/share/easy-rsa/pki/index.txt

rmcert.sh

Define key serial number by keyname

STATUS_CH=$(grep -e ${1}$ -e${1}/ ${INDEX_PATH} | awk '{print $1}' | tr -d '\n')
if [[ $STATUS_CH = "V" ]]; then
    echo "Cert is VALID"
    CERT_SERIAL=$(grep ${1}/ ${INDEX_PATH} | awk '{print $3}' | tr -d '\n')
    echo "Will remove: ${CERT_SERIAL}"
else
    echo "Cert is REVOKED"
    CERT_SERIAL=$(grep ${1}$ ${INDEX_PATH} | awk '{print $4}' | tr -d '\n')
    echo "Will remove: ${CERT_SERIAL}"
fi
d3vilh commented 11 months ago

Nice, thank you for reporting it. Would you like to submit PR for this?

d3vilh commented 11 months ago

Nice, thank you for reporting it. Would you like to submit PR for this?

Included into main branch.