summaryrefslogtreecommitdiffstats
path: root/netconfig
diff options
context:
space:
mode:
authorDarren 'Tadgy' Austin <darren@afterdark.org.uk>2021-03-08 22:58:01 +0000
committerDarren 'Tadgy' Austin <darren@afterdark.org.uk>2021-03-08 22:58:01 +0000
commit39ff28c3f36673e373dac6d2a8a12f0bf0dfceff (patch)
treea36f5d22e87bb178df218dba0ab851c3a11a391c /netconfig
parent908f03bd53526adb20a56b91f2b343dc57ec6d02 (diff)
downloadslacknetsetup-39ff28c3f36673e373dac6d2a8a12f0bf0dfceff.tar.xz
Fix domain name validation checks. Thanks to xbeastx74 on LQ for the report.
Diffstat (limited to 'netconfig')
-rw-r--r--netconfig7
1 files changed, 5 insertions, 2 deletions
diff --git a/netconfig b/netconfig
index a33b85d..bb5a5ac 100644
--- a/netconfig
+++ b/netconfig
@@ -492,8 +492,11 @@ EOF
DOMAIN="`cat $TMP/SeTdom`"
rm -f $TMP/SeTdom $TMP/tempmsg
# These regexes doon't catch everything, just basic syntax mistakes.
- if [ "$DOMAIN" = "" ] || [[ ! "$DOMAIN" =~ ^([[:alnum:]]+[-.]*[[:alnum:]]+)+$ ]] || \
- [[ "${DOMAIN:0:1}" =~ ^[.-]$ ]] || [[ "${DOMAIN: -1:1}" == ^[.-]$ ]]; then
+ DN="${DOMAIN%.*}"
+ TLD="${DOMAIN##*.}"
+ if [ -z "$DOMAIN" ] || [ -z "$TLD" ] || [ -z "$DN" ] || [[ ! "$DOMAIN" =~ ^[^.-][[:alnum:].-]+[^.-]$ ]] || \
+ [[ ! "$DN" =~ ^[^.-][[:alnum:].-]+[^.-]$ ]] || [[ "$DN" =~ \.\. ]] || [[ "$DN" =~ -- ]] || \
+ [[ ! "$TLD" =~ ^[^-][[:alnum:]-]+[^-]$ ]]; then
dialog --title "DOMAINNAME" --ok-button "Back" --msgbox \
"That doesn't appear to be a valid domain name.\n
Domain names can only contain letters and numbers, hyphens