From 85478aaea02ff5168c66c7a10001f486ba59251f Mon Sep 17 00:00:00 2001 From: Orazio Date: Thu, 23 Jul 2020 14:50:59 +0200 Subject: [PATCH] Disallow integers as client names to avoid ambiguity when removing a client by index. --- scripts/openvpn/makeOVPN.sh | 5 +++++ scripts/wireguard/makeCONF.sh | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/scripts/openvpn/makeOVPN.sh b/scripts/openvpn/makeOVPN.sh index 5300a2b..b03af64 100755 --- a/scripts/openvpn/makeOVPN.sh +++ b/scripts/openvpn/makeOVPN.sh @@ -248,6 +248,11 @@ if [[ "${NAME}" =~ [^a-zA-Z0-9.@_-] ]]; then exit 1 fi +if [[ "${NAME}" =~ ^[0-9]+$ ]]; then + echo "Names cannot be integers." + exit 1 +fi + if [[ -z "${NAME}" ]]; then echo "You cannot leave the name blank." exit 1 diff --git a/scripts/wireguard/makeCONF.sh b/scripts/wireguard/makeCONF.sh index e919e4a..e0669b8 100755 --- a/scripts/wireguard/makeCONF.sh +++ b/scripts/wireguard/makeCONF.sh @@ -64,6 +64,11 @@ if [[ "${CLIENT_NAME}" =~ [^a-zA-Z0-9.@_-] ]]; then exit 1 fi +if [[ "${CLIENT_NAME}" =~ ^[0-9]+$ ]]; then + echo "Names cannot be integers." + exit 1 +fi + if [ -z "${CLIENT_NAME}" ]; then echo "::: You cannot leave the name blank." exit 1