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

2568 [Bug] 1.6 Beta Unable to use IDN domains (#2578)

* Replace idn with idn2
* Check if install was success full
* Fix issue with not correctly converting v-add-web-domain / v-add-mail-domain
* Do not convert on default v-add-dns-record
Jaap Marcus 3 лет назад
Родитель
Сommit
fb0c898add

+ 1 - 1
bin/v-add-dns-domain

@@ -41,7 +41,7 @@ source_conf "$HESTIA/conf/hestia.conf"
 # Additional argument formatting
 format_domain
 format_domain_idn
-domain_utf=$(idn -t --quiet -u "$domain_idn")
+domain_utf=$(idn2 --quiet "$domain_idn")
 
 #----------------------------------------------------------#
 #                    Verifications                         #

+ 2 - 2
bin/v-add-dns-record

@@ -17,10 +17,10 @@
 user=$1
 domain=$2
 domain_idn=$2
-record=$(idn -t --quiet -u "$3" )
+record=$(idn2 --quiet "$3" )
 record=$(echo "$record" | tr '[:upper:]' '[:lower:]')
 rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]')
-dvalue=$(idn -t --quiet -u "$5" )
+dvalue=$5
 priority=$6
 id=$7
 restart=$8

+ 1 - 1
bin/v-add-letsencrypt-domain

@@ -184,7 +184,7 @@ echo -e "
 if [ "$proto" = "http-01" ]; then
     for identifier in $(echo $domain,$aliases |tr ',' '\n' |sort -u); do
         if [[ "$identifier" = *[![:ascii:]]* ]]; then
-            identifier=$(idn -t --quiet -a $identifier)
+            identifier=$(idn2 --quiet $identifier)
         fi
         if ! nslookup "${identifier}" > /dev/null 2>&1 ; then
             check_result "$E_NOTEXIST" "DNS record for $identifier doesn't exist"

+ 1 - 1
bin/v-add-mail-domain

@@ -43,7 +43,7 @@ fi
 # Additional argument formatting
 format_domain
 format_domain_idn
-domain_utf=$(idn -t --quiet -u "$domain_idn")
+domain_utf=$(idn2 --quiet -d "$domain_idn")
 
 #----------------------------------------------------------#
 #                    Verifications                         #

+ 1 - 1
bin/v-add-mail-domain-ssl

@@ -28,7 +28,7 @@ if [[ "$domain" =~ .*\.$ ]]; then
     domain=$(echo "$domain" |sed -e "s/\.$//")
 fi
 
-domain_idn=$(idn -t --quiet -a "$domain")
+domain_idn=$(idn2 --quiet "$domain")
 
 # Includes
 # shellcheck source=/etc/hestiacp/hestia.conf

+ 1 - 1
bin/v-add-web-domain

@@ -42,7 +42,7 @@ source_conf "$HESTIA/conf/hestia.conf"
 format_domain
 format_domain_idn
 format_aliases
-domain_utf=$(idn -t --quiet -u "$domain_idn")
+domain_utf=$(idn2 --quiet -d "$domain_idn")
 
 #----------------------------------------------------------#
 #                    Verifications                         #

+ 2 - 2
bin/v-delete-dns-on-web-alias

@@ -15,10 +15,10 @@ user=$1
 domain=$2
 alias=$3
 domain_idn=$2
-dom_alias=$(idn -t --quiet -u "$3" )
+dom_alias=$(idn2 --quiet -d "$3" )
 dom_alias=$(echo $dom_alias |sed -e 's/\.*$//g' -e 's/^\.*//g')
 dom_alias=$(echo $dom_alias |tr '[:upper:]' '[:lower:]')
-dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
+dom_alias_idn=$(idn2  --quiet "$dom_alias" )
 restart="$4"
 
 # Includes

+ 8 - 8
func/domain.sh

