bug fix to csf

This commit is contained in:
usmannasir
2018-12-20 16:18:16 +05:00
parent 232fd21298
commit db15dc03ed
10 changed files with 116 additions and 97 deletions

View File

@@ -1452,7 +1452,7 @@ class FirewallManager:
else: else:
return ACLManager.loadErrorJson('installStatus', 0) return ACLManager.loadErrorJson('installStatus', 0)
execPath = "sudo " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
execPath = execPath + " installCSF" execPath = execPath + " installCSF"
subprocess.Popen(shlex.split(execPath)) subprocess.Popen(shlex.split(execPath))
@@ -1520,7 +1520,7 @@ class FirewallManager:
else: else:
return ACLManager.loadErrorJson('installStatus', 0) return ACLManager.loadErrorJson('installStatus', 0)
execPath = "sudo " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
execPath = execPath + " removeCSF" execPath = execPath + " removeCSF"
subprocess.Popen(shlex.split(execPath)) subprocess.Popen(shlex.split(execPath))
@@ -1579,7 +1579,7 @@ class FirewallManager:
controller = data['controller'] controller = data['controller']
status = data['status'] status = data['status']
execPath = "sudo " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
execPath = execPath + " changeStatus --controller " + controller + " --status " + status execPath = execPath + " changeStatus --controller " + controller + " --status " + status
output = subprocess.check_output(shlex.split(execPath)) output = subprocess.check_output(shlex.split(execPath))
@@ -1613,7 +1613,7 @@ class FirewallManager:
protocol = data['protocol'] protocol = data['protocol']
ports = data['ports'] ports = data['ports']
execPath = "sudo " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
execPath = execPath + " modifyPorts --protocol " + protocol + " --ports " + ports execPath = execPath + " modifyPorts --protocol " + protocol + " --ports " + ports
output = subprocess.check_output(shlex.split(execPath)) output = subprocess.check_output(shlex.split(execPath))

View File

@@ -770,7 +770,7 @@ class preFlightsChecks:
if subprocess.check_output('systemd-detect-virt').find("openvz") > -1: if subprocess.check_output('systemd-detect-virt').find("openvz") > -1:
command = "pip install --upgrade requests" command = "pip install --upgrade requests"
install.preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]', preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'Upgrade requests', 'Upgrade requests',
1, 0, os.EX_OSERR) 1, 0, os.EX_OSERR)
except: except:
@@ -780,17 +780,18 @@ class preFlightsChecks:
os.chdir(self.path) os.chdir(self.path)
#command = "wget http://cyberpanel.net/CyberPanel.1.7.5.tar.gz" command = "wget http://cyberpanel.sh/CyberPanel.1.7.5.tar.gz"
command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz" #command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz"
install.preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]', preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'CyberPanel Download', 'CyberPanel Download',
1, 1, os.EX_OSERR) 1, 1, os.EX_OSERR)
## ##
count = 0 count = 0
command = "tar zxf CyberPanelTemp.tar.gz" command = "tar zxf CyberPanel.1.7.5.tar.gz"
install.preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]', #command = "tar zxf CyberPanelTemp.tar.gz"
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'Extract CyberPanel',1, 1, os.EX_OSERR) 'Extract CyberPanel',1, 1, os.EX_OSERR)
### update password: ### update password:
@@ -852,33 +853,33 @@ class preFlightsChecks:
os.chdir("CyberCP") os.chdir("CyberCP")
command = "python manage.py makemigrations" command = "python manage.py makemigrations"
install.preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]', preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'CyberPanel Make Migrations', 'CyberPanel Make Migrations',
1, 1, os.EX_OSERR) 1, 1, os.EX_OSERR)
## ##
command = "python manage.py migrate" command = "python manage.py migrate"
install.preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]', preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'CyberPanel Migrate',1, 1, os.EX_OSERR) 'CyberPanel Migrate',1, 1, os.EX_OSERR)
## Moving static content to lscpd location ## Moving static content to lscpd location
command = 'mv static /usr/local/lscp/cyberpanel' command = 'mv static /usr/local/lscp/cyberpanel'
install.preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]', preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'Move static content', 1, 1, os.EX_OSERR) 'Move static content', 1, 1, os.EX_OSERR)
## fix permissions ## fix permissions
command = "chmod -R 744 /usr/local/CyberCP" command = "chmod -R 744 /usr/local/CyberCP"
install.preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]', preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'change permissions /usr/local/CyberCP', 1, 0, os.EX_OSERR) 'change permissions /usr/local/CyberCP', 1, 0, os.EX_OSERR)
## change owner ## change owner
command = "chown -R cyberpanel:cyberpanel /usr/local/CyberCP" command = "chown -R cyberpanel:cyberpanel /usr/local/CyberCP"
install.preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]', preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'change owner /usr/local/CyberCP', 1, 0, os.EX_OSERR) 'change owner /usr/local/CyberCP', 1, 0, os.EX_OSERR)
@@ -890,7 +891,7 @@ class preFlightsChecks:
else: else:
command = 'apt-get -y install unzip' command = 'apt-get -y install unzip'
install.preFlightsChecks.call(command, self.distro, '[install_unzip]', preFlightsChecks.call(command, self.distro, '[install_unzip]',
'Install unzip', 1, 0, os.EX_OSERR) 'Install unzip', 1, 0, os.EX_OSERR)
except BaseException, msg: except BaseException, msg:
logging.InstallLog.writeToFile(str(msg) + " [install_unzip]") logging.InstallLog.writeToFile(str(msg) + " [install_unzip]")
@@ -903,7 +904,7 @@ class preFlightsChecks:
else: else:
command = 'apt-get -y install zip' command = 'apt-get -y install zip'
install.preFlightsChecks.call(command, self.distro, '[install_zip]', preFlightsChecks.call(command, self.distro, '[install_zip]',
'Install zip', 1, 0, os.EX_OSERR) 'Install zip', 1, 0, os.EX_OSERR)
except BaseException, msg: except BaseException, msg:
logging.InstallLog.writeToFile(str(msg) + " [install_zip]") logging.InstallLog.writeToFile(str(msg) + " [install_zip]")
@@ -913,12 +914,12 @@ class preFlightsChecks:
os.chdir("/usr/local/lscp/cyberpanel/") os.chdir("/usr/local/lscp/cyberpanel/")
command = 'wget https://files.phpmyadmin.net/phpMyAdmin/4.8.2/phpMyAdmin-4.8.2-all-languages.zip' command = 'wget https://files.phpmyadmin.net/phpMyAdmin/4.8.2/phpMyAdmin-4.8.2-all-languages.zip'
install.preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]', preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]',
'Download PHPMYAdmin', 1, 0, os.EX_OSERR) 'Download PHPMYAdmin', 1, 0, os.EX_OSERR)
##### #####
command = 'unzip phpMyAdmin-4.8.2-all-languages.zip' command = 'unzip phpMyAdmin-4.8.2-all-languages.zip'
install.preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]', preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]',
'Unzip PHPMYAdmin', 1, 0, os.EX_OSERR) 'Unzip PHPMYAdmin', 1, 0, os.EX_OSERR)
@@ -927,7 +928,7 @@ class preFlightsChecks:
os.remove("phpMyAdmin-4.8.2-all-languages.zip") os.remove("phpMyAdmin-4.8.2-all-languages.zip")
command = 'mv phpMyAdmin-4.8.2-all-languages phpmyadmin' command = 'mv phpMyAdmin-4.8.2-all-languages phpmyadmin'
install.preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]', preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]',
'Move PHPMYAdmin', 1, 0, os.EX_OSERR) 'Move PHPMYAdmin', 1, 0, os.EX_OSERR)
## Write secret phrase ## Write secret phrase
@@ -2128,80 +2129,43 @@ class preFlightsChecks:
try: try:
preFlightsChecks.stdOut("Enabling Firewall!") preFlightsChecks.stdOut("Enabling Firewall!")
count = 0
while (1):
if self.distro == ubuntu: if self.distro == ubuntu:
command = 'apt-get -y install firewalld' command = 'apt-get -y install firewalld'
else: else:
command = 'yum -y install firewalld' command = 'yum -y install firewalld'
cmd = shlex.split(command)
res = subprocess.call(cmd)
if preFlightsChecks.resFailed(self.distro, res): preFlightsChecks.call(command, self.distro, '[installFirewalld]',
count = count + 1 'Install FirewallD',
preFlightsChecks.stdOut("Unable to install FirewallD, trying again, try number: " + str(count)) 1, 0, os.EX_OSERR)
if count == 3:
logging.InstallLog.writeToFile(
"Unable to install FirewallD, funtions related to Firewall will not work! [installFirewalld]")
break
else:
logging.InstallLog.writeToFile("FirewallD successfully installed!")
preFlightsChecks.stdOut("FirewallD successfully installed!")
break
###### ######
if self.distro == centos: if self.distro == centos:
# Not available in ubuntu # Not available in ubuntu
command = 'systemctl restart dbus' command = 'systemctl restart dbus'
cmd = shlex.split(command) preFlightsChecks.call(command, self.distro, '[installFirewalld]',
subprocess.call(cmd) 'Start dbus',
1, 0, os.EX_OSERR)
command = 'systemctl restart systemd-logind' command = 'systemctl restart systemd-logind'
cmd = shlex.split(command) preFlightsChecks.call(command, self.distro, '[installFirewalld]',
subprocess.call(cmd) 'restart logind',
1, 0, os.EX_OSERR)
count = 0
while (1):
command = 'systemctl start firewalld' command = 'systemctl start firewalld'
cmd = shlex.split(command) preFlightsChecks.call(command, self.distro, '[installFirewalld]',
res = subprocess.call(cmd) 'Restart FirewallD',
1, 0, os.EX_OSERR)
if preFlightsChecks.resFailed(self.distro, res):
count = count + 1
preFlightsChecks.stdOut("Unable to start FirewallD, trying again, try number: " + str(count))
if count == 3:
logging.InstallLog.writeToFile(
"Unable to start FirewallD, you can manually start it later using systemctl start firewalld! [installFirewalld]")
break
else:
logging.InstallLog.writeToFile("FirewallD successfully started!")
preFlightsChecks.stdOut("FirewallD successfully started!")
break
########## ##########
count = 0
while (1):
command = 'systemctl enable firewalld' command = 'systemctl enable firewalld'
cmd = shlex.split(command) preFlightsChecks.call(command, self.distro, '[installFirewalld]',
res = subprocess.call(cmd) 'Install FirewallD',
1, 0, os.EX_OSERR)
if preFlightsChecks.resFailed(self.distro, res):
count = count + 1
preFlightsChecks.stdOut(
"Trying to enable FirewallD at system startup, trying again, try number: " + str(count))
if count == 3:
logging.InstallLog.writeToFile(
"FirewallD may not start after restart, you need to manually run systemctl enable firewalld ! [installFirewalld]")
break
else:
logging.InstallLog.writeToFile("FirewallD successfully enabled on system startup!")
preFlightsChecks.stdOut("FirewallD successfully enabled on system startup!")
break
FirewallUtilities.addRule("tcp", "8090") FirewallUtilities.addRule("tcp", "8090")
FirewallUtilities.addRule("tcp", "80") FirewallUtilities.addRule("tcp", "80")

View File

@@ -609,6 +609,8 @@ class InstallCyberPanel:
if self.distro == ubuntu: if self.distro == ubuntu:
command = "DEBIAN_FRONTEND=noninteractive apt-get -y install pdns-server pdns-backend-mysql" command = "DEBIAN_FRONTEND=noninteractive apt-get -y install pdns-server pdns-backend-mysql"
os.system(command)
return 1
else: else:
command = 'yum -y install pdns pdns-backend-mysql' command = 'yum -y install pdns pdns-backend-mysql'

View File

@@ -175,7 +175,7 @@ class CSF(multi.Thread):
return currentSettings return currentSettings
except BaseException, msg: except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchCSFSettings]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [fetchCSFSettings]")
@staticmethod @staticmethod
def changeStatus(controller, status): def changeStatus(controller, status):

View File

@@ -21,6 +21,7 @@ class mysqlUtilities:
f = open(passFile) f = open(passFile)
data = f.read() data = f.read()
password = data.split('\n', 1)[0] password = data.split('\n', 1)[0]
password = password.strip('\n').strip('\r')
conn = mysql.connect(user='root', passwd=password) conn = mysql.connect(user='root', passwd=password)
cursor = conn.cursor() cursor = conn.cursor()

View File

@@ -13,6 +13,7 @@ import json
import time import time
from baseTemplate.models import version from baseTemplate.models import version
import MySQLdb as mysql import MySQLdb as mysql
from CyberCP import settings
class Upgrade: class Upgrade:
logPath = "/usr/local/lscp/logs/upgradeLog" logPath = "/usr/local/lscp/logs/upgradeLog"
@@ -217,7 +218,15 @@ WantedBy=multi-user.target"""
try: try:
conn = mysql.connect(db=db, user='root', passwd=password) conn = mysql.connect(db=db, user='root', passwd=password)
except: except:
try:
conn = mysql.connect(host = '127.0.0.1', port = 3307 , db=db, user='root', passwd=password) conn = mysql.connect(host = '127.0.0.1', port = 3307 , db=db, user='root', passwd=password)
except:
dbUser = settings.DATABASES['default']['USER']
password = settings.DATABASES['default']['PASSWORD']
host = settings.DATABASES['default']['HOST']
port = settings.DATABASES['default']['PORT']
conn = mysql.connect(host=host, port=port, db=db, user=dbUser, passwd=password)
cursor = conn.cursor() cursor = conn.cursor()
return conn, cursor return conn, cursor
@@ -291,7 +300,10 @@ WantedBy=multi-user.target"""
except: except:
pass pass
try:
connection.close() connection.close()
except:
pass
except OSError, msg: except OSError, msg:
Upgrade.stdOut(str(msg) + " [applyLoginSystemMigrations]") Upgrade.stdOut(str(msg) + " [applyLoginSystemMigrations]")
@@ -352,7 +364,10 @@ WantedBy=multi-user.target"""
except: except:
pass pass
try:
connection.close() connection.close()
except:
pass
except OSError, msg: except OSError, msg:
Upgrade.stdOut(str(msg) + " [applyLoginSystemMigrations]") Upgrade.stdOut(str(msg) + " [applyLoginSystemMigrations]")
@@ -414,9 +429,12 @@ WantedBy=multi-user.target"""
except: except:
pass pass
try:
connection.close() connection.close()
except: except:
pass pass
except:
pass
@staticmethod @staticmethod
def emailMarketingMigrationsa(): def emailMarketingMigrationsa():
@@ -523,9 +541,12 @@ WantedBy=multi-user.target"""
except: except:
pass pass
try:
connection.close() connection.close()
except: except:
pass pass
except:
pass
@staticmethod @staticmethod
def enableServices(): def enableServices():
@@ -726,6 +747,21 @@ WantedBy=multi-user.target"""
except BaseException, msg: except BaseException, msg:
Upgrade.stdOut(str(msg) + " [installLSCPD]") Upgrade.stdOut(str(msg) + " [installLSCPD]")
@staticmethod
def installPHP73():
try:
command = 'yum install -y lsphp73 lsphp73-json lsphp73-xmlrpc lsphp73-xml lsphp73-tidy lsphp73-soap lsphp73-snmp ' \
'lsphp73-recode lsphp73-pspell lsphp73-process lsphp73-pgsql lsphp73-pear lsphp73-pdo lsphp73-opcache ' \
'lsphp73-odbc lsphp73-mysqlnd lsphp73-mcrypt lsphp73-mbstring lsphp73-ldap lsphp73-intl lsphp73-imap ' \
'lsphp73-gmp lsphp73-gd lsphp73-enchant lsphp73-dba lsphp73-common lsphp73-bcmath'
Upgrade.executioner(command, 'Install PHP 73, 0')
except:
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install ' \
'lsphp7? lsphp7?-common lsphp7?-curl lsphp7?-dev lsphp7?-imap lsphp7?-intl lsphp7?-json ' \
'lsphp7?-ldap lsphp7?-mysql lsphp7?-opcache lsphp7?-pspell lsphp7?-recode ' \
'lsphp7?-sqlite3 lsphp7?-tidy'
Upgrade.executioner(command, 'Install PHP 73, 0')
@staticmethod @staticmethod
def upgrade(): def upgrade():
@@ -778,6 +814,7 @@ WantedBy=multi-user.target"""
Upgrade.s3BackupMigrations() Upgrade.s3BackupMigrations()
Upgrade.enableServices() Upgrade.enableServices()
Upgrade.installPHP73()
Upgrade.setupCLI() Upgrade.setupCLI()
Upgrade.installLSCPD() Upgrade.installLSCPD()
Upgrade.fixPermissions() Upgrade.fixPermissions()

View File

@@ -681,7 +681,6 @@ class vhost:
@staticmethod @staticmethod
def changePHP(vhFile, phpVersion): def changePHP(vhFile, phpVersion):
if ProcessUtilities.decideServer() == ProcessUtilities.OLS: if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
finalphp = 0
try: try:
data = open(vhFile, "r").readlines() data = open(vhFile, "r").readlines()
@@ -689,7 +688,7 @@ class vhost:
writeDataToFile = open(vhFile, "w") writeDataToFile = open(vhFile, "w")
path = " path /usr/local/lsws/lsphp" + str(finalphp) + "/bin/lsphp\n" path = " path /usr/local/lsws/lsphp" + str(php) + "/bin/lsphp\n"
for items in data: for items in data:
if items.find("/usr/local/lsws/lsphp") > -1 and items.find("path") > -1: if items.find("/usr/local/lsws/lsphp") > -1 and items.find("path") > -1:
@@ -711,8 +710,6 @@ class vhost:
else: else:
try: try:
data = open(vhFile, "r").readlines() data = open(vhFile, "r").readlines()
if phpVersion == "PHP 5.3":
finalphp = 53
php = PHPManager.getPHPString(phpVersion) php = PHPManager.getPHPString(phpVersion)
@@ -760,7 +757,6 @@ class vhost:
logging.CyberCPLogFileWriter.writeToFile( logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [checkIfRewriteEnabled]]") str(msg) + " [IO Error with per host config file [checkIfRewriteEnabled]]")
return 0 return 0
return 1
@staticmethod @staticmethod
def findDomainBW(domainName, totalAllowed): def findDomainBW(domainName, totalAllowed):

View File

@@ -320,6 +320,26 @@ SecFilterSelective ARGS "into[[:space:]]+outfile|load[[:space:]]+data|/\*.+
<memHardLimit>2047M</memHardLimit> <memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit> <procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit> <procHardLimit>500</procHardLimit>
</extProcessor>
<extProcessor>
<type>lsapi</type>
<name>lsphp73</name>
<address>uds://tmp/lshttpd/lsphp73.sock</address>
<maxConns>35</maxConns>
<env>PHP_LSAPI_CHILDREN=35</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<persistConn>1</persistConn>
<respBuffer>0</respBuffer>
<autoStart>3</autoStart>
<path>$SERVER_ROOT/lsphp73/bin/lsphp</path>
<backlog>100</backlog>
<instances>1</instances>
<priority>0</priority>
<memSoftLimit>2047M</memSoftLimit>
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</extProcessor> </extProcessor>
</extProcessorList> </extProcessorList>
<scriptHandlerList> <scriptHandlerList>
@@ -367,6 +387,11 @@ SecFilterSelective ARGS &quot;into[[:space:]]+outfile|load[[:space:]]+data|/\*.+
<suffix>php72</suffix> <suffix>php72</suffix>
<type>lsapi</type> <type>lsapi</type>
<handler>lsphp72</handler> <handler>lsphp72</handler>
</scriptHandler>
<scriptHandler>
<suffix>php73</suffix>
<type>lsapi</type>
<handler>lsphp73</handler>
</scriptHandler> </scriptHandler>
</scriptHandlerList> </scriptHandlerList>
<railsDefaults> <railsDefaults>

View File

@@ -173,6 +173,7 @@
<option>lsphp56</option> <option>lsphp56</option>
<option>lsphp71</option> <option>lsphp71</option>
<option>lsphp72</option> <option>lsphp72</option>
<option>lsphp73</option>
</select> </select>
</div> </div>
</div> </div>

View File

@@ -1,16 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.shortcuts import render,redirect from django.shortcuts import redirect
from django.http import HttpResponse
import json import json
import plogical.CyberCPLogFileWriter as logging
from plogical.tuning import tuning
from loginSystem.views import loadLoginPage from loginSystem.views import loadLoginPage
from plogical.virtualHostUtilities import virtualHostUtilities
import subprocess
import shlex
from plogical.acl import ACLManager
from tuning import tuningManager from tuning import tuningManager
# Create your views here. # Create your views here.