Skip to content

Commit 68320a6

Browse files
authored
Add check for mail subdomain
1 parent 2f7fba8 commit 68320a6

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

func/domain.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,25 @@ is_mail_domain_new() {
621621
if [ "$2" == 'mail' ]; then
622622
check_result $E_EXISTS "Mail domain $1 exists"
623623
fi
624-
mail_user=$(echo "$mail" |cut -f 7 -d /)
624+
mail_user=$(echo "$mail" | cut -f 7 -d /)
625625
if [ "$mail_user" != "$user" ]; then
626626
check_result $E_EXISTS "Mail domain $1 exists"
627627
fi
628628
fi
629+
mail_sub=$(echo "$1" | cut -f 1 -d .)
630+
mail_nosub=$(echo "$1" | cut -f 1 -d . --complement)
631+
for mail_reserved in $(echo "mail $WEBMAIL_ALIAS"); do
632+
if [ ! -z "$(ls $HESTIA/data/users/*/mail/$mail_reserved.$1.conf 2>/dev/null)" ]; then
633+
if [ "$2" == 'mail' ]; then
634+
check_result $E_EXISTS "Required subdomain \"$mail_reserved.$1\" already exists"
635+
fi
636+
fi
637+
if [ ! -z "$(ls $HESTIA/data/users/*/mail/$mail_nosub.conf 2>/dev/null)" ] && [ "$mail_sub" = "$mail_reserved" ]; then
638+
if [ "$2" == 'mail' ]; then
639+
check_result $E_INVALID "The subdomain \"$mail_sub.\" is reserved by \"$mail_nosub\""
640+
fi
641+
fi
642+
done
629643
}
630644

631645
# Checking mail account existance
@@ -641,7 +655,6 @@ is_mail_new() {
641655
fi
642656
}
643657

644-
645658
# Add mail server SSL configuration
646659
add_mail_ssl_config() {
647660
# Ensure that SSL certificate directories exists

0 commit comments

Comments
 (0)