@@ -142,7 +142,7 @@ prepare_web_aliases() {
     for tmp_alias in ${1//,/ }; do
         tmp_alias_idn="$tmp_alias"
         if [[ "$tmp_alias" = *[![:ascii:]]* ]]; then
-            tmp_alias_idn=$(idn -t --quiet -a $tmp_alias)
+            tmp_alias_idn=$(idn2 --quiet $tmp_alias)
         fi
         if [[ $i -eq 1 ]]; then
             aliases="$tmp_alias"
@@ -165,7 +165,7 @@ prepare_web_aliases() {
 # Update web domain values
 prepare_web_domain_values() {
     if [[ "$domain" = *[![:ascii:]]* ]]; then
-        domain_idn=$(idn -t --quiet -a $domain)
+        domain_idn=$(idn2 --quiet $domain)
     else
         domain_idn=$domain
     fi
@@ -479,12 +479,12 @@ update_domain_zone() {
     domain_param=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
     parse_object_kv_list "$domain_param"
     local zone_ttl="$TTL"
-    SOA=$(idn --quiet -a -t "$SOA")
+    SOA=$(idn2 --quiet  "$SOA")
     if [ -z "$SERIAL" ]; then
         SERIAL=$(date +'%Y%m%d01')
     fi
     if [[ "$domain" = *[![:ascii:]]* ]]; then
-        domain_idn=$(idn -t --quiet -a $domain)
+        domain_idn=$(idn2 --quiet $domain)
     else
         domain_idn=$domain
     fi
@@ -508,9 +508,9 @@ update_domain_zone() {
         # inherit zone TTL if record lacks explicit TTL value
         [ -z "$TTL" ] && TTL="$zone_ttl"
 
-        RECORD=$(idn --quiet -a -t "$RECORD")
+        RECORD=$(idn2 --quiet  "$RECORD")
         if [ "$TYPE" = 'CNAME' ] || [ "$TYPE" = 'MX' ]; then
-            VALUE=$(idn --quiet -a -t "$VALUE")
+            VALUE=$(idn2 --quiet  "$VALUE")
         fi
         
         if [ "$TYPE" = 'TXT' ]; then
@@ -940,7 +940,7 @@ is_valid_extension() {
         chmod 750 $HESTIA/data/extensions/
         /usr/bin/wget --tries=3 --timeout=15 --read-timeout=15 --waitretry=3 --no-dns-cache --quiet -O $HESTIA/data/extensions/public_suffix_list.dat https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat 
     fi
-    test_domain=$(idn -t --quiet -u "$1" )
+    test_domain=$(idn2 -d  "$1" )
     extension=$( /bin/echo "${test_domain}" | /usr/bin/rev | /usr/bin/cut -d "." --output-delimiter="." -f 1 | /usr/bin/rev );
     exten=$(grep "^$extension\$" $HESTIA/data/extensions/public_suffix_list.dat);
 }
@@ -951,7 +951,7 @@ is_valid_2_part_extension() {
         chmod 750 $HESTIA/data/extensions/
         /usr/bin/wget --tries=3 --timeout=15 --read-timeout=15 --waitretry=3 --no-dns-cache --quiet -O $HESTIA/data/extensions/public_suffix_list.dat https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat 
     fi
-    test_domain=$(idn -t --quiet -u "$1" )
+    test_domain=$(idn2 -d  "$1" )
     extension=$( /bin/echo "${test_domain}" | /usr/bin/rev | /usr/bin/cut -d "." --output-delimiter="." -f 1-2 | /usr/bin/rev );
     exten=$(grep "^$extension\$" $HESTIA/data/extensions/public_suffix_list.dat);
 }

+ 1 - 1
func/main.sh

@@ -1359,7 +1359,7 @@ format_domain_idn() {
         domain_idn=$domain
     fi
     if [[ "$domain_idn" = *[![:ascii:]]* ]]; then
-        domain_idn=$(idn -t --quiet -a $domain_idn)
+        domain_idn=$(idn2 --quiet $domain_idn)
     fi
 }
 

+ 2 - 2
func/rebuild.sh

@@ -465,7 +465,7 @@ rebuild_dns_domain_conf() {
 
     # Get domain values
     get_domain_values 'dns'
-    domain_idn=$(idn -t --quiet -a "$domain")
+    domain_idn=$(idn2 --quiet "$domain")
 
     # Checking zone file
     if [ ! -e "$USER_DATA/dns/$domain.conf" ]; then
@@ -533,7 +533,7 @@ rebuild_mail_domain_conf() {
     
     get_domain_values 'mail'
     if [[ "$domain" = *[![:ascii:]]* ]]; then
-        domain_idn=$(idn -t --quiet -a $domain)
+        domain_idn=$(idn2 --quiet $domain)
     else
         domain_idn=$domain
     fi

+ 1 - 1
install/hst-install-debian.sh

@@ -49,7 +49,7 @@ software="nginx apache2 apache2-utils apache2-suexec-custom
   awstats vsftpd proftpd-basic bind9 exim4 exim4-daemon-heavy
   clamav-daemon spamassassin dovecot-imapd dovecot-pop3d dovecot-sieve dovecot-managesieved
   net-tools mariadb-client mariadb-common mariadb-server postgresql
-  postgresql-contrib phppgadmin mc flex whois git idn unzip zip sudo bc ftp lsof
+  postgresql-contrib phppgadmin mc flex whois git idn2 unzip zip sudo bc ftp lsof
   rrdtool quota e2fslibs bsdutils e2fsprogs curl imagemagick fail2ban
   dnsutils bsdmainutils cron hestia=${HESTIA_INSTALL_VER} hestia-nginx
   hestia-php expect libmail-dkim-perl unrar-free vim-common acl sysstat

+ 1 - 1
install/hst-install-ubuntu.sh

@@ -43,7 +43,7 @@ mariadb_v="10.6"
 software="apache2 apache2.2-common apache2-suexec-custom apache2-utils
     apparmor-utils awstats bc bind9 bsdmainutils bsdutils clamav-daemon
     cron curl dnsutils dovecot-imapd dovecot-pop3d dovecot-sieve dovecot-managesieved
-    e2fslibs e2fsprogs exim4 exim4-daemon-heavy expect fail2ban flex ftp git idn
+    e2fslibs e2fsprogs exim4 exim4-daemon-heavy expect fail2ban flex ftp git idn2
     imagemagick libapache2-mod-fcgid libapache2-mod-php$fpm_v libapache2-mod-rpaf
     lsof mc mariadb-client mariadb-common mariadb-server nginx
     php$fpm_v php$fpm_v-cgi php$fpm_v-common php$fpm_v-curl

+ 1 - 1
src/deb/hestia/control

@@ -6,7 +6,7 @@ Section: admin
 Maintainer: HestiaCP <info@hestiacp.com>
 Homepage: https://www.hestiacp.com
 Architecture: amd64
-Depends: bash, awk, sed, acl, sysstat, setpriv | util-linux (>= 2.33), zstd, lsb-release
+Depends: bash, awk, sed, acl, sysstat, setpriv | util-linux (>= 2.33), zstd, lsb-release, idn2
 Description: hestia
  hestia is an open source hosting control panel.
  hestia has a clean and focused interface without the clutter.

+ 6 - 0
src/hst_autocompile.sh

@@ -721,10 +721,16 @@ if [ "$install" = 'yes' ] || [ "$install" = 'y' ] || [ "$install" = 'true' ]; th
     if [ "$OSTYPE" = 'rhel' ]; then
         for i in $RPM_DIR/*.rpm; do
             dnf -y install $i
+            if [ $? -ne 0 ]; then
+              exit 1;
+            fi
         done
     else
         for i in $DEB_DIR/*.deb; do
             dpkg -i $i
+            if [ $? -ne 0 ]; then
+              exit 1;
+            fi
         done
     fi
     unset $answer

+ 1 - 1
test/test.bats

@@ -814,7 +814,7 @@ function check_ip_not_banned(){
 
 @test "WEB: Add IDN domain ASCII idn-tést.eu" {
    # Expected to fail due to utf exists
-   run v-add-web-domain $user $( idn -a idn-tést.eu) 198.18.0.125
+   run v-add-web-domain $user "xn--idn-tst-fya.eu" 198.18.0.125
    assert_failure $E_EXISTS
 }