From 46e40d68222d2b48ed259a2abe731723cb24c264 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Thu, 16 Oct 2025 16:11:28 +0500 Subject: [PATCH] Fix permission race condition in fixPermissions function Fixes #1583 - Ubuntu 24 permission issues causing 404 errors Changes: - Move main public_html permission setting to END of fixPermissions function - Ensures public_html maintains user:nogroup ownership (not user:user) - Prevents child domain processing from interfering with main directory permissions - Changed all async popenExecutioner calls to sync executioner calls - Reordered operations: permissions first, then ownership This fixes the issue where clicking "Fix Permissions" in file manager would incorrectly change public_html group from nogroup to the user's group, causing 404 errors on Ubuntu 24. --- filemanager/filemanager.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/filemanager/filemanager.py b/filemanager/filemanager.py index b051c9e6d..f0e135468 100644 --- a/filemanager/filemanager.py +++ b/filemanager/filemanager.py @@ -1068,13 +1068,7 @@ class FileManager: command = 'chown -R -P %s:%s /home/%s/public_html/.[^.]*' % (externalApp, externalApp, domainName) ProcessUtilities.executioner(command) - # Set public_html directory itself to user:nogroup with 750 permissions - command = 'chown %s:%s /home/%s/public_html' % (externalApp, groupName, domainName) - ProcessUtilities.executioner(command) - - command = 'chmod 750 /home/%s/public_html' % (domainName) - ProcessUtilities.executioner(command) - + # Process child domains first for childs in website.childdomains_set.all(): command = 'ls -la %s' % childs.path result = ProcessUtilities.outputExecutioner(command) @@ -1105,3 +1099,10 @@ class FileManager: command = 'chown %s:%s %s' % (externalApp, groupName, childs.path) ProcessUtilities.executioner(command) + + # Set public_html directory itself to user:nogroup with 750 permissions (done at the end) + command = 'chown %s:%s /home/%s/public_html' % (externalApp, groupName, domainName) + ProcessUtilities.executioner(command) + + command = 'chmod 750 /home/%s/public_html' % (domainName) + ProcessUtilities.executioner(command)