bug fix: permissions on ubuntu

This commit is contained in:
Usman Nasir
2020-04-03 11:28:27 +05:00
parent 4db2168731
commit d0fd631677
6 changed files with 107 additions and 21 deletions

View File

@@ -498,13 +498,18 @@ class FileManager:
website = Websites.objects.get(domain=domainName)
externalApp = website.externalApp
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
command = 'chown -R %s:%s /home/%s/public_html/*' % (externalApp, externalApp, domainName)
ProcessUtilities.popenExecutioner(command)
command = 'chown -R %s:%s /home/%s/public_html/.[^.]*' % (externalApp, externalApp, domainName)
ProcessUtilities.popenExecutioner(command)
command = "chown root:nobody /home/" + domainName + "/logs"
command = "chown root:%s /home/" % (groupName) + domainName + "/logs"
ProcessUtilities.popenExecutioner(command)
command = "find %s -type d -exec chmod 0755 {} \;" % ("/home/" + domainName + "/public_html")
@@ -513,7 +518,7 @@ class FileManager:
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)
command = 'chown %s:%s /home/%s/public_html' % (externalApp,groupName, domainName)
ProcessUtilities.executioner(command)
command = 'chmod 750 /home/%s/public_html' % (domainName)

View File

@@ -351,8 +351,13 @@ class ApplicationInstaller(multi.Thread):
##
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
if home != '0':
command = "chown " + externalApp + ":" + 'nobody' + " " + finalPath
command = "chown " + externalApp + ":" + groupName + " " + finalPath
ProcessUtilities.executioner(command, externalApp)
command = 'chmod 750 %s' % (self.permPath)
@@ -370,8 +375,13 @@ class ApplicationInstaller(multi.Thread):
homeDir = "/home/" + domainName + "/public_html"
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
if not os.path.exists(homeDir):
command = "chown " + externalApp + ":" + 'nobody' + " " + homeDir
command = "chown " + externalApp + ":" + groupName + " " + homeDir
ProcessUtilities.executioner(command, externalApp)
try:
@@ -523,8 +533,13 @@ class ApplicationInstaller(multi.Thread):
##
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
if home == '0':
command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath
command = "chown -R " + externalApp + ":" + groupName + " " + finalPath
ProcessUtilities.executioner(command, externalApp)
command = "rm -f prestashop_1.7.4.2.zip"
@@ -544,8 +559,13 @@ class ApplicationInstaller(multi.Thread):
homeDir = "/home/" + domainName + "/public_html"
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
if not os.path.exists(homeDir):
command = "chown -R " + externalApp + ":" + 'nobody' + " " + homeDir
command = "chown -R " + externalApp + ":" + groupName + " " + homeDir
ProcessUtilities.executioner(command, externalApp)
try:
@@ -652,7 +672,12 @@ class ApplicationInstaller(multi.Thread):
##
command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
command = "chown -R " + externalApp + ":" + groupName + " " + finalPath
ProcessUtilities.executioner(command, externalApp)
vhost.addRewriteRules(domainName)
@@ -714,10 +739,15 @@ class ApplicationInstaller(multi.Thread):
##
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
website = Websites.objects.get(domain=domain)
externalApp = website.externalApp
command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath
command = "chown -R " + externalApp + ":" + groupName + " " + finalPath
ProcessUtilities.executioner(command, externalApp)
return 0
@@ -756,7 +786,12 @@ class ApplicationInstaller(multi.Thread):
##
command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
command = "chown -R " + externalApp + ":" + groupName + " " + finalPath
ProcessUtilities.executioner(command, website.externalApp)
gitPath = '/home/cyberpanel/' + domain + '.git'
@@ -906,7 +941,12 @@ class ApplicationInstaller(multi.Thread):
shutil.rmtree(finalPath + "installation")
command = "chown -R " + virtualHostUser + ":" + 'nobody' + " " + finalPath
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
command = "chown -R " + virtualHostUser + ":" + groupName + " " + finalPath
ProcessUtilities.executioner(command)
vhost.addRewriteRules(domainName)
@@ -927,8 +967,13 @@ class ApplicationInstaller(multi.Thread):
homeDir = "/home/" + domainName + "/public_html"
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
if not os.path.exists(homeDir):
command = "chown -R " + virtualHostUser + ":" + 'nobody' + " " + homeDir
command = "chown -R " + virtualHostUser + ":" + groupName + " " + homeDir
ProcessUtilities.executioner(command)
try:
@@ -1120,8 +1165,13 @@ class ApplicationInstaller(multi.Thread):
##
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
if home != '0':
command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath
command = "chown -R " + externalApp + ":" + groupName + " " + finalPath
ProcessUtilities.executioner(command, externalApp)
installUtilities.reStartLiteSpeed()
@@ -1140,8 +1190,13 @@ class ApplicationInstaller(multi.Thread):
homeDir = "/home/" + domainName + "/public_html"
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
if not os.path.exists(homeDir):
command = "chown -R " + externalApp + ":" + 'nobody' + " " + homeDir
command = "chown -R " + externalApp + ":" + groupName + " " + homeDir
ProcessUtilities.executioner(command, externalApp)
try:

