Просмотр исходного кода

Merge branch 'main' into fix/2096-ssl-hostname-overwritten

Jaap Marcus 4 лет назад
Родитель
Сommit
42094e5d41
5 измененных файлов с 98 добавлено и 11 удалено
  1. 6 0
      CHANGELOG.md
  2. 13 0
      func/upgrade.sh
  3. 30 5
      install/hst-install-debian.sh
  4. 31 6
      install/hst-install-ubuntu.sh
  5. 18 0
      install/upgrade/versions/1.4.13.sh

+ 6 - 0
CHANGELOG.md

@@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
 
 ## [1.4.13] - Development
 
+### Features
+- Introduce UPGRADE_MESSAGE variable to support custom messages in e-mail upgrade notification.
+
+### Bugfixes
+- Improve the hostname check to prevent invalid hostnames or the use of an ip address (RFC1178).
+
 ## [1.4.12] - Service release 
 
 ### Bugfixes

+ 13 - 0
func/upgrade.sh

@@ -191,12 +191,25 @@ upgrade_send_notification_to_email () {
         echo "$HOSTNAME has been upgraded from Hestia Control Panel v$VERSION to v${new_version}." >> $message_tmp_file
         echo "Installation log: $LOG" >> $message_tmp_file
         echo "" >> $message_tmp_file
+
+        # Check for additional upgrade notes from update scripts.
+        if [[ -z "$UPGRADE_MESSAGE" ]]; then
+            echo "==================================================="  >> $message_tmp_file
+            echo "The upgrade script has generated additional notifications, which must be heeded urgently:" >> $message_tmp_file
+            echo "" >> $message_tmp_file
+            echo -e $UPGRADE_MESSAGE >> $message_tmp_file
+            echo "" >> $message_tmp_file
+            echo "==================================================="  >> $message_tmp_file
+            echo "" >> $message_tmp_file
+        fi
+
         echo "What's new: https://github.com/hestiacp/hestiacp/blob/$RELEASE_BRANCH/CHANGELOG.md" >> $message_tmp_file
         echo  >> $message_tmp_file
         echo "What to do if you run into issues:" >> $message_tmp_file
         echo "- Check our forums for possible solutions: https://forum.hestiacp.com" >> $message_tmp_file
         echo "- File an issue report on GitHub: https://github.com/hestiacp/hestiacp/issues" >> $message_tmp_file
         echo "" >> $message_tmp_file
+        echo "Help support the Hestia Control Panel project by donating via PayPal: https://www.hestiacp.com/donate" >> $message_tmp_file"
         echo "==================================================="  >> $message_tmp_file
         echo "Have a wonderful day," >> $message_tmp_file
         echo "The Hestia Control Panel development team" >> $message_tmp_file

+ 30 - 5
install/hst-install-debian.sh

@@ -168,6 +168,18 @@ sort_config_file(){
     cp $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
 }
 
+# Validate hostname according to RFC1178
+validate_hostname () {
+    if [[ $(echo "$servername" | grep -o "\." | wc -l) -gt 1 ]] && [[ ! $servername =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+        # Hostname valid
+        return 1
+    else
+        # Hostname invalid
+        return 0
+    fi
+}
+
+
 #----------------------------------------------------------#
 #                    Verifications                         #
 #----------------------------------------------------------#
@@ -577,7 +589,25 @@ if [ "$interactive" = 'yes' ]; then
 
     # Asking to set FQDN hostname
     if [ -z "$servername" ]; then
+        # Ask and validate FQDN hostname.
         read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
+
+        # Set hostname if it wasn't set
+        if [ -z "$servername" ]; then
+            servername=$(hostname -f)
+        fi
+
+        # Validate Hostname, go to loop if the validation fails.
+        while validate_hostname; do
+            echo -e "\nPlease use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
+            read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
+        done
+    else
+        # Validate FQDN hostname if it is preset
+        if validate_hostname; then
+            echo "Please use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
+            exit 1
+        fi
     fi
 fi
 
@@ -586,11 +616,6 @@ if [ -z "$vpass" ]; then
     vpass=$(gen_pass)
 fi
 
-# Set hostname if it wasn't set
-if [ -z "$servername" ]; then
-    servername=$(hostname -f)
-fi
-
 # Set FQDN if it wasn't set
 mask1='(([[:alnum:]](-?[[:alnum:]])*)\.)'
 mask2='*[[:alnum:]](-?[[:alnum:]])+\.[[:alnum:]]{2,}'

+ 31 - 6
install/hst-install-ubuntu.sh

@@ -23,7 +23,7 @@ HESTIA_INSTALL_DIR="$HESTIA/install/deb"
 VERBOSE='no'
 
 # Define software versions
-HESTIA_INSTALL_VER='11.4.13~alpha'
+HESTIA_INSTALL_VER='1.4.13~alpha'
 pma_v='5.1.1'
 rc_v="1.4.11"
 multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0")
@@ -150,6 +150,18 @@ sort_config_file(){
     cp $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
 }
 
+# Validate hostname according to RFC1178
+validate_hostname () {
+    if [[ $(echo "$servername" | grep -o "\." | wc -l) -gt 1 ]] && [[ ! $servername =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+        # Hostname valid
+        return 1
+    else
+        # Hostname invalid
+        return 0
+    fi
+}
+
+
 #----------------------------------------------------------#
 #                    Verifications                         #
 #----------------------------------------------------------#
@@ -549,7 +561,25 @@ if [ "$interactive" = 'yes' ]; then
 
     # Asking to set FQDN hostname
     if [ -z "$servername" ]; then
+        # Ask and validate FQDN hostname.
         read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
+
+        # Set hostname if it wasn't set
+        if [ -z "$servername" ]; then
+            servername=$(hostname -f)
+        fi
+
+        # Validate Hostname, go to loop if the validation fails.
+        while validate_hostname; do
+            echo -e "\nPlease use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
+            read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
+        done
+    else
+        # Validate FQDN hostname if it is preset
+        if validate_hostname; then
+            echo "Please use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
+            exit 1
+        fi
     fi
 fi
 
@@ -558,11 +588,6 @@ if [ -z "$vpass" ]; then
     vpass=$(gen_pass)
 fi
 
-# Set hostname if it wasn't set
-if [ -z "$servername" ]; then
-    servername=$(hostname -f)
-fi
-
 # Set FQDN if it wasn't set
 mask1='(([[:alnum:]](-?[[:alnum:]])*)\.)'
 mask2='*[[:alnum:]](-?[[:alnum:]])+\.[[:alnum:]]{2,}'

+ 18 - 0
install/upgrade/versions/1.4.13.sh

@@ -5,7 +5,25 @@
 #######################################################################################
 #######                      Place additional commands below.                   #######
 #######################################################################################
+####### New Feature: UPGRADE_MESSAGE                                            #######
+#######                                                                         #######
+####### Add your text to UPGRADE_MESSAGE to include a message to the upgrade    #######
+####### email. Do not overwrite the variable, it could already contains prior   #######
+####### content of another upgrade script. Please add it using:                 #######
+#######                                                                         #######
+####### UPGRADE_MESSAGE="$UPGRADE_MESSAGE\nYour Upgrade Notification Text"      #######
+#######                                                                         #######
+####### Always start and end with \n to generate a new line.                    #######
+#######################################################################################
+
+
+# Check if hostname is valid according to RFC1178
+if [[ $(echo "$servername" | grep -o "\." | wc -l) -lt 2 ]] || [[ $servername =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]];; then
+    UPGRADE_MESSAGE="$UPGRADE_MESSAGE\nWe've noticed that you're using a invalid hostname. Please have a look at the RFC1178 standard (https://datatracker.ietf.org/doc/html/rfc1178) and use a valid one (ex. hostname.domain.tld). You can change the hostname using v-change-sys-hostname and also add a ssl certificate using v-add-letsencypt-host (proper dns A record mandatory). You'll find more informations in our documentation: https://docs.hestiacp.com/admin_docs/web/ssl_certificates.html#how-to-setup-let-s-encrypt-for-the-control-panel"
+    $HESTIA/bin/v-add-user-notification admin "Invalid Hostname detected" "Warning: We've noticed that you're using a invalid hostname. Please have a look at the <a href="https://datatracker.ietf.org/doc/html/rfc1178" target="_blank">RFC1178 standard</a> and use a valid one (ex. hostname.domain.tld). You can change the hostname using v-change-sys-hostname and also add a ssl certificate using v-add-letsencypt-host (proper dns A record mandatory). You'll find more informations in our <a href="https://docs.hestiacp.com/admin_docs/web/ssl_certificates.html#how-to-setup-let-s-encrypt-for-the-control-panel" target=_"blank">documentation</a>."
+fi
 
+# Empty $HESTIA/ssl/mail/ due to bug in #2066 
 if [ -e "$HESTIA/ssl/mail/" ]; then
     rm -fr $HESTIA/ssl/mail/*
 fi