Skip to content

Commit 42094e5

Browse files
authored
Merge branch 'main' into fix/2096-ssl-hostname-overwritten
2 parents 04b8fc4 + c127b25 commit 42094e5

File tree

5 files changed

+98
-11
lines changed

5 files changed

+98
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
33

44
## [1.4.13] - Development
55

6+
### Features
7+
- Introduce UPGRADE_MESSAGE variable to support custom messages in e-mail upgrade notification.
8+
9+
### Bugfixes
10+
- Improve the hostname check to prevent invalid hostnames or the use of an ip address (RFC1178).
11+
612
## [1.4.12] - Service release
713

814
### Bugfixes

func/upgrade.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,25 @@ upgrade_send_notification_to_email () {
191191
echo "$HOSTNAME has been upgraded from Hestia Control Panel v$VERSION to v${new_version}." >> $message_tmp_file
192192
echo "Installation log: $LOG" >> $message_tmp_file
193193
echo "" >> $message_tmp_file
194+
195+
# Check for additional upgrade notes from update scripts.
196+
if [[ -z "$UPGRADE_MESSAGE" ]]; then
197+
echo "===================================================" >> $message_tmp_file
198+
echo "The upgrade script has generated additional notifications, which must be heeded urgently:" >> $message_tmp_file
199+
echo "" >> $message_tmp_file
200+
echo -e $UPGRADE_MESSAGE >> $message_tmp_file
201+
echo "" >> $message_tmp_file
202+
echo "===================================================" >> $message_tmp_file
203+
echo "" >> $message_tmp_file
204+
fi
205+
194206
echo "What's new: https://github.com/hestiacp/hestiacp/blob/$RELEASE_BRANCH/CHANGELOG.md" >> $message_tmp_file
195207
echo >> $message_tmp_file
196208
echo "What to do if you run into issues:" >> $message_tmp_file
197209
echo "- Check our forums for possible solutions: https://forum.hestiacp.com" >> $message_tmp_file
198210
echo "- File an issue report on GitHub: https://github.com/hestiacp/hestiacp/issues" >> $message_tmp_file
199211
echo "" >> $message_tmp_file
212+
echo "Help support the Hestia Control Panel project by donating via PayPal: https://www.hestiacp.com/donate" >> $message_tmp_file"
200213
echo "===================================================" >> $message_tmp_file
201214
echo "Have a wonderful day," >> $message_tmp_file
202215
echo "The Hestia Control Panel development team" >> $message_tmp_file

install/hst-install-debian.sh

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ sort_config_file(){
168168
cp $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
169169
}
170170

171+
# Validate hostname according to RFC1178
172+
validate_hostname () {
173+
if [[ $(echo "$servername" | grep -o "\." | wc -l) -gt 1 ]] && [[ ! $servername =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
174+
# Hostname valid
175+
return 1
176+
else
177+
# Hostname invalid
178+
return 0
179+
fi
180+
}
181+
182+
171183
#----------------------------------------------------------#
172184
# Verifications #
173185
#----------------------------------------------------------#
@@ -577,7 +589,25 @@ if [ "$interactive" = 'yes' ]; then
577589

578590
# Asking to set FQDN hostname
579591
if [ -z "$servername" ]; then
592+
# Ask and validate FQDN hostname.
580593
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
594+
595+
# Set hostname if it wasn't set
596+
if [ -z "$servername" ]; then
597+
servername=$(hostname -f)
598+
fi
599+
600+
# Validate Hostname, go to loop if the validation fails.
601+
while validate_hostname; do
602+
echo -e "\nPlease use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
603+
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
604+
done
605+
else
606+
# Validate FQDN hostname if it is preset
607+
if validate_hostname; then
608+
echo "Please use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
609+
exit 1
610+
fi
581611
fi
582612
fi
583613

@@ -586,11 +616,6 @@ if [ -z "$vpass" ]; then
586616
vpass=$(gen_pass)
587617
fi
588618

589-
# Set hostname if it wasn't set
590-
if [ -z "$servername" ]; then
591-
servername=$(hostname -f)
592-
fi
593-
594619
# Set FQDN if it wasn't set
595620
mask1='(([[:alnum:]](-?[[:alnum:]])*)\.)'
596621
mask2='*[[:alnum:]](-?[[:alnum:]])+\.[[:alnum:]]{2,}'

install/hst-install-ubuntu.sh

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ HESTIA_INSTALL_DIR="$HESTIA/install/deb"
2323
VERBOSE='no'
2424

2525
# Define software versions
26-
HESTIA_INSTALL_VER='11.4.13~alpha'
26+
HESTIA_INSTALL_VER='1.4.13~alpha'
2727
pma_v='5.1.1'
2828
rc_v="1.4.11"
2929
multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0")
@@ -150,6 +150,18 @@ sort_config_file(){
150150
cp $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
151151
}
152152

153+
# Validate hostname according to RFC1178
154+
validate_hostname () {
155+
if [[ $(echo "$servername" | grep -o "\." | wc -l) -gt 1 ]] && [[ ! $servername =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
156+
# Hostname valid
157+
return 1
158+
else
159+
# Hostname invalid
160+
return 0
161+
fi
162+
}
163+
164+
153165
#----------------------------------------------------------#
154166
# Verifications #
155167
#----------------------------------------------------------#
@@ -549,7 +561,25 @@ if [ "$interactive" = 'yes' ]; then
549561

550562
# Asking to set FQDN hostname
551563
if [ -z "$servername" ]; then
564+
# Ask and validate FQDN hostname.
552565
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
566+
567+
# Set hostname if it wasn't set
568+
if [ -z "$servername" ]; then
569+
servername=$(hostname -f)
570+
fi
571+
572+
# Validate Hostname, go to loop if the validation fails.
573+
while validate_hostname; do
574+
echo -e "\nPlease use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
575+
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
576+
done
577+
else
578+
# Validate FQDN hostname if it is preset
579+
if validate_hostname; then
580+
echo "Please use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
581+
exit 1
582+
fi
553583
fi
554584
fi
555585

@@ -558,11 +588,6 @@ if [ -z "$vpass" ]; then
558588
vpass=$(gen_pass)
559589
fi
560590

561-
# Set hostname if it wasn't set
562-
if [ -z "$servername" ]; then
563-
servername=$(hostname -f)
564-
fi
565-
566591
# Set FQDN if it wasn't set
567592
mask1='(([[:alnum:]](-?[[:alnum:]])*)\.)'
568593
mask2='*[[:alnum:]](-?[[:alnum:]])+\.[[:alnum:]]{2,}'

install/upgrade/versions/1.4.13.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,25 @@
55
#######################################################################################
66
####### Place additional commands below. #######
77
#######################################################################################
8+
####### New Feature: UPGRADE_MESSAGE #######
9+
####### #######
10+
####### Add your text to UPGRADE_MESSAGE to include a message to the upgrade #######
11+
####### email. Do not overwrite the variable, it could already contains prior #######
12+
####### content of another upgrade script. Please add it using: #######
13+
####### #######
14+
####### UPGRADE_MESSAGE="$UPGRADE_MESSAGE\nYour Upgrade Notification Text" #######
15+
####### #######
16+
####### Always start and end with \n to generate a new line. #######
17+
#######################################################################################
18+
19+
20+
# Check if hostname is valid according to RFC1178
21+
if [[ $(echo "$servername" | grep -o "\." | wc -l) -lt 2 ]] || [[ $servername =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]];; then
22+
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"
23+
$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>."
24+
fi
825

26+
# Empty $HESTIA/ssl/mail/ due to bug in #2066
927
if [ -e "$HESTIA/ssl/mail/" ]; then
1028
rm -fr $HESTIA/ssl/mail/*
1129
fi

0 commit comments

Comments
 (0)