Skip to content

Commit acc6cad

Browse files
committed
Fix permission issues on Ubuntu 24 causing 404 errors
Fixes #1583 The fixPermissions function in file manager was causing sites to become inaccessible after running "Fix Permissions" on Ubuntu 24. The root causes: 1. Async execution (popenExecutioner) caused race conditions where commands executed in unpredictable order 2. The public_html directory group was incorrectly changed from 'nogroup' to the user's group, breaking web server access Changes: - Changed all async popenExecutioner calls to sync executioner calls - Reordered commands to set permissions before ownership - Ensured public_html directory maintains correct group ownership (nogroup) - Added comments to clarify the purpose of each step This ensures the file manager's "Fix Permissions" feature works correctly on Ubuntu 24 while maintaining proper security.
1 parent 9d0d5fb commit acc6cad

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

filemanager/filemanager.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,8 +1039,9 @@ def fixPermissions(self, domainName):
10391039
'error_message': "Symlink attack."})
10401040
return HttpResponse(final_json)
10411041

1042+
# Set home directory ownership
10421043
command = 'chown %s:%s /home/%s' % (website.externalApp, website.externalApp, domainName)
1043-
ProcessUtilities.popenExecutioner(command)
1044+
ProcessUtilities.executioner(command)
10441045

10451046
### Sym link checks
10461047

@@ -1053,21 +1054,21 @@ def fixPermissions(self, domainName):
10531054
'error_message': "Symlink attack."})
10541055
return HttpResponse(final_json)
10551056

1056-
command = 'chown -R -P %s:%s /home/%s/public_html/*' % (externalApp, externalApp, domainName)
1057-
ProcessUtilities.popenExecutioner(command)
1058-
1059-
command = 'chown -R -P %s:%s /home/%s/public_html/.[^.]*' % (externalApp, externalApp, domainName)
1060-
ProcessUtilities.popenExecutioner(command)
1061-
1062-
# command = "chown root:%s /home/" % (groupName) + domainName + "/logs"
1063-
# ProcessUtilities.popenExecutioner(command)
1064-
1057+
# Set file permissions first (before ownership to avoid conflicts)
10651058
command = "find %s -type d -exec chmod 0755 {} \;" % ("/home/" + domainName + "/public_html")
1066-
ProcessUtilities.popenExecutioner(command)
1059+
ProcessUtilities.executioner(command)
10671060

10681061
command = "find %s -type f -exec chmod 0644 {} \;" % ("/home/" + domainName + "/public_html")
1069-
ProcessUtilities.popenExecutioner(command)
1062+
ProcessUtilities.executioner(command)
10701063

1064+
# Set ownership for all files inside public_html to user:user
1065+
command = 'chown -R -P %s:%s /home/%s/public_html/*' % (externalApp, externalApp, domainName)
1066+
ProcessUtilities.executioner(command)
1067+
1068+
command = 'chown -R -P %s:%s /home/%s/public_html/.[^.]*' % (externalApp, externalApp, domainName)
1069+
ProcessUtilities.executioner(command)
1070+
1071+
# Set public_html directory itself to user:nogroup with 750 permissions
10711072
command = 'chown %s:%s /home/%s/public_html' % (externalApp, groupName, domainName)
10721073
ProcessUtilities.executioner(command)
10731074

@@ -1084,21 +1085,23 @@ def fixPermissions(self, domainName):
10841085
'error_message': "Symlink attack."})
10851086
return HttpResponse(final_json)
10861087

1087-
1088+
# Set file permissions first
10881089
command = "find %s -type d -exec chmod 0755 {} \;" % (childs.path)
1089-
ProcessUtilities.popenExecutioner(command)
1090+
ProcessUtilities.executioner(command)
10901091

10911092
command = "find %s -type f -exec chmod 0644 {} \;" % (childs.path)
1092-
ProcessUtilities.popenExecutioner(command)
1093+
ProcessUtilities.executioner(command)
10931094

1095+
# Set ownership for all files inside child domain to user:user
10941096
command = 'chown -R -P %s:%s %s/*' % (externalApp, externalApp, childs.path)
1095-
ProcessUtilities.popenExecutioner(command)
1097+
ProcessUtilities.executioner(command)
10961098

10971099
command = 'chown -R -P %s:%s %s/.[^.]*' % (externalApp, externalApp, childs.path)
1098-
ProcessUtilities.popenExecutioner(command)
1100+
ProcessUtilities.executioner(command)
10991101

1102+
# Set child domain directory itself to 755 with user:nogroup
11001103
command = 'chmod 755 %s' % (childs.path)
1101-
ProcessUtilities.popenExecutioner(command)
1104+
ProcessUtilities.executioner(command)
11021105

11031106
command = 'chown %s:%s %s' % (externalApp, groupName, childs.path)
1104-
ProcessUtilities.popenExecutioner(command)
1107+
ProcessUtilities.executioner(command)

0 commit comments

Comments
 (0)