Skip to content

Commit 3fdf201

Browse files
committed
Fix access rights
1 parent 007f3f4 commit 3fdf201

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

docker/scripts/05-permissions-check.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,36 @@ find /app/bootstrap/cache -type d \( ! -perm 750 \) -exec chmod 750 {} + 2>/dev/
2727
# Files: 640 for sensitive, 644 for public
2828
find /app/storage -type f \( ! -perm 640 \) -exec chmod 640 {} + 2>/dev/null || true
2929
find /app/bootstrap/cache -type f \( ! -perm 640 \) -exec chmod 640 {} + 2>/dev/null || true
30-
echo "✅ Permissions set securely"
30+
31+
echo "⏰ Set Permissions for dist folder..."
32+
# dist ships baked-in files (e.g. user.css, custom.js) that must always be
33+
# writable by www-data, regardless of SKIP_PERMISSIONS_CHECKS
34+
find /app/public/dist -type d \( ! -user "www-data" -o ! -group "www-data" \) -exec chown "www-data":"www-data" {} + 2>/dev/null || true
35+
find /app/public/dist -type f \( ! -user "www-data" -o ! -group "www-data" \) -exec chown "www-data":"www-data" {} + 2>/dev/null || true
36+
find /app/public/dist -type d \( ! -perm 755 \) -exec chmod 755 {} + 2>/dev/null || true
37+
find /app/public/dist -type f \( ! -perm 644 \) -exec chmod 644 {} + 2>/dev/null || true
3138

3239
# Safely check SKIP_PERMISSIONS_CHECKS
3340
skip_check="${SKIP_PERMISSIONS_CHECKS:-no}"
3441

3542
if [ "$skip_check" = "yes" ] || [ "$skip_check" = "YES" ]; then
3643
echo "⚠️ WARNING: Skipping upload permissions check"
3744
else
38-
echo "⏰ Set Permissions for Upload/dist folders (this may take a while)..."
45+
echo "⏰ Set Permissions for Upload folder (this may take a while)..."
3946

4047
# More restrictive permissions - no world-readable for sensitive directories
4148
# Only set permissions on writable directories that need it
4249

43-
# Ensure www-data owns necessary directories
50+
# Ensure www-data owns necessary directories and files
4451
find /app/public/uploads -type d \( ! -user "www-data" -o ! -group "www-data" \) -exec chown "www-data":"www-data" {} + 2>/dev/null || true
45-
find /app/public/dist -type d \( ! -user "www-data" -o ! -group "www-data" \) -exec chown "www-data":"www-data" {} + 2>/dev/null || true
52+
find /app/public/uploads -type f \( ! -user "www-data" -o ! -group "www-data" \) -exec chown "www-data":"www-data" {} + 2>/dev/null || true
4653

4754
# Upload directories need 755 for web serving
4855
find /app/public/uploads -type d \( ! -perm 755 \) -exec chmod 755 {} + 2>/dev/null || true
49-
find /app/public/dist -type d \( ! -perm 755 \) -exec chmod 755 {} + 2>/dev/null || true
5056

5157
# Files: 640 for sensitive, 644 for public
5258
find /app/public/uploads -type f \( ! -perm 644 \) -exec chmod 644 {} + 2>/dev/null || true
53-
find /app/public/dist -type f \( ! -perm 644 \) -exec chmod 644 {} + 2>/dev/null || true
5459

55-
echo "✅ Permissions set securely"
5660
fi
61+
62+
echo "✅ Permissions set securely"

0 commit comments

Comments
 (0)