diff --git a/salt/common/tools/sbin/so-common b/salt/common/tools/sbin/so-common index ce59c64db..7ad74ad49 100755 --- a/salt/common/tools/sbin/so-common +++ b/salt/common/tools/sbin/so-common @@ -160,14 +160,6 @@ fail() { exit 1 } -fqdn_lowercase() { - local fqdn=$1 - - echo "$fqdn" | grep -qP '(?=^.{4,253}$)(^((?!-)[a-z0-9-]{0,62}[a-z0-9]\.)+[a-z]{2,63}$)' \ - && return 0 \ - || return 1 -} - get_random_value() { length=${1:-20} head -c 5000 /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $length | head -n 1 @@ -194,12 +186,6 @@ header() { printf '%s\n' "" "$banner" " $*" "$banner" } -hostname_lowercase() { - local hostname=$1 - - [[ $hostname =~ ^[a-z0-9\-]+$ ]] && return 0 || return 1 -} - init_monitor() { MONITORNIC=$1 @@ -386,6 +372,14 @@ set_version() { fi } +has_uppercase() { + local string=$1 + + echo "$string" | grep -qP '[A-Z]' \ + && return 0 \ + || return 1 +} + valid_cidr() { # Verify there is a backslash in the string echo "$1" | grep -qP "^[^/]+/[^/]+$" || return 1 diff --git a/setup/so-functions b/setup/so-functions index 98dd007cb..7bbaa1fda 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -425,7 +425,7 @@ collect_homenet_snsr() { collect_hostname() { collect_hostname_validate - while ! hostname_lowercase "$HOSTNAME"; do + while has_uppercase "$HOSTNAME"; do if ! (whiptail_uppercase_warning); then collect_hostname_validate else @@ -664,7 +664,7 @@ collect_proxy_details() { collect_redirect_host() { collect_redirect_host_validate - while ! hostname_lowercase "$REDIRECTHOST" && ! fqdn_lowercase "$REDIRECTHOST"; do + while has_uppercase "$REDIRECTHOST"; do local text ! valid_hostname "$REDIRECTHOST" && text="domain name" || text="hostname" if ! (whiptail_uppercase_warning "$text"); then