Skip to content

Commit c6d2006

Browse files
authored
Merge pull request hestiacp#1646 from hestiacp/fix/2021-03-incorrect-handling-dns
Fixed multiple small issues
2 parents 7a9d272 + ee30284 commit c6d2006

File tree

4 files changed

+16
-206
lines changed

4 files changed

+16
-206
lines changed

bin/v-add-dns-record

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
# Argument definition
1919
user=$1
2020
domain=$(idn -t --quiet -a "$2" )
21-
record=$(idn -t --quiet -a "$3" )
21+
record=$(idn -t --quiet -u "$3" )
2222
record=$(echo "$record" | tr '[:upper:]' '[:lower:]')
2323
rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]')
24-
dvalue=$(idn -t --quiet -a "$5" )
24+
dvalue=$(idn -t --quiet -u "$5" )
2525
priority=$6
2626
id=$7
2727
restart=$8
@@ -49,6 +49,11 @@ if [[ $rtype =~ NS|CNAME|MX|PTR|SRV ]]; then
4949
fi
5050
fi
5151

52+
if [[ $rtype =~ NS|CNAME|MX|PTR|SRV ]]; then
53+
dvalue=$(idn -t --quiet -a "$dvalue" )
54+
record=$(idn -t --quiet -a "$record" )
55+
fi
56+
5257
# Cleanup quotes on dvalue
5358
# - [CAA] records will be left unchanged
5459
# - [SRV] will be stripped of double quotes even when containg spaces

bin/v-add-sys-webmail

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Argument definition
1616
user=$1
17-
domain=$2
17+
domain=$(idn -t --quiet -a "$2")
1818
webmail=$3
1919
restart="$4"
2020
quiet=$5
@@ -30,8 +30,6 @@ if [[ "$domain" =~ .*\.$ ]]; then
3030
domain=$(echo "$domain" |sed -e "s/\.$//")
3131
fi
3232

33-
domain_idn=$(idn -t --quiet -a "$domain")
34-
3533
# Includes
3634
source $HESTIA/func/main.sh
3735
source $HESTIA/func/domain.sh

bin/v-delete-sys-webmail

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Argument definition
1616
user=$1
17-
domain=$2
17+
domain=$(idn -t --quiet -a "$2")
1818
restart="$3"
1919
quiet=$4
2020

test/test.bats

Lines changed: 7 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ function validate_database(){
333333

334334
run v-add-cron-job $user 1 1 1 1 1 echo 1
335335
assert_failure $E_EXISTS
336-
assert_output --partial 'JOB=1 is already exists'
336+
assert_output --partial 'JOB=1 already exists'
337337
}
338338

