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:
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"
subprocess.Popen(shlex.split(execPath))
@@ -1520,7 +1520,7 @@ class FirewallManager:
else:
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"
subprocess.Popen(shlex.split(execPath))
@@ -1579,7 +1579,7 @@ class FirewallManager:
controller = data['controller']
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
output = subprocess.check_output(shlex.split(execPath))
@@ -1613,7 +1613,7 @@ class FirewallManager:
protocol = data['protocol']
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
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:
command = "pip install --upgrade requests"
install.preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'Upgrade requests',
1, 0, os.EX_OSERR)
except:
@@ -780,17 +780,18 @@ class preFlightsChecks:
os.chdir(self.path)
#command = "wget http://cyberpanel.net/CyberPanel.1.7.5.tar.gz"
command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz"
install.preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
command = "wget http://cyberpanel.sh/CyberPanel.1.7.5.tar.gz"
#command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz"
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'CyberPanel Download',
1, 1, os.EX_OSERR)
##
count = 0
command = "tar zxf CyberPanelTemp.tar.gz"
install.preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
command = "tar zxf CyberPanel.1.7.5.tar.gz"
#command = "tar zxf CyberPanelTemp.tar.gz"
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'Extract CyberPanel',1, 1, os.EX_OSERR)
### update password:
@@ -852,33 +853,33 @@ class preFlightsChecks:
os.chdir("CyberCP")
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',
1, 1, os.EX_OSERR)
##
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)
## Moving static content to lscpd location
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)
## fix permissions
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 owner
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)
@@ -890,7 +891,7 @@ class preFlightsChecks:
else:
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)
except BaseException, msg:
logging.InstallLog.writeToFile(str(msg) + " [install_unzip]")
@@ -903,7 +904,7 @@ class preFlightsChecks:
else:
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)
except BaseException, msg:
logging.InstallLog.writeToFile(str(msg) + " [install_zip]")
@@ -913,12 +914,12 @@ class preFlightsChecks:
os.chdir("/usr/local/lscp/cyberpanel/")
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)
#####
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)
@@ -927,7 +928,7 @@ class preFlightsChecks:
os.remove("phpMyAdmin-4.8.2-all-languages.zip")
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)
## Write secret phrase
@@ -2128,80 +2129,43 @@ class preFlightsChecks:
try:
preFlightsChecks.stdOut("Enabling Firewall!")
count = 0
while (1):
if self.distro == ubuntu:
command = 'apt-get -y install firewalld'
else:
command = 'yum -y install firewalld'
cmd = shlex.split(command)
res = subprocess.call(cmd)
if preFlightsChecks.resFailed(self.distro, res):
count = count + 1
preFlightsChecks.stdOut("Unable to install FirewallD, trying again, try number: " + str(count))
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
preFlightsChecks.call(command, self.distro, '[installFirewalld]',
'Install FirewallD',
1, 0, os.EX_OSERR)
######
if self.distro == centos:
# Not available in ubuntu
command = 'systemctl restart dbus'
cmd = shlex.split(command)
subprocess.call(cmd)
preFlightsChecks.call(command, self.distro, '[installFirewalld]',
'Start dbus',
1, 0, os.EX_OSERR)
command = 'systemctl restart systemd-logind'
cmd = shlex.split(command)
subprocess.call(cmd)
preFlightsChecks.call(command, self.distro, '[installFirewalld]',
'restart logind',
1, 0, os.EX_OSERR)
count = 0
while (1):
command = 'systemctl start firewalld'
cmd = shlex.split(command)
res = subprocess.call(cmd)
preFlightsChecks.call(command, self.distro, '[installFirewalld]',
'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'
cmd = shlex.split(command)
res = subprocess.call(cmd)
preFlightsChecks.call(command, self.distro, '[installFirewalld]',
'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", "80")

View File

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

View File

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

View File

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

View File

@@ -13,6 +13,7 @@ import json
import time
from baseTemplate.models import version
import MySQLdb as mysql
from CyberCP import settings
class Upgrade:
logPath = "/usr/local/lscp/logs/upgradeLog"
@@ -217,7 +218,15 @@ WantedBy=multi-user.target"""
try:
conn = mysql.connect(db=db, user='root', passwd=password)
except:
try:
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()
return conn, cursor
@@ -291,7 +300,10 @@ WantedBy=multi-user.target"""
except:
pass
try:
connection.close()
except:
pass
except OSError, msg:
Upgrade.stdOut(str(msg) + " [applyLoginSystemMigrations]")
@@ -352,7 +364,10 @@ WantedBy=multi-user.target"""
except:
pass
try:
connection.close()
except:
pass
except OSError, msg:
Upgrade.stdOut(str(msg) + " [applyLoginSystemMigrations]")
@@ -414,9 +429,12 @@ WantedBy=multi-user.target"""
except:
pass
try:
connection.close()
except:
pass
except:
pass
@staticmethod
def emailMarketingMigrationsa():
@@ -523,9 +541,12 @@ WantedBy=multi-user.target"""
except:
pass
try:
connection.close()
except:
pass
except:
pass
@staticmethod
def enableServices():
@@ -726,6 +747,21 @@ WantedBy=multi-user.target"""
except BaseException, msg:
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
def upgrade():
@@ -778,6 +814,7 @@ WantedBy=multi-user.target"""
Upgrade.s3BackupMigrations()
Upgrade.enableServices()
Upgrade.installPHP73()
Upgrade.setupCLI()
Upgrade.installLSCPD()
Upgrade.fixPermissions()

View File

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

View File

@@ -320,6 +320,26 @@ SecFilterSelective ARGS "into[[:space:]]+outfile|load[[:space:]]+data|/\*.+
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<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>
</extProcessorList>
<scriptHandlerList>
@@ -367,6 +387,11 @@ SecFilterSelective ARGS &quot;into[[:space:]]+outfile|load[[:space:]]+data|/\*.+
<suffix>php72</suffix>
<type>lsapi</type>
<handler>lsphp72</handler>
</scriptHandler>
<scriptHandler>
<suffix>php73</suffix>
<type>lsapi</type>
<handler>lsphp73</handler>
</scriptHandler>
</scriptHandlerList>
<railsDefaults>

View File

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

View File

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