@@ -110,7 +110,7 @@ prepare_web_backend() {
110110 pool=$( find -L /etc/php/$backend_version -type d \( -name " pool.d" -o -name " *fpm.d" \) )
111111 else
112112 backend_version=$( multiphp_default_version)
113- if [ -z " $pool " ] || [ -z " $BACKEND " ]; then
113+ if [ -z " $pool " ] || [ -z " $BACKEND " ]; then
114114 pool=$( find -L /etc/php/$backend_version -type d \( -name " pool.d" -o -name " *fpm.d" \) )
115115 fi
116116 fi
@@ -177,7 +177,7 @@ prepare_web_domain_values() {
177177 sdocroot=" $HOMEDIR /$user /web/$domain /public_shtml"
178178 $BIN /v-add-fs-directory " $user " " $HOMEDIR /$user /web/$domain /public_shtml" ;
179179 chmod 751 $HOMEDIR /$user /web/$domain /public_shtml;
180- chown www-data:$user $HOMEDIR /$user /web/$domain /public_shtml;
180+ chown www-data:$user $HOMEDIR /$user /web/$domain /public_shtml;
181181 fi
182182
183183 if [ -n " $WEB_BACKEND " ]; then
@@ -342,7 +342,7 @@ get_web_config_lines() {
342342 domain_idn=$domain
343343 format_domain_idn
344344 vhost_lines=$( grep -niF " name $domain_idn " $2 )
345- vhost_lines=$( echo " $vhost_lines " | egrep " $domain_idn ($| |;)" ) # "
345+ vhost_lines=$( echo " $vhost_lines " | egrep " $domain_idn ($| |;)" )
346346 vhost_lines=$( echo " $vhost_lines " | cut -f 1 -d :)
347347 if [ -z " $vhost_lines " ]; then
348348 check_result $E_PARSING " can't parse config $2 "
@@ -715,23 +715,29 @@ add_mail_ssl_config() {
715715 cp -f $USER_DATA /ssl/mail.$domain .ca $HOMEDIR /$user /conf/mail/$domain /ssl/$domain .ca
716716 fi
717717
718- # Add domain SSL configuration to dovecot
718+ # Clean up dovecot configuration (if it exists)
719719 if [ -f /etc/dovecot/conf.d/domains/$domain .conf ]; then
720720 rm -f /etc/dovecot/conf.d/domains/$domain .conf
721721 fi
722-
723- mail_check=$( $BIN /v-list-mail-domain-ssl " $user " " $domain " | grep SUBJECT | grep " $domain " ) ;
724- mail_check_alias=$( $BIN /v-list-mail-domain-ssl " $user " " $domain " | grep ALIASES | grep " $domain " ) ;
725- if [ -n " $mail_check " ] || [ -n " $mail_check_alias " ]; then
722+
723+ # Check if using custom / wildcard mail certificate
724+ wildcard_domain=" \\ *.$( echo " $domain " | cut -f 1 -d . --complement) "
725+ mail_cert_match=$( $BIN /v-list-mail-domain-ssl $user $domain | awk ' /SUBJECT|ALIASES/' | grep -wE " $domain | $wildcard_domain " ) ;
726+
727+ if [ -n " $mail_cert_match " ]; then
728+ # Add domain SSL configuration to dovecot
726729 echo " " >> /etc/dovecot/conf.d/domains/$domain .conf
727730 echo " local_name $domain {" >> /etc/dovecot/conf.d/domains/$domain .conf
728731 echo " ssl_cert = <$HOMEDIR /$user /conf/mail/$domain /ssl/$domain .pem" >> /etc/dovecot/conf.d/domains/$domain .conf
729732 echo " ssl_key = <$HOMEDIR /$user /conf/mail/$domain /ssl/$domain .key" >> /etc/dovecot/conf.d/domains/$domain .conf
730733 echo " }" >> /etc/dovecot/conf.d/domains/$domain .conf
734+
731735 # Add domain SSL configuration to exim4
732736 ln -s $HOMEDIR /$user /conf/mail/$domain /ssl/$domain .pem $HESTIA /ssl/mail/$domain .crt
733737 ln -s $HOMEDIR /$user /conf/mail/$domain /ssl/$domain .key $HESTIA /ssl/mail/$domain .key
734738 fi
739+
740+ # Add domain SSL configuration to dovecot
735741 echo " " >> /etc/dovecot/conf.d/domains/$domain .conf
736742 echo " local_name mail.$domain {" >> /etc/dovecot/conf.d/domains/$domain .conf
737743 echo " ssl_cert = <$HOMEDIR /$user /conf/mail/$domain /ssl/$domain .pem" >> /etc/dovecot/conf.d/domains/$domain .conf
@@ -753,9 +759,9 @@ add_mail_ssl_config() {
753759
754760# Delete SSL support for mail domain
755761del_mail_ssl_config () {
756- # Do a few checks to prevent accidentally removal of domain.com
757- mail_check= $( v-list-mail-domain-ssl $user $ domain | grep SUBJECT | grep " $domain " ) ;
758- mail_check_alias =$( v-list-mail-domain-ssl $user $domain | grep ALIASES | grep " $domain " ) ;
762+ # Check to prevent accidental removal of mismatched certificate
763+ wildcard_domain= " \\ *. $( echo " $ domain" | cut -f 1 -d . --complement ) "
764+ mail_cert_match =$( $BIN / v-list-mail-domain-ssl $user $domain | awk ' /SUBJECT| ALIASES/ ' | grep -wE " $domain | $wildcard_domain " ) ;
759765
760766 # Remove old mail certificates
761767 rm -f $HOMEDIR /$user /conf/mail/$domain /ssl/*
@@ -770,7 +776,7 @@ del_mail_ssl_config() {
770776
771777 # Remove SSL certificates
772778 rm -f $HOMEDIR /$user /conf/mail/$domain /ssl/*
773- if [ -n " $mail_check " ] || [ -n " $mail_check_alias " ]; then
779+ if [ -n " $mail_cert_match " ]; then
774780 rm -f $HESTIA /ssl/mail/$domain .crt $HESTIA /ssl/mail/$domain .key
775781 fi
776782 rm -f $HESTIA /ssl/mail/mail.$domain .crt $HESTIA /ssl/mail/mail.$domain .key
@@ -802,7 +808,6 @@ add_webmail_config() {
802808 if [ " $WEBMAIL_ALIAS " != " mail" ]; then
803809 override_alias=" mail.$domain "
804810 override_alias_idn=" mail.$domain_idn "
805-
806811 fi
807812
808813 # Note: Removing or renaming template variables will lead to broken custom templates.
0 commit comments