From 794a4f66f9c3bb4a27e19e2243d32b2e1147a332 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Fri, 21 Feb 2020 17:36:09 +0500 Subject: [PATCH] change permissions structure --- filemanager/views.py | 10 ++++++++-- plogical/applicationInstaller.py | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/filemanager/views.py b/filemanager/views.py index ff80052bd..1613c7515 100755 --- a/filemanager/views.py +++ b/filemanager/views.py @@ -53,10 +53,10 @@ def changePermissions(request): website = Websites.objects.get(domain=domainName) externalApp = website.externalApp - command = "sudo chown -R " + externalApp + ":" + externalApp +" /home/"+domainName + command = "chown -R " + externalApp + ":" + externalApp +" /home/"+domainName ProcessUtilities.popenExecutioner(command) - command = "sudo chown -R lscpd:lscpd /home/" + domainName+"/logs" + command = "chown root:nobody /home/" + domainName+"/logs" ProcessUtilities.popenExecutioner(command) command = "find %s -type d -exec chmod 0755 {} \;" % ("/home/" + domainName + "/public_html") @@ -65,6 +65,12 @@ def changePermissions(request): command = "find %s -type f -exec chmod 0644 {} \;" % ("/home/" + domainName + "/public_html") ProcessUtilities.popenExecutioner(command) + command = 'chown %s:nobody /home/%s/public_html' % (externalApp, domainName) + ProcessUtilities.executioner(command) + + command = 'chmod 750 /home/%s/public_html' % (domainName) + ProcessUtilities.executioner(command) + data_ret = {'permissionsChanged': 1, 'error_message': "None"} json_data = json.dumps(data_ret) return HttpResponse(json_data) diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index 9ea93e99e..ec9a86241 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -358,7 +358,7 @@ class ApplicationInstaller(multi.Thread): ## - command = "chown -R " + externalApp + ":" + externalApp + " " + finalPath + command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath ProcessUtilities.executioner(command, externalApp) statusFile = open(tempStatusPath, 'w') @@ -374,7 +374,7 @@ class ApplicationInstaller(multi.Thread): homeDir = "/home/" + domainName + "/public_html" if not os.path.exists(homeDir): - command = "chown -R " + externalApp + ":" + externalApp + " " + homeDir + command = "chown -R " + externalApp + ":" + 'nobody' + " " + homeDir ProcessUtilities.executioner(command, externalApp) try: @@ -521,15 +521,15 @@ class ApplicationInstaller(multi.Thread): ## - command = "sudo rm -rf " + finalPath + "install" + command = "rm -rf " + finalPath + "install" ProcessUtilities.executioner(command, externalApp) ## - command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath + command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath ProcessUtilities.executioner(command, externalApp) - command = "sudo rm -f prestashop_1.7.4.2.zip" + command = "rm -f prestashop_1.7.4.2.zip" ProcessUtilities.executioner(command, externalApp) statusFile = open(tempStatusPath, 'w') @@ -544,7 +544,7 @@ class ApplicationInstaller(multi.Thread): homeDir = "/home/" + domainName + "/public_html" if not os.path.exists(homeDir): - command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir + command = "chown -R " + externalApp + ":" + 'nobody' + " " + homeDir ProcessUtilities.executioner(command, externalApp) try: @@ -651,7 +651,7 @@ class ApplicationInstaller(multi.Thread): ## - command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath + command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath ProcessUtilities.executioner(command, externalApp) vhost.addRewriteRules(domainName) @@ -704,7 +704,7 @@ class ApplicationInstaller(multi.Thread): website = Websites.objects.get(domain=domain) externalApp = website.externalApp - command = "chown -R " + externalApp + ":" + externalApp + " " + finalPath + command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath ProcessUtilities.executioner(command, externalApp) return 0 @@ -743,7 +743,7 @@ class ApplicationInstaller(multi.Thread): ## - command = "chown -R " + externalApp + ":" + externalApp + " " + finalPath + command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath ProcessUtilities.executioner(command, website.externalApp) gitPath = '/home/cyberpanel/' + domain + '.git' @@ -891,7 +891,7 @@ class ApplicationInstaller(multi.Thread): shutil.rmtree(finalPath + "installation") - command = "chown -R " + virtualHostUser + ":" + virtualHostUser + " " + finalPath + command = "chown -R " + virtualHostUser + ":" + 'nobody' + " " + finalPath ProcessUtilities.executioner(command) vhost.addRewriteRules(domainName) @@ -909,7 +909,7 @@ class ApplicationInstaller(multi.Thread): homeDir = "/home/" + domainName + "/public_html" if not os.path.exists(homeDir): - command = "chown -R " + virtualHostUser + ":" + virtualHostUser + " " + homeDir + command = "chown -R " + virtualHostUser + ":" + 'nobody' + " " + homeDir ProcessUtilities.executioner(command) try: @@ -1101,7 +1101,7 @@ class ApplicationInstaller(multi.Thread): ## - command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath + command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath ProcessUtilities.executioner(command, externalApp) installUtilities.reStartLiteSpeed() @@ -1118,7 +1118,7 @@ class ApplicationInstaller(multi.Thread): homeDir = "/home/" + domainName + "/public_html" if not os.path.exists(homeDir): - command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir + command = "chown -R " + externalApp + ":" + 'nobody' + " " + homeDir ProcessUtilities.executioner(command, externalApp) try: