From 0ae3c01c5c720ba1e662260099d1e4cb9bd3d69e Mon Sep 17 00:00:00 2001 From: "usman@cyberpersons.com" Date: Sat, 1 Apr 2023 23:37:08 +0500 Subject: [PATCH] bug fix: backups to rustic --- IncBackups/views.py | 56 +++++-- manageSSL/templates/manageSSL/manageSSL.html | 138 +++++++++--------- .../templates/manageSSL/v2ManageSSL.html | 66 ++------- manageSSL/views.py | 13 +- plogical/Backupsv2.py | 17 +-- plogical/dnsUtilities.py | 27 +++- plogical/sslUtilities.py | 19 +++ plogical/sslv2.py | 7 +- plogical/test.py | 26 ---- 9 files changed, 198 insertions(+), 171 deletions(-) diff --git a/IncBackups/views.py b/IncBackups/views.py index d70066154..090d17799 100644 --- a/IncBackups/views.py +++ b/IncBackups/views.py @@ -712,27 +712,25 @@ def add_website(request): final_json = json.dumps({'status': 0, 'error_message': str(msg)}) return HttpResponse(final_json) - +#### Backups v2 def ConfigureV2Backup(request): try: user_id, current_acl = _get_user_acl(request) + if ACLManager.currentContextPermission(current_acl, 'createBackup') == 0: return ACLManager.loadError() - websites = ACLManager.findAllSites(current_acl, user_id) # # destinations = _get_destinations(local=True) proc = httpProc(request, 'IncBackups/ConfigureV2Backup.html', {'websiteList': websites}) return proc.render() - except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) - def CreateV2Backup(request): try: userID = request.session['userID'] @@ -753,8 +751,18 @@ def createV2BackupSetup(request): req_data['scopes'] = request.GET.get('s') req_data['accountname'] = request.GET.get('n') website = request.GET.get('d') + # logging.writeToFile('domainname is ====%s'%(request.GET.get)) + currentACL = ACLManager.loadedACL(userID) + admin = Administrator.objects.get(pk=userID) + + + if ACLManager.checkOwnership(website, admin, currentACL) == 1: + pass + else: + return ACLManager.loadError() + cpbuv2 = CPBackupsV2( {'domain': website, 'BasePath': '/home/backup', 'BackupDatabase': 1, 'BackupData': 1, 'BackupEmails': 1, 'BackendName': 'testremote'}) @@ -766,7 +774,6 @@ def createV2BackupSetup(request): except KeyError: return redirect(loadLoginPage) - def CreateV2BackupButton(request): import re try: @@ -775,8 +782,13 @@ def CreateV2BackupButton(request): Selectedwebsite = data['Selectedwebsite'] Selectedrepo = data['Selectedrepo'] + currentACL = ACLManager.loadedACL(userID) + admin = Administrator.objects.get(pk=userID) - + if ACLManager.checkOwnership(Selectedwebsite, admin, currentACL) == 1: + pass + else: + return ACLManager.loadError() background = CPBackupsV2({'domain': Selectedwebsite, 'BasePath': '/home/backup', 'BackupDatabase': 1, 'BackupData': 1, 'BackupEmails': 1, 'BackendName': Selectedrepo, 'function': 'InitiateBackup', }) @@ -793,7 +805,6 @@ def CreateV2BackupButton(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - def CreateV2BackupStatus(request): try: userID = request.session['userID'] @@ -833,8 +844,15 @@ def selectwebsiteRetorev2(request): userID = request.session['userID'] data = json.loads(request.body) Selectedwebsite = data['Selectedwebsite'] + + currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) + if ACLManager.checkOwnership(str(Selectedwebsite), admin, currentACL) == 1: + pass + else: + return ACLManager.loadError() + obj = Websites.objects.get(domain = str(Selectedwebsite), admin = admin) #/home/cyberpanel.net/.config/rclone/rclone.conf path = '/home/%s/.config/rclone/rclone.conf' %(obj.domain) @@ -859,8 +877,6 @@ def selectwebsiteRetorev2(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - - def ConfigureSftpV2Backup(request): try: userID = request.session['userID'] @@ -869,8 +885,14 @@ def ConfigureSftpV2Backup(request): sfptpasswd = data['sfptpasswd'] hostName = data['hostName'] UserName = data['UserName'] + currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) + if ACLManager.checkOwnership(str(Selectedwebsite), admin, currentACL) == 1: + pass + else: + return ACLManager.loadError() + req_data = {} req_data['name'] = 'SFTP' req_data['host'] = hostName @@ -895,15 +917,21 @@ def ConfigureSftpV2Backup(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - def selectwebsiteCreatev2(request): import re try: userID = request.session['userID'] data = json.loads(request.body) Selectedwebsite = data['Selectedwebsite'] + + currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) + if ACLManager.checkOwnership(str(Selectedwebsite), admin, currentACL) == 1: + pass + else: + return ACLManager.loadError() + obj = Websites.objects.get(domain = str(Selectedwebsite), admin = admin) #/home/cyberpanel.net/.config/rclone/rclone.conf path = '/home/%s/.config/rclone/rclone.conf' %(obj.domain) @@ -963,15 +991,21 @@ def selectwebsiteCreatev2(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - def selectreporestorev2(request): try: userID = request.session['userID'] data = json.loads(request.body) Selectedrepo = data['Selectedrepo'] Selectedwebsite= data['Selectedwebsite'] + currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) + if ACLManager.checkOwnership(str(Selectedwebsite), admin, currentACL) == 1: + pass + else: + return ACLManager.loadError() + + # f'rustic -r testremote snapshots --password "" --json 2>/dev/null' # final_json = json.dumps({'status': 0, 'fetchStatus': 1, 'error_message': Selectedrepo }) # return HttpResponse(final_json) diff --git a/manageSSL/templates/manageSSL/manageSSL.html b/manageSSL/templates/manageSSL/manageSSL.html index b769e1add..2b3f41e78 100755 --- a/manageSSL/templates/manageSSL/manageSSL.html +++ b/manageSSL/templates/manageSSL/manageSSL.html @@ -3,78 +3,80 @@ {% block title %}{% trans "Manage SSL - CyberPanel" %}{% endblock %} {% block content %} -{% load static %} -{% get_current_language as LANGUAGE_CODE %} - - - -
-
-