339339
@test "Cron: Second cron job" {
@@ -510,6 +510,12 @@ function validate_database(){
510510
refute_output
511511
}
512512

513+
@test "WEB: Delete web domain wildcard alias" {
514+
run v-delete-web-domain-alias $user $domain "*.$domain"
515+
assert_success
516+
refute_output
517+
}
518+
513519
@test "WEB: Add web domain stats" {
514520
run v-add-web-domain-stats $user $domain awstats
515521
assert_success
@@ -838,205 +844,6 @@ function validate_database(){
838844
refute_output
839845
}
840846

841-
#----------------------------------------------------------#
842-
# MULTIPHP #
843-
#----------------------------------------------------------#
844-
845-
@test "Multiphp: Default php Backend version" {
846-
def_phpver=$(multiphp_default_version)
847-
multi_domain="multiphp.${domain}"
848-
849-
run v-add-web-domain $user $multi_domain 198.18.0.125
850-
assert_success
851-
refute_output
852-
853-
echo -e "<?php\necho PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
854-
validate_web_domain $user $multi_domain "$def_phpver" 'php-test.php'
855-
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
856-
857-
}
858-
859-
@test "Multiphp: Change backend version - PHP v5.6" {
860-
test_phpver='5.6'
861-
multi_domain="multiphp.${domain}"
862-
863-
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
864-
skip "PHP ${test_phpver} not installed"
865-
fi
866-
867-
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-5_6' 'yes'
868-
assert_success
869-
refute_output
870-
871-
# Changing web backend will create a php-fpm pool config in the corresponding php folder
872-
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
873-
874-
# A single php-fpm pool config file must be present
875-
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
876-
assert_equal "$num_fpm_config_files" '1'
877-
878-
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
879-
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
880-
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
881-
}
882-
883-
@test "Multiphp: Change backend version - PHP v7.0" {
884-
test_phpver='7.0'
885-
multi_domain="multiphp.${domain}"
886-
887-
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
888-
skip "PHP ${test_phpver} not installed"
889-
fi
890-
891-
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_0' 'yes'
892-
assert_success
893-
refute_output
894-
895-
# Changing web backend will create a php-fpm pool config in the corresponding php folder
896-
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
897-
898-
# A single php-fpm pool config file must be present
899-
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
900-
assert_equal "$num_fpm_config_files" '1'
901-
902-
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
903-
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
904-
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
905-
}
906-
907-
@test "Multiphp: Change backend version - PHP v7.1" {
908-
test_phpver='7.1'
909-
multi_domain="multiphp.${domain}"
910-
911-
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
912-
skip "PHP ${test_phpver} not installed"
913-
fi
914-
915-
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_1' 'yes'
916-
assert_success
917-
refute_output
918-
919-
# Changing web backend will create a php-fpm pool config in the corresponding php folder
920-
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
921-
922-
# A single php-fpm pool config file must be present
923-
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
924-
assert_equal "$num_fpm_config_files" '1'
925-
926-
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
927-
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
928-
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
929-
}
930-
931-
@test "Multiphp: Change backend version - PHP v7.2" {
932-
test_phpver='7.2'
933-
multi_domain="multiphp.${domain}"
934-
935-
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
936-
skip "PHP ${test_phpver} not installed"
937-
fi
938-
939-
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_2' 'yes'
940-
assert_success
941-
refute_output
942-
943-
# Changing web backend will create a php-fpm pool config in the corresponding php folder
944-
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
945-
946-
# A single php-fpm pool config file must be present
947-
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
948-
assert_equal "$num_fpm_config_files" '1'
949-
950-
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
951-
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
952-
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
953-
}
954-
955-
@test "Multiphp: Change backend version - PHP v7.3" {
956-
test_phpver='7.3'
957-
multi_domain="multiphp.${domain}"
958-
959-
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
960-
skip "PHP ${test_phpver} not installed"
961-
fi
962-
963-
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_3' 'yes'
964-
assert_success
965-
refute_output
966-
967-
# Changing web backend will create a php-fpm pool config in the corresponding php folder
968-
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
969-
970-
# A single php-fpm pool config file must be present
971-
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
972-
assert_equal "$num_fpm_config_files" '1'
973-
974-
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
975-
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
976-
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
977-
}
978-
979-
@test "Multiphp: Change backend version - PHP v7.4" {
980-
test_phpver='7.4'
981-
multi_domain="multiphp.${domain}"
982-
983-
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
984-
skip "PHP ${test_phpver} not installed"
985-
fi
986-
987-
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_4' 'yes'
988-
assert_success
989-
refute_output
990-
991-
# Changing web backend will create a php-fpm pool config in the corresponding php folder
992-
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
993-
994-
# A single php-fpm pool config file must be present
995-
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
996-
assert_equal "$num_fpm_config_files" '1'
997-
998-
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
999-
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
1000-
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
1001-
}
1002-
1003-
@test "Multiphp: Change backend version - PHP v8.0" {
1004-
test_phpver='8.0'
1005-
multi_domain="multiphp.${domain}"
1006-
1007-
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
1008-
skip "PHP ${test_phpver} not installed"
1009-
fi
1010-
1011-
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-8_0' 'yes'
1012-
assert_success
1013-
refute_output
1014-
1015-
# Changing web backend will create a php-fpm pool config in the corresponding php folder
1016-
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
1017-
1018-
# A single php-fpm pool config file must be present
1019-
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
1020-
assert_equal "$num_fpm_config_files" '1'
1021-
1022-
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
1023-
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
1024-
rm $HOMEDIR/$user/web/$multi_domain/public_html/php-test.php
1025-
}
1026-
1027-
@test "Multiphp: Cleanup" {
1028-
multi_domain="multiphp.${domain}"
1029-
1030-
run v-delete-web-domain $user $multi_domain 'yes'
1031-
assert_success
1032-
refute_output
1033-
1034-
# No php-fpm pool config file must be present
1035-
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
1036-
assert_equal "$num_fpm_config_files" '0'
1037-
}
1038-
1039-
1040847
#----------------------------------------------------------#
1041848
# DNS #
1042849
#----------------------------------------------------------#

0 commit comments

Comments
 (0)