From 8680995e66e820258bfaede558a5e144120856a8 Mon Sep 17 00:00:00 2001 From: Peca Date: Mon, 4 Aug 2025 15:19:22 +0200 Subject: [PATCH] Avoid 600 permissions for Apache-less variant --- bin/v-fix-user-permissions | 8 ++++---- bin/v-fix-website-permissions | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/v-fix-user-permissions b/bin/v-fix-user-permissions index 991ada62..47690477 100644 --- a/bin/v-fix-user-permissions +++ b/bin/v-fix-user-permissions @@ -49,10 +49,10 @@ find /home/$user/mail/*/ -maxdepth 1 -type d -exec chmod g-rwx {} \; find /home/$user/conf/dns/ -type f -exec chown root:bind {} \; find /home/$user/conf/ -type d -exec chown root:root {} \; -find /home/$user/web/*/public_html/ -type d -exec chmod 755 {} + -find /home/$user/web/*/public_html/ -type f -exec chmod 644 {} + -find /home/$user/web/*/public_html/ -exec chown $user:$user {} \; -find /home/$user/web/*/ -name "*.php" -type f -exec chmod 600 {} + +for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do + /usr/local/vesta/bin/v-fix-website-permissions $domain $user + echo "--------------------------------" +done echo "Done, permissions fixed for user: $user" diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions index 5c1eaca3..186075a1 100644 --- a/bin/v-fix-website-permissions +++ b/bin/v-fix-website-permissions @@ -28,6 +28,7 @@ USER=$user # Includes source /usr/local/vesta/func/main.sh +source /usr/local/vesta/conf/vesta.conf if [ -z "$user" ]; then check_result $E_NOTEXIST "domain $domain doesn't exist" @@ -77,6 +78,11 @@ find public_html/ -type d ! -user $USER -exec chown $USER:$USER {} + find public_html/ -type f ! \( -name "*.php" -o -name "*.env" \) ! -user $USER -exec chown $USER:$USER {} + php_chmod="600" + +if [ "$WEB_SYSTEM" = 'nginx' ]; then + php_chmod="644" +fi + if [ -f "/home/php_chmod" ]; then php_chmod=$(cat /home/php_chmod) fi