View File

@@ -849,7 +849,12 @@ class backupUtilities:
installUtilities.reStartLiteSpeed()
command = "chown -R " + externalApp + ":nobody" " " + websiteHome
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
command = "chown -R " + externalApp + ":%s " % (groupName) + websiteHome
cmd = shlex.split(command)
subprocess.call(cmd)

View File

@@ -717,7 +717,12 @@ class cPanelImporter:
command = "sudo chown -R " + externalApp + ":" + externalApp + " /home/" + self.mainDomain
ProcessUtilities.normalExecutioner(command)
command = "sudo chown -R root:nobody /home/" + self.mainDomain + "/logs"
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
command = "sudo chown -R root:%s /home/" % (groupName) + self.mainDomain + "/logs"
ProcessUtilities.normalExecutioner(command)
command = "sudo find %s -type d -exec chmod 0755 {} \;" % ("/home/" + self.mainDomain + "/public_html")

View File

@@ -91,7 +91,12 @@ class vhost:
try:
os.makedirs(pathHTML)
command = "chown " + virtualHostUser + ":nobody " + pathHTML
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
command = "chown " + virtualHostUser + ":%s " % (groupName) + pathHTML
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
@@ -842,7 +847,13 @@ class vhost:
try:
os.makedirs(path)
command = "chown " + virtualHostUser + ":nobody " + path
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
command = "chown " + virtualHostUser + ":%s " % (groupName) + path
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)

View File

@@ -299,10 +299,15 @@ class virtualHostUtilities:
print("0, %s file is symlinked." % (fileName))
return 0
numberOfTotalLines = int(ProcessUtilities.outputExecutioner('wc -l %s' % (fileName), 'nobody').split(" ")[0])
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
numberOfTotalLines = int(ProcessUtilities.outputExecutioner('wc -l %s' % (fileName), groupName).split(" ")[0])
if numberOfTotalLines < 25:
data = ProcessUtilities.outputExecutioner('cat %s' % (fileName), 'nobody')
data = ProcessUtilities.outputExecutioner('cat %s' % (fileName), groupName)
else:
if page == 1:
end = numberOfTotalLines
@@ -311,7 +316,7 @@ class virtualHostUtilities:
start = 1
startingAndEnding = "'" + str(start) + "," + str(end) + "p'"
command = "sed -n " + startingAndEnding + " " + fileName
data = ProcessUtilities.outputExecutioner(command, 'nobody')
data = ProcessUtilities.outputExecutioner(command, groupName)
else:
end = numberOfTotalLines - ((page - 1) * 25)
start = end - 24
@@ -319,7 +324,7 @@ class virtualHostUtilities:
start = 1
startingAndEnding = "'" + str(start) + "," + str(end) + "p'"
command = "sed -n " + startingAndEnding + " " + fileName
data = ProcessUtilities.outputExecutioner(command, 'nobody')
data = ProcessUtilities.outputExecutioner(command, groupName)
print(data)
return data
except BaseException as msg: