diff --git a/CyberCP/secMiddleware.py b/CyberCP/secMiddleware.py index 39de0f2c6..47fd6a4bd 100755 --- a/CyberCP/secMiddleware.py +++ b/CyberCP/secMiddleware.py @@ -72,7 +72,7 @@ class secMiddleware: final_json = json.dumps(final_dic) return HttpResponse(final_json) - if request.build_absolute_uri().find('api/verifyConn') > -1 or request.build_absolute_uri().find('webhook') > -1 or request.build_absolute_uri().find('saveSpamAssassinConfigurations') > -1 or request.build_absolute_uri().find('docker') > -1 or request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1: + if request.build_absolute_uri().find('api/remoteTransfer') > -1 or request.build_absolute_uri().find('api/verifyConn') > -1 or request.build_absolute_uri().find('webhook') > -1 or request.build_absolute_uri().find('saveSpamAssassinConfigurations') > -1 or request.build_absolute_uri().find('docker') > -1 or request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1: continue if key == 'key' or key == 'cert' or key == 'recordContentAAAA' or key == 'backupDestinations' or key == 'ports' \ or key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' \ diff --git a/api/views.py b/api/views.py index 8c61fa691..257648f27 100755 --- a/api/views.py +++ b/api/views.py @@ -435,10 +435,14 @@ def remoteTransfer(request): ## Accounts to transfer is a path to file, containing accounts. + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py" - execPath = execPath + " remoteTransfer --ipAddress " + ipAddress + " --dir " + dir + " --accountsToTransfer " + path + execPath = execPath + " remoteTransfer --ipAddress " + ipAddress.rstrip('\n') + " --dir " + dir + " --accountsToTransfer " + path ProcessUtilities.popenExecutioner(execPath) + if os.path.exists('/usr/local/CyberCP/debug'): + logging.writeToFile('Repor of %s' % repr(execPath)) + return HttpResponse(json.dumps({"transferStatus": 1, "dir": dir})) ## diff --git a/backup/backupManager.py b/backup/backupManager.py index c4bc4a788..c42a80d32 100755 --- a/backup/backupManager.py +++ b/backup/backupManager.py @@ -1163,6 +1163,10 @@ class BackupManager: r = requests.post(url, data=finalData, verify=False) + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'Remote transfer initiation status: %s' % (r.text) + logging.CyberCPLogFileWriter.writeToFile(message) + data = json.loads(r.text) if data['transferStatus'] == 1: diff --git a/plogical/backupSchedule.py b/plogical/backupSchedule.py index c0efe9427..919bb2d1a 100755 --- a/plogical/backupSchedule.py +++ b/plogical/backupSchedule.py @@ -89,8 +89,21 @@ class backupSchedule: ifRunning = ProcessUtilities.outputExecutioner('ps aux') + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'Output of px aux when running remote backup status check: %s' % (ifRunning) + logging.CyberCPLogFileWriter.writeToFile(message) + + if (ifRunning.find('startBackup') > -1 or ifRunning.find('BackupRoot') > -1) and ifRunning.find('/%s/' % (backupDomain)): + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'If running found.' + logging.CyberCPLogFileWriter.writeToFile(message) + if os.path.exists(status): + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'If running found. and status file exists' + logging.CyberCPLogFileWriter.writeToFile(message) + status = open(status, 'r').read() time.sleep(2) @@ -115,6 +128,9 @@ class backupSchedule: return 1, tempStoragePath elif status.find("[5009]") > -1: + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'If running found. status file exists but error' + logging.CyberCPLogFileWriter.writeToFile(message) ## removing status file, so that backup can re-run try: command = 'sudo rm -f ' + status @@ -150,6 +166,9 @@ class backupSchedule: return 0, tempStoragePath elif os.path.exists(schedulerPath): + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'If running found. status file exists, scheduler path also exists hence killed' + logging.CyberCPLogFileWriter.writeToFile(message) backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed. Error: %s' % ( open(schedulerPath, 'r').read()), backupSchedule.ERROR) @@ -157,8 +176,15 @@ class backupSchedule: command = 'rm -rf %s' % (tempStoragePath) ProcessUtilities.normalExecutioner(command) return 0, 'Backup process killed.' + else: + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'If running not found.' + logging.CyberCPLogFileWriter.writeToFile(message) if os.path.exists(status): + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'if running not found, Status file exists' + logging.CyberCPLogFileWriter.writeToFile(message) status = open(status, 'r').read() time.sleep(2) @@ -182,6 +208,11 @@ class backupSchedule: pass return 1, tempStoragePath elif os.path.exists(schedulerPath): + + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'if running not found, Status file exists, scheduler path exists thus killed.' + logging.CyberCPLogFileWriter.writeToFile(message) + backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed. Error: %s' % (open(schedulerPath, 'r').read()), backupSchedule.ERROR) os.remove(schedulerPath) @@ -189,13 +220,23 @@ class backupSchedule: ProcessUtilities.normalExecutioner(command) return 0, 'Backup process killed.' else: + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'Status file does not exists.' + logging.CyberCPLogFileWriter.writeToFile(message) if killCounter == 1: + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'if running not found, Status file does not exists, kill counter 1, thus killed' + logging.CyberCPLogFileWriter.writeToFile(message) + command = 'rm -rf %s' % (tempStoragePath) ProcessUtilities.normalExecutioner(command) return 0, 'Backup process killed without reporting any error. [184]' elif os.path.exists(schedulerPath): + if os.path.exists('/usr/local/CyberCP/debug'): + message = 'if running not found, Status file does not exists, scheduler path found thus killed' + logging.CyberCPLogFileWriter.writeToFile(message) backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed. Error: %s' % ( open(schedulerPath, 'r').read()), backupSchedule.ERROR) diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index dfe889493..2eaab56c9 100755 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -645,7 +645,7 @@ class backupUtilities: dbName = database.find('dbName').text - if VERSION == '2.1' and int(BUILD) >= 1: + if (VERSION == '2.1' or VERSION == '2.3') and int(BUILD) >= 1: logging.CyberCPLogFileWriter.writeToFile('Backup version 2.1.1+ detected..') databaseUsers = database.findall('databaseUsers') @@ -912,7 +912,7 @@ class backupUtilities: dbName = database.find('dbName').text - if VERSION == '2.1' and int(BUILD) >= 1: + if (VERSION == '2.1' or VERSION == '2.3') and int(BUILD) >= 1: logging.CyberCPLogFileWriter.writeToFile('Backup version 2.1.1+ detected..') @@ -963,6 +963,7 @@ class backupUtilities: # /home/backup/backup-example.com-02.13.2018_10-24-52/public_html.tar.gz ## Moving above v2.0.0 extracting webhome data is not required, thus commenting below lines + if not twoPointO: tar = tarfile.open(pathToCompressedHome) tar.extractall(websiteHome) diff --git a/plogical/processUtilities.py b/plogical/processUtilities.py index 406a770f3..2a3cd62ca 100755 --- a/plogical/processUtilities.py +++ b/plogical/processUtilities.py @@ -225,7 +225,8 @@ class ProcessUtilities(multi.Thread): command = 'sudo %s' % (command) if os.path.exists(ProcessUtilities.debugPath): - logging.writeToFile(ProcessUtilities.token + command) + if command.find('cat') == -1: + logging.writeToFile(ProcessUtilities.token + command) if dir == None: sock.sendall((ProcessUtilities.token + command).encode('utf-8')) @@ -238,8 +239,11 @@ class ProcessUtilities(multi.Thread): else: command = '%s-u %s -d %s %s' % (ProcessUtilities.token, user, dir, command) command = command.replace('sudo', '') + + if os.path.exists(ProcessUtilities.debugPath): - logging.writeToFile(command) + if command.find('cat') == -1: + logging.writeToFile(command) sock.sendall(command.encode('utf-8'))