diff --git a/CyberCP/secMiddleware.py b/CyberCP/secMiddleware.py index 27de0fe89..62d13d283 100644 --- a/CyberCP/secMiddleware.py +++ b/CyberCP/secMiddleware.py @@ -1,5 +1,6 @@ from django.conf import settings from django.shortcuts import HttpResponse +from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging class secMiddleware: @@ -9,6 +10,6 @@ class secMiddleware: def __call__(self, request): if request.method == 'POST': if request.body.find(';') > -1 or request.body.find('&&') > -1 or request.body.find('|') > -1 or request.body.find('...') > -1: - return HttpResponse('Bad input.') + logging.writeToFile('Bad Input on.') response = self.get_response(request) return response \ No newline at end of file diff --git a/CyberCP/settings.py b/CyberCP/settings.py index d0d1f47c9..ba653da73 100644 --- a/CyberCP/settings.py +++ b/CyberCP/settings.py @@ -24,7 +24,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False ALLOWED_HOSTS = ['*'] diff --git a/backup/templates/backup/backup.html b/backup/templates/backup/backup.html index 9393807ba..5d83cb414 100644 --- a/backup/templates/backup/backup.html +++ b/backup/templates/backup/backup.html @@ -11,7 +11,7 @@
-

{% trans "Back up Website" %}

+

{% trans "Back up Website" %} - {% trans "Backup Docs" %}

{% trans "This page can be used to Back up your websites" %}

diff --git a/backup/templates/backup/backupDestinations.html b/backup/templates/backup/backupDestinations.html index 4f219637c..f7fa6171f 100644 --- a/backup/templates/backup/backupDestinations.html +++ b/backup/templates/backup/backupDestinations.html @@ -11,7 +11,7 @@
-

{% trans "Set up Back up Destinations" %}

+

{% trans "Set up Back up Destinations" %} - {% trans "Remote Backups" %}

{% trans "On this page you can set up your Back up destinations. (SFTP)" %}

diff --git a/backup/templates/backup/backupSchedule.html b/backup/templates/backup/backupSchedule.html index a977d9c0b..2a2b35b81 100644 --- a/backup/templates/backup/backupSchedule.html +++ b/backup/templates/backup/backupSchedule.html @@ -10,7 +10,7 @@
-

{% trans "Schedule Back up" %}

+

{% trans "Schedule Back up" %} - {% trans "Remote Backups" %}

{% trans "On this page you can schedule Back ups to localhost or remote server (If you have added one)." %}

diff --git a/backup/templates/backup/remoteBackups.html b/backup/templates/backup/remoteBackups.html index b6eaf2fda..f65818880 100644 --- a/backup/templates/backup/remoteBackups.html +++ b/backup/templates/backup/remoteBackups.html @@ -11,7 +11,7 @@
-

{% trans "Remote Backups" %}

+

{% trans "Remote Backups" %} - {% trans "Remote Transfer" %}

{% trans "This feature can import website(s) from remote server" %}

diff --git a/backup/templates/backup/restore.html b/backup/templates/backup/restore.html index c9ea47be1..b1918595e 100644 --- a/backup/templates/backup/restore.html +++ b/backup/templates/backup/restore.html @@ -11,7 +11,7 @@
-

{% trans "Restore Website" %}

+

{% trans "Restore Website" %} - {% trans "Backup Docs" %}

{% trans "This page can be used to restore your websites, Back up should be generated from CyberPanel Back up generation tool, it will detect all Back ups under /home/backup." %}

diff --git a/dns/templates/dns/addDeleteDNSRecords.html b/dns/templates/dns/addDeleteDNSRecords.html index 56248584c..077e1eb08 100644 --- a/dns/templates/dns/addDeleteDNSRecords.html +++ b/dns/templates/dns/addDeleteDNSRecords.html @@ -10,7 +10,7 @@
-

{% trans "Add/Modify DNS Zone" %}

+

{% trans "Add/Modify DNS Zone" %} - {% trans "DNS Docs" %}

{% trans "On this page you can add/modify dns records for domains whose dns zone is already created." %}

diff --git a/dns/templates/dns/createDNSZone.html b/dns/templates/dns/createDNSZone.html index 39988311b..d575d2f9d 100644 --- a/dns/templates/dns/createDNSZone.html +++ b/dns/templates/dns/createDNSZone.html @@ -9,7 +9,7 @@
-

{% trans "Create DNS Zone" %}

+

{% trans "Create DNS Zone" %} - {% trans "DNS Docs" %}

{% trans "This page is used to create DNS zone, to edit dns zone you can visit Modify DNS Zone Page." %}

diff --git a/dns/templates/dns/createNameServer.html b/dns/templates/dns/createNameServer.html index 3cffc2eaa..cb6736c18 100644 --- a/dns/templates/dns/createNameServer.html +++ b/dns/templates/dns/createNameServer.html @@ -9,7 +9,7 @@
-

{% trans "Create Nameserver" %}

+

{% trans "Create Nameserver" %} - {% trans "DNS Docs" %}

{% trans "You can use this page to setup nameservers using which people on the internet can resolve websites hosted on this server." %}

diff --git a/dns/templates/dns/deleteDNSZone.html b/dns/templates/dns/deleteDNSZone.html index b4203b93e..4a90613db 100644 --- a/dns/templates/dns/deleteDNSZone.html +++ b/dns/templates/dns/deleteDNSZone.html @@ -9,7 +9,7 @@
-

{% trans "Delete DNS Zone" %}

+

{% trans "Delete DNS Zone" %} - {% trans "DNS Docs" %}

{% trans "This page can be used to delete DNS Zone. Deleting the DNS zone will remove all its related records as well." %}

diff --git a/emailPremium/templates/emailPremium/SpamAssassin.html b/emailPremium/templates/emailPremium/SpamAssassin.html index 274fbd24c..065ccec1c 100644 --- a/emailPremium/templates/emailPremium/SpamAssassin.html +++ b/emailPremium/templates/emailPremium/SpamAssassin.html @@ -10,7 +10,7 @@
-

{% trans "SpamAssassin Configurations!" %}

+

{% trans "SpamAssassin Configurations!" %} - {% trans "SpamAssassin Docs" %}

{% trans "On this page you can configure SpamAssassin settings." %}

diff --git a/emailPremium/templates/emailPremium/emailLimits.html b/emailPremium/templates/emailPremium/emailLimits.html index b935403fc..f3aeee57c 100644 --- a/emailPremium/templates/emailPremium/emailLimits.html +++ b/emailPremium/templates/emailPremium/emailLimits.html @@ -10,7 +10,7 @@
-

{{ domain }}

+

{{ domain }} - {% trans "Emai Limits Docs" %}

{% trans "View and change email limits for a domain name." %}

diff --git a/emailPremium/templates/emailPremium/emailPage.html b/emailPremium/templates/emailPremium/emailPage.html index e7a947bc4..a4f5f5c54 100644 --- a/emailPremium/templates/emailPremium/emailPage.html +++ b/emailPremium/templates/emailPremium/emailPage.html @@ -10,7 +10,7 @@
-

{{ emailAddress }}

+

{{ emailAddress }} - {% trans "Emai Limits Docs" %}

{% trans "View and change limits for an Email Address." %}

diff --git a/emailPremium/templates/emailPremium/listDomains.html b/emailPremium/templates/emailPremium/listDomains.html index d2de14444..9c3fe8826 100644 --- a/emailPremium/templates/emailPremium/listDomains.html +++ b/emailPremium/templates/emailPremium/listDomains.html @@ -11,7 +11,7 @@
-

{% trans "List Domains" %}

+

{% trans "List Domains" %} - {% trans "Emai Limits Docs" %}

{% trans "On this page you manage emails limits for Domains/Email Addresses" %}

diff --git a/emailPremium/templates/emailPremium/policyServer.html b/emailPremium/templates/emailPremium/policyServer.html index 70c18854d..3d9fea014 100644 --- a/emailPremium/templates/emailPremium/policyServer.html +++ b/emailPremium/templates/emailPremium/policyServer.html @@ -10,7 +10,7 @@
-

{% trans "Email Policy Server Configurations!" %}

+

{% trans "Email Policy Server Configurations!" %} - {% trans "Emai Limits Docs" %}

{% trans "Turn ON Email Policy Server to use Email Limits Feature. " %}

diff --git a/firewall/views.py b/firewall/views.py index 38cc58f62..849022036 100644 --- a/firewall/views.py +++ b/firewall/views.py @@ -442,7 +442,7 @@ def getSSHConfigs(request): def saveSSHConfigs(request): try: val = request.session['userID'] - admin= Administrator.objects.get(val=val) + admin= Administrator.objects.get(pk=val) try: if request.method == 'POST': data = json.loads(request.body) @@ -460,9 +460,7 @@ def saveSSHConfigs(request): rootLogin = data['rootLogin'] command = 'sudo semanage port -a -t ssh_port_t -p tcp ' +sshPort - cmd = shlex.split(command) - res = subprocess.call(cmd) diff --git a/install/install.py b/install/install.py index aac5428b6..a14493fba 100644 --- a/install/install.py +++ b/install/install.py @@ -44,7 +44,7 @@ class preFlightsChecks: else: logging.InstallLog.writeToFile("SELinux is enabled, please disable SELinux and restart the installation!") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) except BaseException,msg: logging.InstallLog.writeToFile(str(msg) + "[checkIfSeLinuxDisabled]") @@ -57,7 +57,7 @@ class preFlightsChecks: return 1 else: preFlightsChecks.stdOut("You are running Unsupported python version, please install python 2.7") - sys.exit() + os._exit(0) def setup_account_cyberpanel(self): try: @@ -74,7 +74,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("We are not able to install SUDO, exiting the installer. [setup_account_cyberpanel]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("SUDO successfully installed!") preFlightsChecks.stdOut("SUDO successfully installed!") @@ -95,7 +95,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("We are not able add user cyberpanel to system, exiting the installer. [setup_account_cyberpanel]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("CyberPanel user added!") preFlightsChecks.stdOut("CyberPanel user added!") @@ -117,7 +117,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Not able to add user CyberPanel to SUDO group, exiting the installer. [setup_account_cyberpanel]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("CyberPanel user was successfully added to SUDO group!") preFlightsChecks.stdOut("CyberPanel user was successfully added to SUDO group!") @@ -166,6 +166,8 @@ class preFlightsChecks: except: logging.InstallLog.writeToFile("[116] setup_account_cyberpanel") + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) def yum_update(self): try: @@ -198,9 +200,7 @@ class preFlightsChecks: return 1 def installCyberPanelRepo(self): - cmd = [] - count = 0 while(1): @@ -215,7 +215,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to add CyberPanel official repository, exiting installer! [installCyberPanelRepo]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("CyberPanel Repo added!") preFlightsChecks.stdOut("CyberPanel Repo added!") @@ -224,7 +224,6 @@ class preFlightsChecks: def enableEPELRepo(self): try: cmd = [] - count = 0 while (1): @@ -240,6 +239,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to add EPEL repository, exiting installer! [enableEPELRepo]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) else: logging.InstallLog.writeToFile("EPEL Repo added!") preFlightsChecks.stdOut("EPEL Repo added!") @@ -247,16 +247,19 @@ class preFlightsChecks: except OSError,msg: logging.InstallLog.writeToFile(str(msg) + " [enableEPELRepo]") + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) return 0 except ValueError,msg: logging.InstallLog.writeToFile(str(msg) + " [enableEPELRepo]") + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) return 0 return 1 def install_pip(self): count = 0 - while (1): command = "yum -y install python-pip" res = subprocess.call(shlex.split(command)) @@ -267,7 +270,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install PIP, exiting installer! [install_pip]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("PIP successfully installed!") preFlightsChecks.stdOut("PIP successfully installed!") @@ -285,7 +288,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install python development tools, exiting installer! [install_python_dev]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("Python development tools successfully installed!") preFlightsChecks.stdOut("Python development tools successfully installed!") @@ -304,7 +307,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install GCC, exiting installer! [install_gcc]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("GCC Successfully installed!") preFlightsChecks.stdOut("GCC Successfully installed!") @@ -324,9 +327,8 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile( "Unable to install Python setup tools, exiting installer! [install_python_setup_tools]") - print("[" + time.strftime( - "%I-%M-%S-%a-%b-%Y") + "] " + "Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) else: logging.InstallLog.writeToFile("Python setup tools Successfully installed!") print("[" + time.strftime("%I-%M-%S-%a-%b-%Y") + "] " + "Python setup tools Successfully installed!") @@ -362,7 +364,7 @@ class preFlightsChecks: logging.InstallLog.writeToFile( "Unable to install urllib3 module, exiting installer! [install_python_requests]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("urllib3 module Successfully installed!") preFlightsChecks.stdOut("urllib3 module Successfully installed!") @@ -383,7 +385,7 @@ class preFlightsChecks: logging.InstallLog.writeToFile( "Unable to install requests module, exiting installer! [install_python_requests]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("Requests module Successfully installed!") preFlightsChecks.stdOut("Requests module Successfully installed!") @@ -406,7 +408,7 @@ class preFlightsChecks: logging.InstallLog.writeToFile( "Unable to install urllib3 module, exiting installer! [install_python_requests]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("urllib3 module Successfully installed!") preFlightsChecks.stdOut("urllib3 module Successfully installed!") @@ -427,7 +429,7 @@ class preFlightsChecks: logging.InstallLog.writeToFile( "Unable to install requests module, exiting installer! [install_python_requests]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("Requests module Successfully installed!") preFlightsChecks.stdOut("Requests module Successfully installed!") @@ -453,7 +455,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install pexpect, exiting installer! [install_pexpect]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("pexpect successfully installed!") preFlightsChecks.stdOut("pexpect successfully installed!") @@ -472,7 +474,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install pexpect, exiting installer! [install_pexpect]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("pexpect successfully installed!") preFlightsChecks.stdOut("pexpect successfully installed!") @@ -491,7 +493,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install DJANGO, exiting installer! [install_django]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("DJANGO successfully installed!") preFlightsChecks.stdOut("DJANGO successfully installed!") @@ -508,7 +510,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install MySQL-python, exiting installer! [install_python_mysql_library]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("MySQL-python successfully installed!") preFlightsChecks.stdOut("MySQL-python successfully installed!") @@ -525,7 +527,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install GUNICORN, exiting installer! [install_gunicorn]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("GUNICORN successfully installed!") preFlightsChecks.stdOut("GUNICORN successfully installed!") @@ -571,26 +573,6 @@ class preFlightsChecks: preFlightsChecks.stdOut("Gunicorn can now start after system restart!") break - ## - - count = 0 - - while(1): - command = "systemctl start gunicorn.socket" - res = subprocess.call(shlex.split(command)) - - if res == 1: - count = count + 1 - preFlightsChecks.stdOut("Starting Gunicorn now, try number: " + str(count)) - if count == 3: - logging.InstallLog.writeToFile("Unable to start Gunicorn, exiting installer! [setup_gunicorn]") - preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() - else: - logging.InstallLog.writeToFile("Gunicorn successfully started!") - preFlightsChecks.stdOut("Gunicorn successfully started!") - break - except BaseException, msg: logging.InstallLog.writeToFile(str(msg) + " [setup_gunicorn]") preFlightsChecks.stdOut("Not able to setup gunicorn, see install log.") @@ -616,7 +598,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install psutil, exiting installer! [install_psutil]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("psutil successfully installed!") preFlightsChecks.stdOut("psutil successfully installed!") @@ -634,7 +616,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install psutil, exiting installer! [install_psutil]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("psutil successfully installed!") preFlightsChecks.stdOut("psutil successfully installed!") @@ -669,7 +651,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install psmisc, exiting installer! [install_psmisc]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("psmisc successfully installed!") preFlightsChecks.stdOut("psmisc successfully installed!") @@ -691,7 +673,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install upgrade requests, exiting installer! [download_install_CyberPanel]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("requests module successfully upgraded!") preFlightsChecks.stdOut("requests module successfully upgraded!") @@ -715,7 +697,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to download CyberPanel, exiting installer! [download_install_CyberPanel]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("CyberPanel successfully downloaded!") preFlightsChecks.stdOut("CyberPanel successfully downloaded!") @@ -736,7 +718,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to extract CyberPanel. You can try to install on fresh OS again, exiting installer! [download_install_CyberPanel]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("Successfully extracted CyberPanel!") preFlightsChecks.stdOut("Successfully extracted CyberPanel!") @@ -811,7 +793,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to prepare migrations file. You can try to install on fresh OS again, exiting installer! [download_install_CyberPanel]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("Successfully prepared migrations file!") preFlightsChecks.stdOut("Successfully prepared migrations file!") @@ -832,7 +814,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to execute the migrations file, exiting installer! [download_install_CyberPanel]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("Migrations file successfully executed!") preFlightsChecks.stdOut("Migrations file successfully executed!") @@ -846,7 +828,7 @@ class preFlightsChecks: if res == 1: logging.InstallLog.writeToFile("Could not move static content!") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("Static content moved!") preFlightsChecks.stdOut("Static content moved!") @@ -906,7 +888,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install unzip, exiting installer! [install_unzip]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("unzip successfully installed!") preFlightsChecks.stdOut("unzip Successfully installed!") @@ -924,9 +906,7 @@ class preFlightsChecks: def install_zip(self): try: - count = 0 - while (1): command = 'yum -y install zip' @@ -941,7 +921,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to install zip, exiting installer! [install_zip]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("zip successfully installed!") preFlightsChecks.stdOut("zip successfully installed!") @@ -963,7 +943,7 @@ class preFlightsChecks: count = 0 while(1): - command = 'wget https://files.phpmyadmin.net/phpMyAdmin/4.8.1/phpMyAdmin-4.8.1-all-languages.zip' + command = 'wget https://files.phpmyadmin.net/phpMyAdmin/4.8.2/phpMyAdmin-4.8.2-all-languages.zip' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -973,7 +953,7 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile("Unable to download PYPMYAdmin, exiting installer! [download_install_phpmyadmin]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("PHPMYAdmin successfully downloaded!") preFlightsChecks.stdOut("PHPMYAdmin successfully downloaded!") @@ -984,7 +964,7 @@ class preFlightsChecks: count = 0 while(1): - command = 'unzip phpMyAdmin-4.8.1-all-languages.zip' + command = 'unzip phpMyAdmin-4.8.2-all-languages.zip' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -996,9 +976,8 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile( "Unable to unzip PHPMYAdmin, exiting installer! [download_install_phpmyadmin]") - print("[" + time.strftime( - "%I-%M-%S-%a-%b-%Y") + "] " + "Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) else: logging.InstallLog.writeToFile("PHPMYAdmin unzipped!") print( @@ -1007,12 +986,12 @@ class preFlightsChecks: ### - os.remove("phpMyAdmin-4.8.1-all-languages.zip") + os.remove("phpMyAdmin-4.8.2-all-languages.zip") count = 0 while(1): - command = 'mv phpMyAdmin-4.8.1-all-languages phpmyadmin' + command = 'mv phpMyAdmin-4.8.2-all-languages phpmyadmin' cmd = shlex.split(command) @@ -1026,9 +1005,8 @@ class preFlightsChecks: if count == 3: logging.InstallLog.writeToFile( "Unable to install PHPMYAdmin, exiting installer! [download_install_phpmyadmin]") - print("[" + time.strftime( - "%I-%M-%S-%a-%b-%Y") + "] " + "Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) else: logging.InstallLog.writeToFile("PHPMYAdmin Successfully installed!") print( @@ -1303,7 +1281,7 @@ class preFlightsChecks: count = count + 1 preFlightsChecks.stdOut("Unable to generate SSL for Postfix, trying again, try number: " + str(count)) if count == 3: - logging.InstallLog.writeToFile("Unable to generate SSL for Postfix, you will not be able to send emails and rest should work fine!! [setup_postfix_davecot_config]") + logging.InstallLog.writeToFile("Unable to generate SSL for Postfix, you will not be able to send emails and rest should work fine! [setup_postfix_davecot_config]") return else: logging.InstallLog.writeToFile("SSL for Postfix generated!") @@ -1373,7 +1351,7 @@ class preFlightsChecks: count = count + 1 preFlightsChecks.stdOut("Unable to change permissions for mysql-virtual_domains.cf, trying again, try number: " + str(count)) if count == 3: - logging.InstallLog.writeToFile("Unable change permissions for mysql-virtual_domains.cf. [setup_postfix_davecot_config]") + logging.InstallLog.writeToFile("Unable to change permissions for mysql-virtual_domains.cf. [setup_postfix_davecot_config]") break else: logging.InstallLog.writeToFile("Permissions changed for mysql-virtual_domains.cf!") @@ -2157,11 +2135,8 @@ class preFlightsChecks: count = 0 while(1): - command = 'chmod +x /usr/local/lscp/bin/lscpdctrl' - cmd = shlex.split(command) - res = subprocess.call(cmd) if res == 1: @@ -2235,11 +2210,8 @@ class preFlightsChecks: try: ## first install crontab - file = open("installLogs.txt", 'a') - count = 0 - while(1): command = 'yum install cronie -y' @@ -2265,9 +2237,7 @@ class preFlightsChecks: while(1): command = 'systemctl enable crond' - cmd = shlex.split(command) - res = subprocess.call(cmd, stdout=file) if res == 1: @@ -2284,11 +2254,8 @@ class preFlightsChecks: count = 0 while(1): - command = 'systemctl start crond' - cmd = shlex.split(command) - res = subprocess.call(cmd, stdout=file) if res == 1: @@ -2312,6 +2279,12 @@ class preFlightsChecks: command = 'chmod +x /usr/local/CyberCP/plogical/findBWUsage.py' cmd = shlex.split(command) + res = subprocess.call(cmd, stdout=file) + + if res == 1: + logging.InstallLog.writeToFile("1427 [setup_cron]") + else: + pass command = 'chmod +x /usr/local/CyberCP/postfixSenderPolicy/client.py' cmd = shlex.split(command) @@ -2326,11 +2299,8 @@ class preFlightsChecks: count = 0 while(1): - command = 'systemctl restart crond.service' - cmd = shlex.split(command) - res = subprocess.call(cmd, stdout=file) if res == 1: @@ -2449,7 +2419,7 @@ class preFlightsChecks: logging.InstallLog.writeToFile( "Unable to install urllib3 module, exiting installer! [install_python_requests]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("urllib3 module Successfully installed!") preFlightsChecks.stdOut("urllib3 module Successfully installed!") @@ -2470,7 +2440,7 @@ class preFlightsChecks: logging.InstallLog.writeToFile( "Unable to install requests module, exiting installer! [install_python_requests]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("Requests module Successfully installed!") preFlightsChecks.stdOut("Requests module Successfully installed!") @@ -2513,7 +2483,7 @@ class preFlightsChecks: logging.InstallLog.writeToFile( "Failed to install pyOpenSSL, exiting installer! [installCertBot]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("pyOpenSSL successfully installed! [pip]") preFlightsChecks.stdOut("pyOpenSSL successfully installed! [pip]") @@ -2533,7 +2503,7 @@ class preFlightsChecks: logging.InstallLog.writeToFile( "Failed to install CertBot, exiting installer! [installCertBot]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("CertBot successfully installed! [pip]") preFlightsChecks.stdOut("CertBot successfully installed! [pip]") @@ -2739,7 +2709,7 @@ milter_default_action = accept logging.InstallLog.writeToFile( "Failed to install project dependant modules! [setupVirtualEnv]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("Project dependant modules installed successfully!") preFlightsChecks.stdOut("Project dependant modules installed successfully!!") @@ -2761,7 +2731,7 @@ milter_default_action = accept logging.InstallLog.writeToFile( "Failed install virtualenv! [setupVirtualEnv]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("virtualenv installed successfully!") preFlightsChecks.stdOut("virtualenv installed successfully!") @@ -2771,7 +2741,7 @@ milter_default_action = accept count = 0 while (1): - command = "virtualenv /usr/local/CyberCP" + command = "virtualenv --system-site-packages /usr/local/CyberCP" res = subprocess.call(shlex.split(command)) if res == 1: @@ -2782,7 +2752,7 @@ milter_default_action = accept logging.InstallLog.writeToFile( "Failed to setup virtualenv! [setupVirtualEnv]") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("virtualenv setuped successfully!") preFlightsChecks.stdOut("virtualenv setuped successfully!") @@ -2799,7 +2769,7 @@ milter_default_action = accept count = 0 while (1): - command = "pip install -r /usr/local/CyberCP/requirments.txt" + command = "pip install --ignore-installed -r /usr/local/CyberCP/requirments.txt" res = subprocess.call(shlex.split(command)) if res == 1: @@ -2809,8 +2779,7 @@ milter_default_action = accept if count == 3: logging.InstallLog.writeToFile( "Failed to install project dependant modules! [setupVirtualEnv]") - preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + break else: logging.InstallLog.writeToFile("Project dependant modules installed successfully!") preFlightsChecks.stdOut("Project dependant modules installed successfully!!") @@ -2819,6 +2788,9 @@ milter_default_action = accept command = "systemctl restart gunicorn.socket" res = subprocess.call(shlex.split(command)) + command = "virtualenv --system-site-packages /usr/local/CyberCP" + res = subprocess.call(shlex.split(command)) + except OSError, msg: diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 7877ec4cf..cbb45a334 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -44,7 +44,7 @@ class InstallCyberPanel: if count == 3: logging.InstallLog.writeToFile("Failed to install OpenLiteSpeed, exiting installer! [installLiteSpeed]") InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") - sys.exit() + os._exit(0) else: logging.InstallLog.writeToFile("OpenLiteSpeed successfully installed!") InstallCyberPanel.stdOut("OpenLiteSpeed successfully installed!") @@ -98,7 +98,7 @@ class InstallCyberPanel: ## cache module settings cacheStart = "module cache {\n" - param = " param <<
-

{% trans "DKIM Manager" %}

+

{% trans "DKIM Manager" %} - {% trans "DKIM Docs" %}

{% trans "This page can be used to generate and view DKIM keys for Domains" %}

diff --git a/mailServer/templates/mailServer/emailForwarding.html b/mailServer/templates/mailServer/emailForwarding.html index 9d350f4cd..cb0c1bceb 100644 --- a/mailServer/templates/mailServer/emailForwarding.html +++ b/mailServer/templates/mailServer/emailForwarding.html @@ -9,7 +9,7 @@
-

{% trans "Setup Email Forwarding" %}

+

{% trans "Setup Email Forwarding" %} - {% trans "Forwarding Docs" %}

{% trans "This page help you setup email forwarding for your emails." %}

diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index 6ae701a1f..c03dc2106 100644 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -31,7 +31,7 @@ from backup.models import DBUsers from mailServer.models import Domains as eDomains from random import randint import time - +from plogical.mailUtilities import mailUtilities ## I am not the monster that you think I am.. @@ -614,21 +614,9 @@ class backupUtilities: username = email.split("@")[0] password = emailAccount.find('password').text - - finalData = json.dumps({'domain': masterDomain, 'username': username, 'password': password}) - - r = requests.post("http://localhost:5003/email/submitEmailCreation", data=finalData,verify=False) - - data = json.loads(r.text) - - if data['createEmailStatus'] == 1: - continue - else: - status = open(os.path.join(completPath,'status'), "w") - status.write("Error Message: " + data[ - 'error_message'] + ". Not able to create email accounts, aborting. [5009]") - status.close() - return 0 + result = mailUtilities.createEmailAccount(masterDomain, username, password) + if result[0] == 0: + raise BaseException(result[1]) except BaseException, msg: status = open(os.path.join(completPath,'status'), "w") diff --git a/plogical/vhost.py b/plogical/vhost.py index e120f88c7..1c248fda7 100644 --- a/plogical/vhost.py +++ b/plogical/vhost.py @@ -309,7 +309,6 @@ class vhost: ## File Manager defination context = "context /.filemanager {\n" - type = " type NULL\n" location = " location /usr/local/lsws/Example/html/FileManager\n" allowBrowse = " allowBrowse 1\n" autoIndex = " autoIndex 1\n\n" @@ -319,8 +318,17 @@ class vhost: deny = " deny 0.0.0.0/0\n" accessControlEnds = " }\n" + rewriteInherit = """ rewrite { + inherit 0 + + } + """ + phpIniOverride = "phpIniOverride {\n" php_admin_value = 'php_admin_value open_basedir "/tmp:/usr/local/lsws/Example/html/FileManager:$VH_ROOT"\n' + php_value = 'php_value display_errors "Off"\n' + php_value_upload_max_size = 'php_value upload_max_filesize "200M"\n' + php_value_post_max_size = 'php_value post_max_size "250M"\n' endPHPIniOverride = "}\n" @@ -328,7 +336,6 @@ class vhost: contextEnds = "}\n" confFile.writelines(context) - confFile.writelines(type) confFile.writelines(location) confFile.writelines(allowBrowse) confFile.writelines(autoIndex) @@ -336,10 +343,16 @@ class vhost: confFile.writelines(allow) confFile.writelines(deny) confFile.writelines(accessControlEnds) + confFile.write(rewriteInherit) + + confFile.writelines(phpIniOverride) if openBasedir == 1: - confFile.writelines(phpIniOverride) confFile.writelines(php_admin_value) - confFile.writelines(endPHPIniOverride) + confFile.write(php_value) + confFile.write(php_value_upload_max_size) + confFile.write(php_value_post_max_size) + confFile.writelines(endPHPIniOverride) + confFile.writelines(defaultCharSet) confFile.writelines(contextEnds) @@ -349,10 +362,26 @@ class vhost: php_admin_value = 'php_admin_value open_basedir "/tmp:$VH_ROOT"\n' endPHPIniOverride = "}\n" + confFile.writelines(phpIniOverride) if openBasedir == 1: - confFile.writelines(phpIniOverride) confFile.writelines(php_admin_value) - confFile.writelines(endPHPIniOverride) + confFile.writelines(endPHPIniOverride) + + + slashContext = """ +context / { + location $DOC_ROOT/ + allowBrowse 1 + + rewrite { + enable 1 +RewriteFile .htaccess + + } + addDefaultCharset off +} +""" + confFile.write(slashContext) confFile.close() @@ -584,40 +613,7 @@ class vhost: def addRewriteRules(virtualHostName, fileName=None): try: - path = vhost.Server_root + "/conf/vhosts/" + virtualHostName + "/vhost.conf" - - data = open(path, "r").readlines() - - if fileName == None: - dataToWritten = "rewriteFile /home/" + virtualHostName + "/public_html/.htaccess" + "\n" - else: - dataToWritten = "rewriteFile " + fileName + "\n" - - ### Data if re-writes are not already enabled - - rewrite = "rewrite {\n" - enables = " enable 1\n" - rules = " rules << -1: - skip = 1 - - if skip == 1 and items.find('}') > -1: - skip = 0 + if items.find('php_admin_value') > -1: continue - - if skip == 1: - continue - writeToFile.writelines(items) writeToFile.close() else: ## Check if phpini already active - inistatus = 0 + fileManagerCheck = 0 + + writeToFile = open(completePathToConfigFile, 'w') for items in data: + + if items.find('context /.filemanager') > -1: + writeToFile.writelines(items) + fileManagerCheck = 1 + continue + if items.find('phpIniOverride') > -1: - inistatus = 1 - - if inistatus == 0: - writeToFile = open(completePathToConfigFile, 'w') - for items in data: - if items.find('context /.filemanager') > -1: - writeToFile.writelines(items) - phpIniOverride = "phpIniOverride {\n" - php_admin_value = 'php_admin_value open_basedir "/tmp:/usr/local/lsws/Example/html/FileManager:$VH_ROOT"\n' - endPHPIniOverride = "}\n" - writeToFile.writelines(phpIniOverride) - writeToFile.writelines(php_admin_value) - writeToFile.writelines(endPHPIniOverride) + writeToFile.writelines(items) + if fileManagerCheck == 1: + writeToFile.writelines('php_admin_value open_basedir "/tmp:/usr/local/lsws/Example/html/FileManager:$VH_ROOT"\n') + fileManagerCheck = 0 + continue else: - writeToFile.writelines(items) + writeToFile.writelines('php_admin_value open_basedir "/tmp:$VH_ROOT"\n') + continue - phpIniOverride = "\nphpIniOverride {\n" - php_admin_value = 'php_admin_value open_basedir "/tmp:$VH_ROOT"\n' - endPHPIniOverride = "}\n" + writeToFile.writelines(items) - writeToFile.writelines(phpIniOverride) - writeToFile.writelines(php_admin_value) - writeToFile.writelines(endPHPIniOverride) + writeToFile.close() - writeToFile.close() installUtilities.installUtilities.reStartLiteSpeed() print "1,None" diff --git a/postfixSenderPolicy/accept_traffic.py b/postfixSenderPolicy/accept_traffic.py index 96cd5f4ee..a6e0a96da 100755 --- a/postfixSenderPolicy/accept_traffic.py +++ b/postfixSenderPolicy/accept_traffic.py @@ -7,7 +7,7 @@ django.setup() import threading as multi from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging from policyConstraint import policyConstraints -from emailPremium.models import DomainLimits, EmailLimits, EmailLogs +from emailPremium.models import DomainLimits, EmailLogs from mailServer.models import Domains, EUsers import time from cacheManager import cacheManager @@ -20,37 +20,44 @@ class HandleRequest(multi.Thread): multi.Thread.__init__(self) self.connection = conn + def __del__(self): + try: + self.connection.close() + except BaseException, msg: + logging.writeToFile(str(msg) + ' [HandleRequest.__del__]') + def run(self): limitThreads.acquire() dataComplete = "" + try: - try: - while True: - # Wait for a connection - if os.path.exists(HandleRequest.cleaningPath): - readFromFile = open(HandleRequest.cleaningPath, 'r') - command = readFromFile.read() - cacheManager.handlePurgeRequest(command) - readFromFile.close() - logging.writeToFile(command + 'nCommand') - os.remove(HandleRequest.cleaningPath) + while True: - Data = self.connection.recv(64) - if Data: - if len(Data) < 64: - dataComplete = dataComplete + Data - self.manageRequest(dataComplete) - dataComplete = '' - else: - dataComplete = dataComplete + Data + Data = self.connection.recv(64) + + # Wait for a connection + if os.path.exists(HandleRequest.cleaningPath): + readFromFile = open(HandleRequest.cleaningPath, 'r') + command = readFromFile.read() + cacheManager.handlePurgeRequest(command) + readFromFile.close() + os.remove(HandleRequest.cleaningPath) + cacheManager.flushCache() + + if Data: + if len(Data) < 64: + dataComplete = dataComplete + Data + self.manageRequest(dataComplete) + dataComplete = '' else: - self.connection.close() - break - finally: - # Clean up the connection - self.connection.close() + dataComplete = dataComplete + Data + else: + self.connection.close() + break - finally: + limitThreads.release() + except BaseException, msg: + logging.writeToFile(str(msg) + ' [HandleRequest.run]') limitThreads.release() def manageRequest(self, completeData): @@ -69,14 +76,17 @@ class HandleRequest(multi.Thread): domainObj = cacheManager.domains[domainName] emailObj = domainObj.findEmailOBJ(emailAddress) else: - domain = Domains.objects.get(domain=domainName) - domainLTS = DomainLimits.objects.get(domain=domain) + try: + domain = Domains.objects.get(domain=domainName) + domainLTS = DomainLimits.objects.get(domain=domain) - newDomain = policyConstraints(domainName, domainLTS.monthlyLimit, domainLTS.monthlyUsed, domainLTS.limitStatus) - cacheManager.domains[domainName] = newDomain - domainObj = newDomain + newDomain = policyConstraints(domainName, domainLTS.monthlyLimit, domainLTS.monthlyUsed, domainLTS.limitStatus) + cacheManager.domains[domainName] = newDomain + domainObj = newDomain - emailObj = newDomain.findEmailOBJ(emailAddress) + emailObj = newDomain.findEmailOBJ(emailAddress) + except: + raise BaseException #logging.writeToFile('Domain Limit Status: ' + str(domainObj.limitStatus)) #logging.writeToFile('Email Limit Status: ' + str(domainObj.limitStatus)) @@ -84,7 +94,7 @@ class HandleRequest(multi.Thread): #logging.writeToFile('Email Monthly Used: ' + str(emailObj.monthlyUsed)) if domainObj.limitStatus == 1 and emailObj.limitStatus == 1: - if domainObj.monthlyLimits <= domainObj.monthlyLimits or emailObj.monthlyLimits <= emailObj.monthlyUsed or emailObj.hourlyLimits <= emailObj.hourlyUsed: + if domainObj.monthlyLimits <= domainObj.monthlyUsed or emailObj.monthlyLimits <= emailObj.monthlyUsed or emailObj.hourlyLimits <= emailObj.hourlyUsed: logging.writeToFile(emailAddress + ' either exceeded monthly or hourly sending limit.') self.connection.sendall('action=defer_if_permit Service temporarily unavailable\n\n') else: @@ -108,6 +118,6 @@ class HandleRequest(multi.Thread): except BaseException, msg: - logging.writeToFile(completeData) self.connection.sendall('action=dunno\n\n') + limitThreads.release() logging.writeToFile(str(msg)) diff --git a/postfixSenderPolicy/policyCTRL.py b/postfixSenderPolicy/policyCTRL.py index e778adcb2..4401d8b02 100755 --- a/postfixSenderPolicy/policyCTRL.py +++ b/postfixSenderPolicy/policyCTRL.py @@ -38,15 +38,6 @@ class policyCTRL: except BaseException, msg: logging.writeToFile(str(msg)) - ## Cleaning PID - path = policyCTRL.cleaningPID - if os.path.exists(path): - pid = open(path, "r").readlines()[0] - try: - os.kill(int(pid), signal.SIGTERM) - except BaseException, msg: - logging.writeToFile(str(msg)) - def main(): diff --git a/requirments.txt b/requirments.txt index 242796b8e..cacd75630 100644 --- a/requirments.txt +++ b/requirments.txt @@ -26,7 +26,6 @@ jsonpointer==1.9 kitchen==1.1.1 MarkupSafe==0.11 mock==2.0.0 -MySQL-python==1.2.5 parsedatetime==2.4 pbr==4.0.4 perf==0.1 diff --git a/websiteFunctions/templates/websiteFunctions/listCron.html b/websiteFunctions/templates/websiteFunctions/listCron.html index 452926467..44e9a1fd2 100644 --- a/websiteFunctions/templates/websiteFunctions/listCron.html +++ b/websiteFunctions/templates/websiteFunctions/listCron.html @@ -9,7 +9,7 @@
-

{% trans "Cron Management" %}

+

{% trans "Cron Management" %} - {% trans "Cron Docs" %}

{% trans "Create, edit or delete your cron jobs from this page." %}

diff --git a/websiteFunctions/templates/websiteFunctions/website.html b/websiteFunctions/templates/websiteFunctions/website.html index 9328ce770..1ad48373a 100644 --- a/websiteFunctions/templates/websiteFunctions/website.html +++ b/websiteFunctions/templates/websiteFunctions/website.html @@ -690,7 +690,7 @@
-

{% trans "Current rewrite rules in the file fetched." %}

+

{% trans "Current rewrite rules in the file fetched." %} Click to read more about whats changed in rewrite rules from v1.7 onwards.