Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
shuricksumy opened this issue Jul 29, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@shuricksumy
Copy link

shuricksumy commented Jul 29, 2023

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
Copy link
Owner

d3vilh commented Jul 29, 2023

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

@d3vilh d3vilh self-assigned this Jul 29, 2023
@d3vilh d3vilh added the bug Something isn't working label Jul 29, 2023
d3vilh added a commit that referenced this issue Jul 30, 2023
@d3vilh
Copy link
Owner

d3vilh commented Jul 30, 2023

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

Included into main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants