From 1c0a1914281c14203ea3a443c52cc71611d63f4a Mon Sep 17 00:00:00 2001 From: usmannasir <01-134132-158@student.bahria.edu.pk> Date: Wed, 14 Nov 2018 18:36:56 +0500 Subject: [PATCH] ssl_dh for ubuntu 18.10 --- install/install.py | 42 ++++++++++++++++++++++++++++------ install/installCyberPanel.py | 44 +----------------------------------- managePHP/views.py | 11 +++------ plogical/phpUtilities.py | 35 ++++++++++++++-------------- plogical/website.py | 7 ++++-- 5 files changed, 62 insertions(+), 77 deletions(-) diff --git a/install/install.py b/install/install.py index 71e9ce511..06595296e 100644 --- a/install/install.py +++ b/install/install.py @@ -1006,7 +1006,6 @@ class preFlightsChecks: preFlightsChecks.stdOut("Owner for '/usr/local/CyberCP' successfully changed!") break - def install_unzip(self): self.stdOut("Install zip") try: @@ -2076,6 +2075,21 @@ class preFlightsChecks: command = "sed -i 's/auth_mechanisms = plain/#auth_mechanisms = plain/g' /etc/dovecot/conf.d/10-auth.conf" subprocess.call(shlex.split(command)) + ## Ubuntu 18.10 ssl_dh for dovecot 2.3.2.1 + + if get_Ubuntu_release() == 18.10: + dovecotConf = '/etc/dovecot/dovecot.conf' + + data = open(dovecotConf, 'r').readlines() + writeToFile = open(dovecotConf, 'w') + for items in data: + if items.find('ssl_key = -1: + writeToFile.writelines(items) + writeToFile.writelines('ssl_dh = -1 and items.find('local:') and items[0] != '#': + writeToFile.writelines('Socket inet:8891@localhost\n') + else: + writeToFile.writelines(items) + writeToFile.close() + #### Restarting Postfix and OpenDKIM diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 4de145881..e45a2ae1a 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -307,7 +307,6 @@ class InstallCyberPanel: count = 0 while (1): - if self.distro == ubuntu: command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install ' \ 'lsphp7? lsphp7?-common lsphp7?-curl lsphp7?-dev lsphp7?-imap lsphp7?-intl lsphp7?-json ' \ @@ -315,7 +314,7 @@ class InstallCyberPanel: 'lsphp7?-sqlite3 lsphp7?-tidy' res = os.system(command) else: - command = 'yum -y groupinstall lsphp-all' + command = 'yum -y install lsphp*' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -332,47 +331,6 @@ class InstallCyberPanel: logging.InstallLog.writeToFile("LiteSpeed PHPs successfully installed!") InstallCyberPanel.stdOut("LiteSpeed PHPs successfully installed!") - ## only php 71 - if self.distro == centos: - count = 0 - while (1): - command = 'yum install lsphp71 lsphp71-json lsphp71-xmlrpc lsphp71-xml lsphp71-tidy lsphp71-soap lsphp71-snmp lsphp71-recode lsphp71-pspell lsphp71-process lsphp71-pgsql lsphp71-pear lsphp71-pdo lsphp71-opcache lsphp71-odbc lsphp71-mysqlnd lsphp71-mcrypt lsphp71-mbstring lsphp71-ldap lsphp71-intl lsphp71-imap lsphp71-gmp lsphp71-gd lsphp71-enchant lsphp71-dba lsphp71-common lsphp71-bcmath -y' - cmd = shlex.split(command) - res = subprocess.call(cmd) - if res == 1: - count = count + 1 - InstallCyberPanel.stdOut( - "Trying to install LiteSpeed PHP 7.1, trying again, try number: " + str(count)) - if count == 3: - logging.InstallLog.writeToFile( - "Failed to install LiteSpeed PHP 7.1, exiting installer! [installAllPHPVersions]") - InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("LiteSpeed PHP 7.1 successfully installed!") - InstallCyberPanel.stdOut("LiteSpeed PHP 7.1 successfully installed!") - break - - ## only php 72 - count = 0 - while (1): - command = 'yum install -y lsphp72 lsphp72-json lsphp72-xmlrpc lsphp72-xml lsphp72-tidy lsphp72-soap lsphp72-snmp lsphp72-recode lsphp72-pspell lsphp72-process lsphp72-pgsql lsphp72-pear lsphp72-pdo lsphp72-opcache lsphp72-odbc lsphp72-mysqlnd lsphp72-mcrypt lsphp72-mbstring lsphp72-ldap lsphp72-intl lsphp72-imap lsphp72-gmp lsphp72-gd lsphp72-enchant lsphp72-dba lsphp72-common lsphp72-bcmath' - cmd = shlex.split(command) - res = subprocess.call(cmd) - if res == 1: - count = count + 1 - InstallCyberPanel.stdOut( - "Trying to install LiteSpeed PHP 7.1, trying again, try number: " + str(count)) - if count == 3: - logging.InstallLog.writeToFile( - "Failed to install LiteSpeed PHP 7.1, exiting installer! [installAllPHPVersions]") - InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("LiteSpeed PHP 7.1 successfully installed!") - InstallCyberPanel.stdOut("LiteSpeed PHP 7.1 successfully installed!") - break - ## break for outer loop break diff --git a/managePHP/views.py b/managePHP/views.py index c6ed79d2e..15426b014 100644 --- a/managePHP/views.py +++ b/managePHP/views.py @@ -1355,14 +1355,9 @@ def getRequestStatus(request): return HttpResponse(final_json) elif requestStatus.find("PHP Extension Removed") > -1: - if subprocess.check_output(checkCommand).find(extensionName) > -1: - ext = installedPackages.objects.get(extensionName=extensionName) - ext.status = 1 - ext.save() - else: - ext = installedPackages.objects.get(extensionName=extensionName) - ext.status = 0 - ext.save() + ext = installedPackages.objects.get(extensionName=extensionName) + ext.status = 0 + ext.save() installUtilities.reStartLiteSpeed() final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1, diff --git a/plogical/phpUtilities.py b/plogical/phpUtilities.py index d281eb7f1..86560ac2b 100644 --- a/plogical/phpUtilities.py +++ b/plogical/phpUtilities.py @@ -25,21 +25,21 @@ class phpUtilities: cmd = shlex.split(command) - with open(phpUtilities.installLogPath, 'w') as f: - res = subprocess.call(cmd, stdout=f) + try: + with open(phpUtilities.installLogPath, 'w') as f: + subprocess.call(cmd, stdout=f) - if res == 1: + writeToFile = open(phpUtilities.installLogPath, 'a') + writeToFile.writelines("PHP Extension Installed.\n") + writeToFile.close() + + return 1 + except: writeToFile = open(phpUtilities.installLogPath, 'a') writeToFile.writelines("Can not be installed.\n") writeToFile.close() logging.CyberCPLogFileWriter.writeToFile("[Could not Install]") return 0 - else: - writeToFile = open(phpUtilities.installLogPath, 'a') - writeToFile.writelines("PHP Extension Installed.\n") - writeToFile.close() - - return 1 except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installPHPExtension]") @@ -56,21 +56,22 @@ class phpUtilities: cmd = shlex.split(command) - with open(phpUtilities.installLogPath, 'w') as f: - res = subprocess.call(cmd, stdout=f) + try: - if res == 1: + with open(phpUtilities.installLogPath, 'w') as f: + subprocess.call(cmd, stdout=f) + + writeToFile = open(phpUtilities.installLogPath, 'a') + writeToFile.writelines("PHP Extension Removed.\n") + writeToFile.close() + return 1 + except: writeToFile = open(phpUtilities.installLogPath, 'a') writeToFile.writelines("Can not un-install Extension.\n") writeToFile.close() logging.CyberCPLogFileWriter.writeToFile("[Could not Install]") return 0 - else: - writeToFile = open(phpUtilities.installLogPath, 'a') - writeToFile.writelines("PHP Extension Removed.\n") - writeToFile.close() - return 1 except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[unInstallPHPExtension]") diff --git a/plogical/website.py b/plogical/website.py index 7c936298c..3af406d97 100644 --- a/plogical/website.py +++ b/plogical/website.py @@ -987,7 +987,11 @@ class WebsiteManager: json_data = json.dumps(dic) return HttpResponse(json_data) - cronPath = "/var/spool/cron/" + website.externalApp + if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + cronPath = "/var/spool/cron/" + website.externalApp + else: + cronPath = "/var/spool/cron/crontabs/" + website.externalApp + cmd = 'sudo test -e ' + cronPath + ' && echo Exists' output = os.popen(cmd).read() @@ -996,7 +1000,6 @@ class WebsiteManager: final_json = json.dumps(data_ret) return HttpResponse(final_json) - cronPath = "/var/spool/cron/" + website.externalApp crons = [] try: