diff --git a/filemanager/filemanager.py b/filemanager/filemanager.py index fd4d2fbb8..5a8b1c2c7 100755 --- a/filemanager/filemanager.py +++ b/filemanager/filemanager.py @@ -386,10 +386,10 @@ class FileManager: domainName = self.data['domainName'] website = Websites.objects.get(domain=domainName) - command = 'chown %s:%s %s' % (website.externalApp, website.externalApp, self.data['completePath'] + '/' + myfile.name) + command = 'chown %s:%s %s' % (website.externalApp, website.externalApp, self.returnPathEnclosed(self.data['completePath'] + '/' + myfile.name)) ProcessUtilities.executioner(command) - self.changeOwner(self.data['completePath'] + '/' + myfile.name) + self.changeOwner(self.returnPathEnclosed(self.data['completePath'] + '/' + myfile.name)) json_data = json.dumps(finalData) return HttpResponse(json_data) @@ -421,7 +421,7 @@ class FileManager: ProcessUtilities.executioner(command, website.externalApp) - self.changeOwner(self.data['extractionLocation']) + self.fixPermissions(domainName) json_data = json.dumps(finalData) return HttpResponse(json_data) @@ -518,8 +518,27 @@ class FileManager: command = "find %s -type f -exec chmod 0644 {} \;" % ("/home/" + domainName + "/public_html") ProcessUtilities.popenExecutioner(command) - command = 'chown %s:%s /home/%s/public_html' % (externalApp,groupName, domainName) + 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) \ No newline at end of file + ProcessUtilities.executioner(command) + + for childs in website.childdomains_set.all(): + command = "find %s -type d -exec chmod 0755 {} \;" % (childs.path) + ProcessUtilities.popenExecutioner(command) + + command = "find %s -type f -exec chmod 0644 {} \;" % (childs.path) + ProcessUtilities.popenExecutioner(command) + + command = 'chown -R %s:%s %s/*' % (externalApp, externalApp, childs.path) + ProcessUtilities.popenExecutioner(command) + + command = 'chown -R %s:%s %s/.[^.]*' % (externalApp, externalApp, childs.path) + ProcessUtilities.popenExecutioner(command) + + command = 'chmod 755 %s' % (childs.path) + ProcessUtilities.popenExecutioner(command) + + command = 'chmod %s:%s %s' % (externalApp, groupName, childs.path) + ProcessUtilities.popenExecutioner(command) \ No newline at end of file diff --git a/install/install.py b/install/install.py index cf6663b32..bef8f5683 100755 --- a/install/install.py +++ b/install/install.py @@ -190,7 +190,7 @@ class preFlightsChecks: @staticmethod def pureFTPDServiceName(distro): if distro == ubuntu: - return 'pure-ftpd' + return 'pure-ftpd-mysql' return 'pure-ftpd' @staticmethod @@ -327,7 +327,7 @@ class preFlightsChecks: os._exit(os.EX_SOFTWARE) elif self.distro == centos: - command = 'rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm' + command = 'rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.2-1.el7.noarch.rpm' preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) elif self.distro == cent8: command = 'rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm' diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index c3e101573..b7b5e2058 100755 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -348,11 +348,24 @@ class InstallCyberPanel: def installPureFTPD(self): if self.distro == ubuntu: - command = 'apt-get -y install ' + install.preFlightsChecks.pureFTPDServiceName(self.distro) + command = 'DEBIAN_FRONTEND=noninteractive apt install pure-ftpd-mysql -y' + os.system(command) + + command = 'wget https://rep.cyberpanel.net/pure-ftpd-common_1.0.47-3_all.deb' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + + command = 'wget https://rep.cyberpanel.net/pure-ftpd-mysql_1.0.47-3_amd64.deb' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + + command = 'dpkg --install --force-confold pure-ftpd-common_1.0.47-3_all.deb' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + + command = 'dpkg --install --force-confold pure-ftpd-mysql_1.0.47-3_amd64.deb' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + else: command = "yum install -y pure-ftpd" - - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) ####### Install pureftpd to system startup @@ -428,8 +441,6 @@ class InstallCyberPanel: writeDataToFile.close() if self.distro == ubuntu: - command = 'apt install pure-ftpd-mysql -y' - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) if os.path.exists('/etc/pure-ftpd/db/mysql.conf'): os.remove('/etc/pure-ftpd/db/mysql.conf') @@ -446,16 +457,16 @@ class InstallCyberPanel: command = 'echo "40110 40210" > /etc/pure-ftpd/conf/PassivePortRange' subprocess.call(command, shell=True) - command = 'wget https://ubuntu.cyberpanel.net/pool/main/p/pure-ftpd/pure-ftpd-common_1.0.47-3_all.deb' + command = 'echo "no" > /etc/pure-ftpd/conf/UnixAuthentication' + subprocess.call(command, shell=True) + + command = 'echo "/etc/pure-ftpd/db/mysql.conf" > /etc/pure-ftpd/conf/MySQLConfigFile' + subprocess.call(command, shell=True) + + command = 'ln -s /etc/pure-ftpd/conf/MySQLConfigFile /etc/pure-ftpd/auth/30mysql' install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - command = 'wget https://ubuntu.cyberpanel.net/pool/main/p/pure-ftpd/pure-ftpd-common_1.0.47-3_all.deb' - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - - command = 'dpkg --install --force-confold pure-ftpd-common_1.0.47-3_all.deb' - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - - command = 'dpkg --install --force-confold pure-ftpd-mysql_1.0.47-3_amd64.deb' + command = 'ln -s /etc/pure-ftpd/conf/UnixAuthentication /etc/pure-ftpd/auth/65unix' install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) command = 'systemctl restart pure-ftpd-mysql.service' diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index a48eb85b8..3e817d665 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -248,6 +248,7 @@ class ApplicationInstaller(multi.Thread): try: website = ChildDomains.objects.get(domain=domainName) externalApp = website.master.externalApp + self.masterDomain = website.master.domain if home == '0': path = self.extraArgs['path'] @@ -270,6 +271,7 @@ class ApplicationInstaller(multi.Thread): except: website = Websites.objects.get(domain=domainName) externalApp = website.externalApp + self.masterDomain = website.domain if home == '0': path = self.extraArgs['path'] @@ -351,17 +353,10 @@ class ApplicationInstaller(multi.Thread): ## - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: - groupName = 'nobody' - else: - groupName = 'nogroup' + from filemanager.filemanager import FileManager - if home != '0': - command = "chown " + externalApp + ":" + groupName + " " + finalPath - ProcessUtilities.executioner(command, externalApp) - - command = 'chmod 750 %s' % (self.permPath) - ProcessUtilities.executioner(command) + fm = FileManager(None, None) + fm.fixPermissions(self.masterDomain) statusFile = open(tempStatusPath, 'w') statusFile.writelines("Successfully Installed. [200]") @@ -429,6 +424,7 @@ class ApplicationInstaller(multi.Thread): try: website = ChildDomains.objects.get(domain=domainName) externalApp = website.master.externalApp + self.masterDomain = website.master.domain if home == '0': path = self.extraArgs['path'] @@ -451,6 +447,7 @@ class ApplicationInstaller(multi.Thread): except: website = Websites.objects.get(domain=domainName) externalApp = website.externalApp + self.masterDomain = website.domain if home == '0': path = self.extraArgs['path'] @@ -533,20 +530,10 @@ class ApplicationInstaller(multi.Thread): ## - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: - groupName = 'nobody' - else: - groupName = 'nogroup' + from filemanager.filemanager import FileManager - if home == '0': - command = "chown -R " + externalApp + ":" + groupName + " " + finalPath - ProcessUtilities.executioner(command, externalApp) - - command = "rm -f prestashop_1.7.4.2.zip" - ProcessUtilities.executioner(command, externalApp) - - command = 'chmod 750 %s' % (self.permPath) - ProcessUtilities.executioner(command) + fm = FileManager(None, None) + fm.fixPermissions(self.masterDomain) statusFile = open(tempStatusPath, 'w') statusFile.writelines("Successfully Installed. [200]") @@ -583,228 +570,6 @@ class ApplicationInstaller(multi.Thread): statusFile.close() return 0 - def setupGit(self): - try: - admin = self.extraArgs['admin'] - domainName = self.extraArgs['domainName'] - username = self.extraArgs['username'] - reponame = self.extraArgs['reponame'] - branch = self.extraArgs['branch'] - tempStatusPath = self.extraArgs['tempStatusPath'] - defaultProvider = self.extraArgs['defaultProvider'] - self.tempStatusPath = tempStatusPath - - statusFile = open(tempStatusPath, 'w') - statusFile.writelines('Checking if GIT installed..,0') - statusFile.close() - - ### Check git - - try: - command = 'git --help' - output = ProcessUtilities.outputExecutioner(command) - - if output.find('command not found') > -1: - statusFile = open(tempStatusPath, 'w') - statusFile.writelines('Installing GIT..,0') - statusFile.close() - self.installGit() - statusFile = open(tempStatusPath, 'w') - statusFile.writelines('GIT successfully installed,20') - statusFile.close() - - except BaseException as msg: - statusFile = open(tempStatusPath, 'w') - statusFile.writelines('Installing GIT..,0') - statusFile.close() - self.installGit() - statusFile = open(tempStatusPath, 'w') - statusFile.writelines('GIT successfully installed.,20') - statusFile.close() - - ## Open Status File - - statusFile = open(tempStatusPath, 'w') - statusFile.writelines('Setting up directories..,20') - statusFile.close() - - try: - website = ChildDomains.objects.get(domain=domainName) - externalApp = website.master.externalApp - finalPath = website.path - - except: - website = Websites.objects.get(domain=domainName) - externalApp = website.externalApp - finalPath = "/home/" + domainName + "/public_html/" - - ## Security Check - - if finalPath.find("..") > -1: - raise BaseException('Specified path must be inside virtual host home.') - - permPath = '/home/%s/public_html' % (domainName) - command = 'chmod 755 %s' % (permPath) - ProcessUtilities.executioner(command) - - command = 'mkdir -p ' + finalPath - ProcessUtilities.executioner(command, externalApp) - - ## checking for directories/files - - if self.dataLossCheck(finalPath, tempStatusPath) == 0: - raise BaseException('Directory is not empty.') - - #### - - statusFile = open(tempStatusPath, 'w') - statusFile.writelines('Cloning the repo..,40') - statusFile.close() - - try: - command = 'git clone --depth 1 --no-single-branch git@' + defaultProvider + '.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath - output = ProcessUtilities.outputExecutioner(command, externalApp) - finalPathGit = '%s/.git' % (finalPath.rstrip('/')) - if not os.path.exists(finalPathGit): - raise BaseException(output) - except BaseException as msg: - raise BaseException('Failed to clone repository, make sure you deployed your key to repository. Error: %s' % (str(msg))) - - ## - - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: - groupName = 'nobody' - else: - groupName = 'nogroup' - - command = "chown -R " + externalApp + ":" + groupName + " " + finalPath - ProcessUtilities.executioner(command, externalApp) - - vhost.addRewriteRules(domainName) - installUtilities.reStartLiteSpeed() - - mailUtilities.checkHome() - - gitPath = '/home/cyberpanel/' + domainName + '.git' - writeToFile = open(gitPath, 'w') - writeToFile.write(username + ':' + reponame) - writeToFile.close() - - permPath = '/home/%s/public_html' % (domainName) - command = 'chmod 750 %s' % (permPath) - ProcessUtilities.executioner(command) - - statusFile = open(tempStatusPath, 'w') - statusFile.writelines("GIT Repository successfully attached. [200]") - statusFile.close() - return 0 - - - except BaseException as msg: - try: - os.remove('/home/cyberpanel/' + domainName + '.git') - except: - pass - - permPath = '/home/%s/public_html' % (domainName) - command = 'chmod 750 %s' % (permPath) - ProcessUtilities.executioner(command) - - statusFile = open(self.tempStatusPath, 'w') - statusFile.writelines(str(msg) + " [404]") - statusFile.close() - return 0 - - def gitPull(self): - try: - domain = self.extraArgs['domain'] - - try: - website = Websites.objects.get(domain=domain) - finalPath = "/home/" + domain + "/public_html/" - externalApp = website.externalApp - except: - childDomain = ChildDomains.objects.get(domain=domain) - finalPath = childDomain.path - externalApp = website.externalApp - - path = '/home/cyberpanel/' + domain + '.git' - - if not os.path.exists(path): - logging.writeToFile('Git is not setup for this website.') - return 0 - - command = 'git --git-dir=' + finalPath + '.git --work-tree=' + finalPath + ' pull' - ProcessUtilities.executioner(command, externalApp) - - ## - - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: - groupName = 'nobody' - else: - groupName = 'nogroup' - - website = Websites.objects.get(domain=domain) - externalApp = website.externalApp - - command = "chown -R " + externalApp + ":" + groupName + " " + finalPath - ProcessUtilities.executioner(command, externalApp) - - return 0 - - - except BaseException as msg: - logging.writeToFile(str(msg) + " [ApplicationInstaller.gitPull]") - return 0 - - def detachRepo(self): - try: - domain = self.extraArgs['domainName'] - admin = self.extraArgs['admin'] - - try: - website = ChildDomains.objects.get(domain=domain) - externalApp = website.master.externalApp - - - except: - website = Websites.objects.get(domain=domain) - externalApp = website.externalApp - - try: - website = Websites.objects.get(domain=domain) - finalPath = "/home/" + domain + "/public_html/" - except: - childDomain = ChildDomains.objects.get(domain=domain) - finalPath = childDomain.path - - command = 'rm -rf ' + finalPath - ProcessUtilities.executioner(command, website.externalApp) - - command = 'mkdir ' + finalPath - ProcessUtilities.executioner(command, website.externalApp) - - ## - - 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' - - os.remove(gitPath) - - return 0 - - - except BaseException as msg: - logging.writeToFile(str(msg) + " [ApplicationInstaller.gitPull]") - return 0 - def installJoomla(self): try: @@ -993,36 +758,6 @@ class ApplicationInstaller(multi.Thread): logging.writeToFile(str(msg)) return 0 - def changeBranch(self): - try: - domainName = self.extraArgs['domainName'] - githubBranch = self.extraArgs['githubBranch'] - admin = self.extraArgs['admin'] - - try: - website = Websites.objects.get(domain=domainName) - finalPath = "/home/" + domainName + "/public_html/" - externalApp = website.externalApp - except: - childDomain = ChildDomains.objects.get(domain=domainName) - finalPath = childDomain.path - externalApp = childDomain.master.externalApp - - try: - command = 'git --git-dir=' + finalPath + '/.git checkout -b ' + githubBranch - ProcessUtilities.executioner(command, externalApp) - except: - try: - command = 'git --git-dir=' + finalPath + '/.git checkout ' + githubBranch - ProcessUtilities.executioner(command, externalApp) - except subprocess.CalledProcessError as msg: - logging.writeToFile('Failed to change branch: ' + str(msg)) - return 0 - return 0 - except BaseException as msg: - logging.writeToFile('Failed to change branch: ' + str(msg)) - return 0 - def installMagento(self): try: @@ -1051,6 +786,7 @@ class ApplicationInstaller(multi.Thread): try: website = ChildDomains.objects.get(domain=domainName) externalApp = website.master.externalApp + self.masterDomain = website.master.domain if home == '0': path = self.extraArgs['path'] @@ -1073,6 +809,7 @@ class ApplicationInstaller(multi.Thread): except: website = Websites.objects.get(domain=domainName) externalApp = website.externalApp + self.masterDomain = website.domain if home == '0': path = self.extraArgs['path'] @@ -1165,20 +902,13 @@ class ApplicationInstaller(multi.Thread): ## - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: - groupName = 'nobody' - else: - groupName = 'nogroup' + from filemanager.filemanager import FileManager - if home != '0': - command = "chown -R " + externalApp + ":" + groupName + " " + finalPath - ProcessUtilities.executioner(command, externalApp) + fm = FileManager(None, None) + fm.fixPermissions(self.masterDomain) installUtilities.reStartLiteSpeed() - command = 'chmod 750 %s' % (self.permPath) - ProcessUtilities.executioner(command) - statusFile = open(tempStatusPath, 'w') statusFile.writelines("Successfully Installed. [200]") statusFile.close() diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index 6ee5b2583..08621d459 100755 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -482,6 +482,9 @@ class backupUtilities: 1024.0 * 1024.0))) + "MB" items.save() + command = 'chmod 600 %s' % (os.path.join(backupPath,backupName+".tar.gz")) + ProcessUtilities.executioner(command) + logging.CyberCPLogFileWriter.statusWriter(status, "Completed\n") os.remove(pidFile) diff --git a/plogical/processUtilities.py b/plogical/processUtilities.py index 1bfe9b31b..9ff4437e4 100755 --- a/plogical/processUtilities.py +++ b/plogical/processUtilities.py @@ -190,10 +190,15 @@ class ProcessUtilities(multi.Thread): sock = ret[0] if user == None: - if command.find('sudo') == -1: + + if command.find('export') > -1: + pass + elif command.find('sudo') == -1: command = 'sudo %s' % (command) + if os.path.exists(ProcessUtilities.debugPath): logging.writeToFile(ProcessUtilities.token + command) + sock.sendall((ProcessUtilities.token + command).encode('utf-8')) else: command = '%s-u %s %s' % (ProcessUtilities.token, user, command) diff --git a/plogical/remoteTransferUtilities.py b/plogical/remoteTransferUtilities.py index 5df7b9b91..76a1ef5c0 100755 --- a/plogical/remoteTransferUtilities.py +++ b/plogical/remoteTransferUtilities.py @@ -193,6 +193,9 @@ class remoteTransferUtilities: command = "sudo scp -o StrictHostKeyChecking=no -i /root/.ssh/cyberpanel " + completedPathToSend + " root@" + IPAddress + ":/home/backup/transfer-" + folderNumber + "/" subprocess.call(shlex.split(command), stdout=writeToFile) + if os.path.exists(ProcessUtilities.debugPath): + logging.CyberCPLogFileWriter.writeToFile(command) + os.remove(completedPathToSend) except BaseException as msg: