From e671c5c53ed8be8ce767becb53956840eee63c9b Mon Sep 17 00:00:00 2001 From: Michael Ramsey Date: Fri, 11 Oct 2019 02:30:22 -0400 Subject: [PATCH] Fixed serverLogs pages for Maillog and FTP logs for Ubuntu. Fixed CSF bug for Ubuntu. --- plogical/csf.py | 38 ++++++++++++++++++++++---------------- serverLogs/views.py | 13 ++++++++++--- upgrade.sh | 17 +++++++++++++++++ 3 files changed, 49 insertions(+), 19 deletions(-) mode change 100755 => 100644 plogical/csf.py mode change 100755 => 100644 serverLogs/views.py create mode 100644 upgrade.sh diff --git a/plogical/csf.py b/plogical/csf.py old mode 100755 new mode 100644 index b4c5e5812..829de1b26 --- a/plogical/csf.py +++ b/plogical/csf.py @@ -64,7 +64,7 @@ class CSF(multi.Thread): command = 'yum install bind-utils perl-libwww-perl net-tools perl-LWP-Protocol-https -y' ProcessUtilities.normalExecutioner(command) elif ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: - command = 'apt-get install dnsutils libwww-perl -y' + command = 'apt-get install dnsutils libwww-perl net-tools -y' ProcessUtilities.normalExecutioner(command) else: @@ -266,7 +266,19 @@ class CSF(multi.Thread): # HTACCESS_LOG is ins main error.log elif items.find('HTACCESS_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'): writeToConf.writelines('HTACCESS_LOG = "/usr/local/lsws/logs/error.log"\n') - elif ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + else: + writeToConf.writelines(items) + + writeToConf.close() + + ## + + # Some Ubuntu initial configurations + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + data = open('/etc/csf/csf.conf', 'r').readlines() + writeToConf = open('/etc/csf/csf.conf', 'w') + + for items in data: if items.find('SSHD_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'): writeToConf.writelines('SSHD_LOG = "/var/log/auth.log"\n') elif items.find('SU_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'): @@ -277,14 +289,16 @@ class CSF(multi.Thread): writeToConf.writelines('POP3D_LOG = "/var/log/mail.log"\n') elif items.find('IMAPD_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'): writeToConf.writelines('IMAPD_LOG = "/var/log/mail.log"\n') + elif items.find('IPTABLES_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'): + writeToConf.writelines('IPTABLES_LOG = "/var/log/kern.log"\n') elif items.find('SYSLOG_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'): writeToConf.writelines('SYSLOG_LOG = "/var/log/syslog"\n') - else: - writeToConf.writelines(items) + else: + writeToConf.writelines(items) + writeToConf.close() - writeToConf.close() + ## - ## command = 'csf -s' ProcessUtilities.normalExecutioner(command) @@ -495,19 +509,11 @@ class CSF(multi.Thread): except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[blockIP]") - @staticmethod - def run_command(command): - p = subprocess.Popen(command, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - return iter(p.stdout.readline, b'') - @staticmethod def checkIP(ipAddress): try: - command = "sudo csf -g ' + ipAddress.split()" - for line in CSF.run_command(command): - print(line) + command = 'sudo csf -g ' + ipAddress + ProcessUtilities.executioner(command) except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[checkIP]") diff --git a/serverLogs/views.py b/serverLogs/views.py old mode 100755 new mode 100644 index 7bffba1a0..300509a09 --- a/serverLogs/views.py +++ b/serverLogs/views.py @@ -12,6 +12,7 @@ import shlex from plogical.virtualHostUtilities import virtualHostUtilities from plogical.acl import ACLManager from plogical.processUtilities import ProcessUtilities +import os # Create your views here. @@ -130,9 +131,15 @@ def getLogsFromFile(request): elif type == "error": fileName = installUtilities.Server_root_path + "/logs/error.log" elif type == "email": - fileName = "/var/log/maillog" + if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + fileName = "/var/log/maillog" + else: + fileName = "/var/log/mail.log" elif type == "ftp": - fileName = "/var/log/messages" + if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + fileName = "/var/log/messages" + else: + fileName = "/var/log/syslog" elif type == "modSec": fileName = "/usr/local/lsws/logs/auditmodsec.log" elif type == "cyberpanel": @@ -195,4 +202,4 @@ def clearLogFile(request): logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'cleanStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) - return HttpResponse(json_data) \ No newline at end of file + return HttpResponse(json_data) diff --git a/upgrade.sh b/upgrade.sh new file mode 100644 index 000000000..e312a77eb --- /dev/null +++ b/upgrade.sh @@ -0,0 +1,17 @@ +#!/bin/bash +## Script to clear caches after static file changes. Useful for development and testing. +## All credit belongs to Usman Nasir +## To use make it executable +## chmod +x /usr/local/CyberCP/upgrade.sh +## Then run it like below. +## /usr/local/CyberCP/upgrade.sh + +cd /usr/local/CyberCP && python manage.py collectstatic --no-input +rm -rf /usr/local/CyberCP/public/static/* +cp -R /usr/local/CyberCP/static/* /usr/local/CyberCP/public/static/ +find /usr/local/CyberCP -type d -exec chmod 0755 {} \; +find /usr/local/CyberCP -type f -exec chmod 0644 {} \; +chmod -R 755 /usr/local/CyberCP/bin +chown -R root:root /usr/local/CyberCP +chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin/tmp +systemctl restart lscpd