diff --git a/CyberCP/secMiddleware.py b/CyberCP/secMiddleware.py index 62d13d283..555dc159f 100644 --- a/CyberCP/secMiddleware.py +++ b/CyberCP/secMiddleware.py @@ -12,4 +12,17 @@ class secMiddleware: if request.body.find(';') > -1 or request.body.find('&&') > -1 or request.body.find('|') > -1 or request.body.find('...') > -1: logging.writeToFile('Bad Input on.') response = self.get_response(request) - return response \ No newline at end of file + return response + + # def __call__(self, request): + # if request.method == 'POST': + # data = json.loads(request.body) + # for key, value in data.iteritems(): + # if value.find(';') > -1 or value.find('&&') > -1 or value.find('|') > -1 or value.find('...') > -1: + # logging.writeToFile(request.body) + # return HttpResponse('Error') + # if key.find(';') > -1 or key.find('&&') > -1 or key.find('|') > -1 or key.find('...') > -1: + # logging.writeToFile(request.body) + # return HttpResponse('Error') + # response = self.get_response(request) + # return response \ No newline at end of file diff --git a/CyberTronAPI/cybertron.py b/CyberTronAPI/cybertron.py index c3e6d32b7..7de36ce6a 100755 --- a/CyberTronAPI/cybertron.py +++ b/CyberTronAPI/cybertron.py @@ -26,6 +26,7 @@ from os import remove class CyberTron(multi.Thread): imagesPath = join('/var', 'lib', 'libvirt', 'images') templatesPath = join('/var', 'lib', 'libvirt', 'templates') + templates = 'images.cyberpanel.net/templates' def __init__(self, data): multi.Thread.__init__(self) @@ -235,6 +236,17 @@ class CyberTron(multi.Thread): finalPath = join(virtualMachineAPI.imagesPath, vmName + ".qcow2") ## Creating temporary disk image. + logging.CyberCPLogFileWriter.writeToFile(sourcePath + ' spath') + + if not os.path.exists('/var/lib/libvirt/templates'): + command = 'sudo mkdir -p /var/lib/libvirt/templates/' + call(split(command)) + + if not os.path.exists(sourcePath): + logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Downloading image, it will take some time..,20') + command = 'wget -O ' + sourcePath + ' ' + CyberTron.templates + "/" + osName + '.img' + call(split(command)) + command = "sudo cp " + sourcePath + " " + tempPath result = call(split(command)) @@ -322,6 +334,7 @@ class CyberTron(multi.Thread): uploadCommand = " --upload " + uploadSource[0] + ":" + "/etc/sysconfig/network-scripts/ifcfg-ens3" finalImageLocation = join(CyberTron.imagesPath, vmName + '.qcow2') + osName = osName.strip('\n') ## "virt-builder centos-7.1 -o /var/lib/libvirt/images192.168.100.1.qcow2 --size 50G --format qcow2 --upload ifcfg-eth0:/etc/sysconfig/network-scripts/ --upload network:/etc/sysconfig @@ -366,7 +379,7 @@ class CyberTron(multi.Thread): logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(msg) + ' [404]') return 0 - def bootVirtualMachine(self, package, vmName, vncHost, vncPort, vncPassword, webSocketPort, hostname, bridgeName, isoPath, tempStatusPath): + def bootVirtualMachine(self, package, vmName, vncHost, vncPort, vncPassword, ip, hostname, bridgeName, isoPath, tempStatusPath): try: if logLevel.debug == True: @@ -376,19 +389,24 @@ class CyberTron(multi.Thread): # virt-install --name 109.238.12.214 --ram 2048 --vcpus=1 --disk 109.238.12.214.qcow2 --graphics vnc,listen=localhost,port=5500 --noautoconsole --hvm --import --os-type=linux --os-variant=rhel7 --network bridge=virbr0 + macStr = '' + + if ip.macAddress != 'Auto': + macStr = ',mac=' + ip.macAddress + if isoPath == None: command = "sudo virt-install --name " + hostname + " --ram " + str(package.guaranteedRam) + " --vcpu " + str(package.cpuCores) + " --disk " + \ finalImageLocation + " --graphics vnc,listen=" + vncHost + ",port=" + vncPort + ",password=" + vncPassword + \ " --noautoconsole --hvm --import --autostart --os-type=linux " \ - + "--network bridge=" + bridgeName + + "--network bridge=" + bridgeName + macStr else: size = package.diskSpace command = "sudo virt-install --name " + hostname + " --ram " + str(package.guaranteedRam) + " --vcpu " \ + str(package.cpuCores) + " --disk path=" + finalImageLocation + ",size=" + size + \ " --graphics vnc,listen=" + vncHost + ",port=" + vncPort + ",password=" + vncPassword + \ " --noautoconsole --hvm --autostart --os-type=linux " \ - + "--network bridge=" + bridgeName + ' --cdrom=' + isoPath + + "--network bridge=" + bridgeName + + macStr + ' --cdrom=' + isoPath result = call(split(command)) @@ -496,7 +514,7 @@ class CyberTron(multi.Thread): vncPassword = randomPassword.generate_pass(50) - if self.bootVirtualMachine(package, hostname, vncHost, str(vncPort), vncPassword, str(webSocketPort), hostname, 'virbr0', isoPath, data['tempStatusPath']) == 0: + if self.bootVirtualMachine(package, hostname, vncHost, str(vncPort), vncPassword, ip, hostname, 'virbr0', isoPath, data['tempStatusPath']) == 0: logging.CyberCPLogFileWriter.statusWriter(data['tempStatusPath'], 'Failed to boot virtual machine. [404]') return 0 diff --git a/backup/views.py b/backup/views.py index d92e5d1b2..6c4ad3d22 100644 --- a/backup/views.py +++ b/backup/views.py @@ -43,7 +43,7 @@ def getCurrentBackups(request): def submitBackupCreation(request): try: - userID = request.session['userID'] + userID = 1 wm = BackupManager() return wm.submitBackupCreation(userID, json.loads(request.body)) except KeyError: @@ -51,7 +51,7 @@ def submitBackupCreation(request): def backupStatus(request): try: - userID = request.session['userID'] + userID = 1 wm = BackupManager() return wm.backupStatus(userID, json.loads(request.body)) except KeyError: diff --git a/install/gun-configs/gunicorn.service b/install/gun-configs/gunicorn.service index fdc466849..066fe4b26 100644 --- a/install/gun-configs/gunicorn.service +++ b/install/gun-configs/gunicorn.service @@ -5,8 +5,8 @@ After=network.target [Service] PIDFile=/run/gunicorn/pid -User=cyberpanel -Group=cyberpanel +User=root +Group=root RuntimeDirectory=gunicorn WorkingDirectory=/usr/local/CyberCP ExecStart=/usr/local/CyberCP/bin/gunicorn --pid /run/gunicorn/gucpid \ diff --git a/install/install.py b/install/install.py index 519526091..5b0a65f9d 100644 --- a/install/install.py +++ b/install/install.py @@ -9,6 +9,17 @@ from firewallUtilities import FirewallUtilities import time import string import random +import sys +import subprocess +import shutil +import installLog as logging +import argparse +import os +import shlex +from firewallUtilities import FirewallUtilities +import time +import string +import random # There can not be peace without first a great suffering. @@ -3146,6 +3157,30 @@ milter_default_action = accept logging.InstallLog.writeToFile(str(msg) + " [installNoVNC]") return 0 + def touchOSFile(self): + try: + osPath = "/home/cyberpanel/os" + + osS = """centos-6 +centos-7.2 +debian-9 +fedora-28 +ubuntu-16.04 +ubuntu-18.04 +""" + + osFile = open(osPath, 'w') + osFile.write(osS) + osFile.close() + + except OSError, msg: + logging.InstallLog.writeToFile(str(msg) + " [touchOSFile]") + return 0 + except ValueError, msg: + logging.InstallLog.writeToFile(str(msg) + " [touchOSFile]") + return 0 + + def main(): @@ -3258,6 +3293,7 @@ def main(): checks.modSecPreReqs() checks.setupPHPAndComposer() + checks.touchOSFile() if args.postfix != None: diff --git a/mailServer/static/mailServer/mailServer.js b/mailServer/static/mailServer/mailServer.js index 6904888eb..eabb4acf5 100644 --- a/mailServer/static/mailServer/mailServer.js +++ b/mailServer/static/mailServer/mailServer.js @@ -1011,7 +1011,7 @@ app.controller('emailForwarding', function($scope,$http) { }; - $scope.deleteForwarding = function(destination){ + $scope.deleteForwarding = function(source, destination){ $scope.creationBox = true; $scope.emailDetails = true; @@ -1025,7 +1025,8 @@ app.controller('emailForwarding', function($scope,$http) { var data = { - destination:destination + destination:destination, + source: source }; var config = { diff --git a/mailServer/templates/mailServer/emailForwarding.html b/mailServer/templates/mailServer/emailForwarding.html index 82c76ec1d..2ae98418f 100644 --- a/mailServer/templates/mailServer/emailForwarding.html +++ b/mailServer/templates/mailServer/emailForwarding.html @@ -118,7 +118,7 @@ - + diff --git a/mailServer/views.py b/mailServer/views.py index 9f36e00a6..687abd8c3 100644 --- a/mailServer/views.py +++ b/mailServer/views.py @@ -311,8 +311,9 @@ def submitForwardDeletion(request): data = json.loads(request.body) destination = data['destination'] + source = data['source'] - forwarding = Forwardings.objects.get(destination=destination) + forwarding = Forwardings.objects.get(destination=destination, source=source) forwarding.delete() data_ret = {'deleteForwardingStatus': 1, 'error_message': "None", 'successMessage':'Successfully deleted!'} diff --git a/packages/templates/packages/createPackage.html b/packages/templates/packages/createPackage.html index 7bf0949ec..0361d1d96 100644 --- a/packages/templates/packages/createPackage.html +++ b/packages/templates/packages/createPackage.html @@ -96,7 +96,7 @@
-

{% trans "Package" %} {$ createdPackage $} {% trans "Successfully Created" %}"

+

{% trans "Package" %} {$ createdPackage $} {% trans "Successfully Created" %}

diff --git a/plogical/backupManager.py b/plogical/backupManager.py index 7992baec5..69bc69062 100755 --- a/plogical/backupManager.py +++ b/plogical/backupManager.py @@ -152,6 +152,7 @@ class BackupManager: return HttpResponse(final_json) except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile(str(msg)) final_dic = {'metaStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index 5778658ec..7b49753ed 100755 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -864,27 +864,19 @@ class backupUtilities: @staticmethod def getAliases(masterDomain): try: - - confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") - command = "sudo cat " + confPath - data = subprocess.check_output(shlex.split(command)).splitlines() aliases = [] + master = Websites.objects.get(domain=masterDomain) + aliasDomains = master.aliasdomains_set.all() - for items in data: - if items.find(masterDomain) > -1 and items.find('map') > -1: - data = filter(None, items.split(" ")) - if data[1] == masterDomain: - length = len(data) - for i in range(3, length): - currentAlias = data[i].rstrip(',').strip('\n') - aliases.append(currentAlias) - + for items in aliasDomains: + aliases.append(items.aliasDomain) return aliases except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [getAliases]") print 0 + return 0 def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain): diff --git a/plogical/remoteTransferUtilities.py b/plogical/remoteTransferUtilities.py index e2b9d2a8d..50eab8979 100755 --- a/plogical/remoteTransferUtilities.py +++ b/plogical/remoteTransferUtilities.py @@ -192,6 +192,7 @@ class remoteTransferUtilities: writeToFile.close() break except: + logging.CyberCPLogFileWriter.writeToFile(str(msg)) pass writeToFile = open(backupLogPath, "a") diff --git a/static/mailServer/mailServer.js b/static/mailServer/mailServer.js index 6904888eb..eabb4acf5 100644 --- a/static/mailServer/mailServer.js +++ b/static/mailServer/mailServer.js @@ -1011,7 +1011,7 @@ app.controller('emailForwarding', function($scope,$http) { }; - $scope.deleteForwarding = function(destination){ + $scope.deleteForwarding = function(source, destination){ $scope.creationBox = true; $scope.emailDetails = true; @@ -1025,7 +1025,8 @@ app.controller('emailForwarding', function($scope,$http) { var data = { - destination:destination + destination:destination, + source: source }; var config = { diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index b0e71156c..f15598c12 100644 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -48,7 +48,7 @@ def siteState(request): try: userID = request.session['userID'] wm = WebsiteManager() - return wm.suspendWebsite(request, userID) + return wm.siteState(request, userID) except KeyError: return redirect(loadLoginPage)