Skip to content

Commit

Permalink
Fixed serverLogs pages for Maillog and FTP logs for Ubuntu. Fixed CSF…
Browse files Browse the repository at this point in the history
… bug for Ubuntu.
  • Loading branch information
meramsey committed Oct 11, 2019
1 parent 164c6cd commit e671c5c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 19 deletions.
38 changes: 22 additions & 16 deletions plogical/csf.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def installCSF():
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:

Expand Down Expand Up @@ -266,7 +266,19 @@ def installCSF():
# 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] != '#'):
Expand All @@ -277,14 +289,16 @@ def installCSF():
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)
Expand Down Expand Up @@ -495,19 +509,11 @@ def blockIP(ipAddress):
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]")
Expand Down
13 changes: 10 additions & 3 deletions serverLogs/views.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from plogical.virtualHostUtilities import virtualHostUtilities
from plogical.acl import ACLManager
from plogical.processUtilities import ProcessUtilities
import os
# Create your views here.


Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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)
return HttpResponse(json_data)
17 changes: 17 additions & 0 deletions upgrade.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e671c5c

Please sign in to comment.