Explorar o código

Strip some extra dots from user input (#3048)

And prevent users entering invalid hostnames
Jaap Marcus %!s(int64=3) %!d(string=hai) anos
pai
achega
88cf9bafd7
Modificáronse 2 ficheiros con 6 adicións e 0 borrados
  1. 3 0
      install/hst-install-debian.sh
  2. 3 0
      install/hst-install-ubuntu.sh

+ 3 - 0
install/hst-install-debian.sh

@@ -171,6 +171,9 @@ sort_config_file(){
 
 # Validate hostname according to RFC1178
 validate_hostname () {
+    # remove extra .
+    servername = $(echo "$servername" |sed -e "s/[.]*$//g")
+    servername = $(echo "$domain" |sed -e "s/^[.]*//")
     if [[ $(echo "$servername" | grep -o "\." | wc -l) -gt 1 ]] && [[ ! $servername =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
         # Hostname valid
         return 1

+ 3 - 0
install/hst-install-ubuntu.sh

@@ -169,6 +169,9 @@ sort_config_file(){
 
 # Validate hostname according to RFC1178
 validate_hostname () {
+    # remove extra .
+    servername = $(echo "$servername" |sed -e "s/[.]*$//g")
+    servername = $(echo "$domain" |sed -e "s/^[.]*//")
     if [[ $(echo "$servername" | grep -o "\." | wc -l) -gt 1 ]] && [[ ! $servername =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
         # Hostname valid
         return 1