diff --git a/CLManager/CLManagerMain.py b/CLManager/CLManagerMain.py index 2a02fd91c..a2809033f 100644 --- a/CLManager/CLManagerMain.py +++ b/CLManager/CLManagerMain.py @@ -10,7 +10,7 @@ from django.shortcuts import HttpResponse from math import ceil from websiteFunctions.models import Websites from CLManager.models import CLPackages - +from plogical.httpProc import httpProc class CLManagerMain(multi.Thread): @@ -27,29 +27,14 @@ class CLManagerMain(multi.Thread): self.submitCageFSInstall() elif self.function == 'enableOrDisable': self.enableOrDisable() - except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [ContainerManager.run]') def renderC(self): - userID = self.request.session['userID'] - currentACL = ACLManager.loadedACL(userID) - - if currentACL['admin'] == 1: - pass - else: - return ACLManager.loadError() - - ipFile = "/etc/cyberpanel/machineIP" - f = open(ipFile) - ipData = f.read() - ipAddress = ipData.split('\n', 1)[0] - data = {} data['CL'] = 0 data['activatedPath'] = 0 - data['ipAddress'] = ipAddress CLPath = '/etc/sysconfig/cloudlinux' activatedPath = '/home/cyberpanel/cloudlinux' @@ -60,11 +45,14 @@ class CLManagerMain(multi.Thread): data['activatedPath'] = 1 if data['CL'] == 0: - return render(self.request, 'CLManager/notAvailable.html', data) + proc = httpProc(self.request, 'CLManager/notAvailable.html', data, 'admin') + return proc.render() elif data['activatedPath'] == 0: - return render(self.request, 'CLManager/notAvailable.html', data) + proc = httpProc(self.request, 'CLManager/notAvailable.html', data, 'admin') + return proc.render() else: - return render(self.request, 'CLManager/cloudLinux.html', data) + proc = httpProc(self.request, 'CLManager/cloudLinux.html', data, 'admin') + return proc.render() def submitCageFSInstall(self): try: diff --git a/CLScript/CLMain.py b/CLScript/CLMain.py index c6f730ba4..0d09cec9b 100644 --- a/CLScript/CLMain.py +++ b/CLScript/CLMain.py @@ -4,8 +4,8 @@ class CLMain(): def __init__(self): self.path = '/usr/local/CyberCP/version.txt' #versionInfo = json.loads(open(self.path, 'r').read()) - self.version = '2.0' - self.build = '3' + self.version = '2.1' + self.build = '1' ipFile = "/etc/cyberpanel/machineIP" f = open(ipFile) diff --git a/CLScript/CloudLinuxResellers.py b/CLScript/CloudLinuxResellers.py index 0f93d04a6..c64509b33 100755 --- a/CLScript/CloudLinuxResellers.py +++ b/CLScript/CloudLinuxResellers.py @@ -14,7 +14,6 @@ import argparse import json from CLScript.CLMain import CLMain - class CloudLinuxResellers(CLMain): def __init__(self, id, name): @@ -23,17 +22,26 @@ class CloudLinuxResellers(CLMain): self.name = name def listAll(self, owner=None): + import pwd users = [] acl = ACL.objects.get(name='reseller') + from plogical.vhost import vhost for items in Administrator.objects.filter(acl=acl): if self.name != None: if self.name != items.userName: continue + + try: + uid = pwd.getpwnam(items.userName).pw_uid + except: + vhost.addUser(items.userName, '/home/%s' % (items.userName)) + uid = pwd.getpwnam(items.userName).pw_uid + user = {'name': items.userName, "locale_code": "EN_us", "email": items.email, - "id": None + "id": uid } users.append(user) diff --git a/CLScript/CloudLinuxUsers.py b/CLScript/CloudLinuxUsers.py index bdc984655..a26d2e9e5 100755 --- a/CLScript/CloudLinuxUsers.py +++ b/CLScript/CloudLinuxUsers.py @@ -81,7 +81,7 @@ class CloudLinuxUsers(CLMain): for webs in websites: try: itemPackage = webs.package - package = {'name': itemPackage.packageName, 'owner': webs.externalApp} + package = {'name': itemPackage.packageName, 'owner': webs.admin.userName} user = {} @@ -92,7 +92,12 @@ class CloudLinuxUsers(CLMain): user['username'] = webs.externalApp if self.ow: - user['owner'] = webs.externalApp + if webs.admin.owner == 1: + user['owner'] = webs.admin.userName + else: + from loginSystem.models import Administrator + oAdmin = Administrator.objects.get(pk=webs.admin.owner) + user['owner'] = oAdmin.userName if self.domain: user['domain'] = webs.domain @@ -133,7 +138,11 @@ class CloudLinuxUsers(CLMain): if self.owner == None: websites = Websites.objects.all() else: - websites = Websites.objects.filter(externalApp=self.owner) + from loginSystem.models import Administrator + from plogical.acl import ACLManager + oAdmin = Administrator.objects.get(userName=self.owner) + currentACL = ACLManager.loadedACL(oAdmin.pk) + websites = ACLManager.findWebsiteObjects(currentACL, oAdmin.pk) if self.username != None: websites = websites.filter(externalApp=self.username) diff --git a/CLScript/UserInfo.py b/CLScript/UserInfo.py index 472b614f3..55b266be9 100755 --- a/CLScript/UserInfo.py +++ b/CLScript/UserInfo.py @@ -2,10 +2,15 @@ import getpass def main(): + import pwd if getpass.getuser() == 'root': userType = "admin" else: - userType = "user" + try: + uid = pwd.getpwnam(getpass.getuser()).pw_uid + userType = 'reseller' + except: + userType = 'user' data = """{ "userName": "%s", diff --git a/CyberCP/secMiddleware.py b/CyberCP/secMiddleware.py index 8f0271330..064b6e905 100755 --- a/CyberCP/secMiddleware.py +++ b/CyberCP/secMiddleware.py @@ -1,7 +1,7 @@ # coding=utf-8 from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging import json -from django.shortcuts import HttpResponse +from django.shortcuts import HttpResponse, render import re from loginSystem.models import Administrator @@ -96,17 +96,24 @@ class secMiddleware: logging.writeToFile(str(msg)) response = self.get_response(request) return response - + # else: + # try: + # if request.path.find('cloudAPI/') > -1 or request.path.find('api/') > -1: + # pass + # else: + # uID = request.session['userID'] + # except: + # return render(request, 'loginSystem/login.html', {}) response = self.get_response(request) response['X-XSS-Protection'] = "1; mode=block" - #response['Strict-Transport-Security'] = "max-age=31536000; includeSubDomains; preload" response['X-Frame-Options'] = "sameorigin" response['Content-Security-Policy'] = "script-src 'self' https://www.jsdelivr.com" response['Content-Security-Policy'] = "connect-src *;" response['Content-Security-Policy'] = "font-src 'self' 'unsafe-inline' https://www.jsdelivr.com https://fonts.googleapis.com" response['Content-Security-Policy'] = "style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://www.jsdelivr.com https://cdnjs.cloudflare.com https://maxcdn.bootstrapcdn.com https://cdn.jsdelivr.net" + #response['Content-Security-Policy'] = "default-src 'self' cyberpanel.cloud *.cyberpanel.cloud" response['X-Content-Type-Options'] = "nosniff" response['Referrer-Policy'] = "same-origin" diff --git a/IncBackups/IncBackupPath.py b/IncBackups/IncBackupPath.py new file mode 100644 index 000000000..10cc418b1 --- /dev/null +++ b/IncBackups/IncBackupPath.py @@ -0,0 +1,7 @@ +from enum import Enum + + +class IncBackupPath(Enum): + SFTP = "/home/cyberpanel/sftp" + AWS = "/home/cyberpanel/aws" + # WASABI = "/home/cyberpanel/wasabi" diff --git a/IncBackups/IncBackupProvider.py b/IncBackups/IncBackupProvider.py new file mode 100644 index 000000000..9645be3d5 --- /dev/null +++ b/IncBackups/IncBackupProvider.py @@ -0,0 +1,8 @@ +from enum import Enum, auto + + +class IncBackupProvider(Enum): + LOCAL = auto() + SFTP = auto() + AWS = auto() + # WASABI = auto() diff --git a/IncBackups/IncBackupsControl.py b/IncBackups/IncBackupsControl.py index c8e17ef83..c62152edc 100644 --- a/IncBackups/IncBackupsControl.py +++ b/IncBackups/IncBackupsControl.py @@ -83,9 +83,7 @@ class IncJobs(multi.Thread): result = self.getRemoteBackups() activator = 0 - json_data = "[" - checker = 0 - + json_data = [] if result[0].find('unable to open config file') == -1: for items in reversed(result): @@ -98,20 +96,11 @@ class IncJobs(multi.Thread): if activator: entry = items.split(' ') - - dic = {'id': entry[0], - 'date': "%s %s" % (entry[2], entry[3]), - 'host': entry[5], - 'path': entry[-1] - } - - if checker == 0: - json_data = json_data + json.dumps(dic) - checker = 1 - else: - json_data = json_data + ',' + json.dumps(dic) - - json_data = json_data + ']' + json_data.append({'id': entry[0], + 'date': "%s %s" % (entry[2], entry[3]), + 'host': entry[5], + 'path': entry[-1] + }) final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) diff --git a/IncBackups/static/IncBackups/IncBackups.js b/IncBackups/static/IncBackups/IncBackups.js index 32b01ef70..9031c393d 100644 --- a/IncBackups/static/IncBackups/IncBackups.js +++ b/IncBackups/static/IncBackups/IncBackups.js @@ -101,7 +101,7 @@ app.controller('createIncrementalBackups', function ($scope, $http, $timeout) { function ListInitialDatas(response) { if (response.data.status === 1) { - $scope.records = JSON.parse(response.data.data); + $scope.records = response.data.data; } else { new PNotify({ title: 'Error!', @@ -240,7 +240,7 @@ app.controller('createIncrementalBackups', function ($scope, $http, $timeout) { function ListInitialDatas(response) { $scope.cyberpanelLoading = true; if (response.data.status === 1) { - $scope.jobs = JSON.parse(response.data.data); + $scope.jobs = response.data.data; } else { new PNotify({ title: 'Operation Failed!', @@ -358,7 +358,7 @@ app.controller('incrementalDestinations', function ($scope, $http) { function ListInitialDatas(response) { $scope.cyberpanelLoading = true; if (response.data.status === 1) { - $scope.records = JSON.parse(response.data.data); + $scope.records = response.data.data; } else { new PNotify({ title: 'Operation Failed!', @@ -621,7 +621,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) { if (response.data.status === 1) { new PNotify({ title: 'Success!', - text: 'Destination successfully removed.', + text: 'Operation successful.', type: 'success' }); } else { @@ -668,12 +668,11 @@ app.controller('scheduleBackupInc', function ($scope, $http) { function ListInitialDatas(response) { $scope.cyberpanelLoading = true; if (response.data.status === 1) { - $scope.records = JSON.parse(response.data.data); - var parsed = JSON.parse(response.data.data); - - for (var j = 0; j < parsed.length; j++) { - websitesToBeBackedTemp.push(parsed[j].website); - } + let data = response.data.data; + $scope.records = data; + data.forEach(item => { + websitesToBeBackedTemp.push(item.website) + }) } else { new PNotify({ title: 'Operation Failed!', @@ -766,7 +765,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) { function ListInitialDatas(response) { $scope.cyberpanelLoading = true; if (response.data.status === 1) { - $scope.websites = JSON.parse(response.data.data); + $scope.websites = response.data.data; if(response.data.websiteData === 1){ $scope.websiteData = true; @@ -1074,7 +1073,7 @@ app.controller('restoreRemoteBackupsInc', function ($scope, $http, $timeout) { function ListInitialDatas(response) { $scope.cyberpanelLoading = true; if (response.data.status === 1) { - $scope.records = JSON.parse(response.data.data); + $scope.records = response.data.data; } else { new PNotify({ title: 'Error!', diff --git a/IncBackups/templates/IncBackups/restoreRemoteBackups.html b/IncBackups/templates/IncBackups/restoreRemoteBackups.html index b9e6b9228..7c2b38caa 100755 --- a/IncBackups/templates/IncBackups/restoreRemoteBackups.html +++ b/IncBackups/templates/IncBackups/restoreRemoteBackups.html @@ -55,7 +55,7 @@
{% trans "Use the tabs to navigate through the control panel." %}
+Error: {{ error_message }}
+{% trans "Use the tabs to navigate through the control panel." %}
-{% trans "Use the tabs to navigate through the control panel." %}
+