Skip to content

Commit 05f7b64

Browse files
authored
check if folder exist first. (hestiacp#2789)
there was a minor bug where,, if the folder didn't exist, we would say "Target dir outside of target domain dir" instead of "folder does not exist" because we checked them in the wrong order ^^ PS untested as of writing, but in theory this should fix it.
1 parent 9d3b247 commit 05f7b64

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

bin/v-change-web-domain-docroot

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,12 @@ else
8686
# Check for existence of specified directory under target domain's public_html folder
8787
target_domain_directory="$HOMEDIR/$user/web/$target_domain"
8888
if [ -n "$target_directory" ]; then
89-
9089
# Checking destination path
9190
real_target_directory="$(readlink -e "${target_domain_directory}/public_html/$target_directory/")"
92-
if [ -z "$(echo $real_target_directory | egrep "^$target_domain_directory\b")" ]; then
93-
check_result "$E_FORBIDEN" "Target dir outside of target domain dir"
94-
fi
95-
9691
if [ ! -e "$real_target_directory" ]; then
9792
check_result "$E_NOTEXIST" "Directory $target_directory does not exist under $HOMEDIR/$user/$target_domain/public_html/."
93+
elif [ -z "$(echo $real_target_directory | egrep "^$target_domain_directory\b")" ]; then
94+
check_result "$E_FORBIDEN" "Target dir outside of target domain dir"
9895
else
9996
CUSTOM_DOCROOT="$real_target_directory"
10097
if [ -n "$php" ]; then

0 commit comments

Comments
 (0)