{% trans "Manage SSL" %} - {% trans "SSL Docs" %}

-

{% trans "This page can be used to issue Let’s Encrypt SSL for existing websites on server." %}

-
- -
-
-

- {% trans "Manage SSL" %} -

-
- - -
- - -
- -
- -
-
- -
- -
- - -
-
- - -
- -
-
-

{% trans "Cannot issue SSL. Error message:" %} {$ errorMessage $}

-
- -
-

{% trans "SSL Issued for" %} {$ sslDomain $}

-
- -
-

{% trans "Could not connect to server. Please refresh this page." %}

-
-
- - -
- - -
- + {% load static %} + {% get_current_language as LANGUAGE_CODE %} + +
+
+

{% trans "Manage SSL" %} - {% trans "SSL Docs" %}

+

{% trans "This page can be used to issue Let’s Encrypt SSL for existing websites on server." %}

+ +
+
+

+ {% trans "Manage SSL" %} +

+
+ + +
+ + +
+ +
+ +
+
+ +
+ +
+ + +
+
+ + +
+ +
+
+

{% trans "Cannot issue SSL. Error message:" %} {$ errorMessage $}

+
+ +
+

{% trans "SSL Issued for" %} {$ sslDomain $}

+
+ +
+

{% trans "Could not connect to server. Please refresh this page." %}

+
+
+ + +
+ +
+ + +
+
+
+ +
-
- - -
{% endblock %} diff --git a/manageSSL/templates/manageSSL/v2ManageSSL.html b/manageSSL/templates/manageSSL/v2ManageSSL.html index 43ffdafc4..a151f7379 100755 --- a/manageSSL/templates/manageSSL/v2ManageSSL.html +++ b/manageSSL/templates/manageSSL/v2ManageSSL.html @@ -19,17 +19,25 @@

- {% trans "Add Records" %} + {% trans "SSL v2" %}

- - + {% if SaveSuccess %} +
+ +
+
+

{% trans "Changes saved succesfully." %}

+
+
+
+ {% endif %}