Skip to content

Commit e671c5c

Browse files
committed
Fixed serverLogs pages for Maillog and FTP logs for Ubuntu. Fixed CSF bug for Ubuntu.
1 parent 164c6cd commit e671c5c

File tree

3 files changed

+49
-19
lines changed

3 files changed

+49
-19
lines changed

plogical/csf.py

100755100644
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def installCSF():
6464
command = 'yum install bind-utils perl-libwww-perl net-tools perl-LWP-Protocol-https -y'
6565
ProcessUtilities.normalExecutioner(command)
6666
elif ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
67-
command = 'apt-get install dnsutils libwww-perl -y'
67+
command = 'apt-get install dnsutils libwww-perl net-tools -y'
6868
ProcessUtilities.normalExecutioner(command)
6969
else:
7070

@@ -266,7 +266,19 @@ def installCSF():
266266
# HTACCESS_LOG is ins main error.log
267267
elif items.find('HTACCESS_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'):
268268
writeToConf.writelines('HTACCESS_LOG = "/usr/local/lsws/logs/error.log"\n')
269-
elif ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
269+
else:
270+
writeToConf.writelines(items)
271+
272+
writeToConf.close()
273+
274+
##
275+
276+
# Some Ubuntu initial configurations
277+
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
278+
data = open('/etc/csf/csf.conf', 'r').readlines()
279+
writeToConf = open('/etc/csf/csf.conf', 'w')
280+
281+
for items in data:
270282
if items.find('SSHD_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'):
271283
writeToConf.writelines('SSHD_LOG = "/var/log/auth.log"\n')
272284
elif items.find('SU_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'):
@@ -277,14 +289,16 @@ def installCSF():
277289
writeToConf.writelines('POP3D_LOG = "/var/log/mail.log"\n')
278290
elif items.find('IMAPD_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'):
279291
writeToConf.writelines('IMAPD_LOG = "/var/log/mail.log"\n')
292+
elif items.find('IPTABLES_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'):
293+
writeToConf.writelines('IPTABLES_LOG = "/var/log/kern.log"\n')
280294
elif items.find('SYSLOG_LOG =') > -1 and items.find('=') > -1 and (items[0] != '#'):
281295
writeToConf.writelines('SYSLOG_LOG = "/var/log/syslog"\n')
282-
else:
283-
writeToConf.writelines(items)
296+
else:
297+
writeToConf.writelines(items)
298+
writeToConf.close()
284299

285-
writeToConf.close()
300+
##
286301

287-
##
288302

289303
command = 'csf -s'
290304
ProcessUtilities.normalExecutioner(command)
@@ -495,19 +509,11 @@ def blockIP(ipAddress):
495509
except BaseException, msg:
496510
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[blockIP]")
497511

498-
@staticmethod
499-
def run_command(command):
500-
p = subprocess.Popen(command,
501-
stdout=subprocess.PIPE,
502-
stderr=subprocess.STDOUT)
503-
return iter(p.stdout.readline, b'')
504-
505512
@staticmethod
506513
def checkIP(ipAddress):
507514
try:
508-
command = "sudo csf -g ' + ipAddress.split()"
509-
for line in CSF.run_command(command):
510-
print(line)
515+
command = 'sudo csf -g ' + ipAddress
516+
ProcessUtilities.executioner(command)
511517

512518
except BaseException, msg:
513519
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[checkIP]")

serverLogs/views.py

100755100644
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from plogical.virtualHostUtilities import virtualHostUtilities
1313
from plogical.acl import ACLManager
1414
from plogical.processUtilities import ProcessUtilities
15+
import os
1516
# Create your views here.
1617

1718

@@ -130,9 +131,15 @@ def getLogsFromFile(request):
130131
elif type == "error":
131132
fileName = installUtilities.Server_root_path + "/logs/error.log"
132133
elif type == "email":
133-
fileName = "/var/log/maillog"
134+
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
135+
fileName = "/var/log/maillog"
136+
else:
137+
fileName = "/var/log/mail.log"
134138
elif type == "ftp":
135-
fileName = "/var/log/messages"
139+
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
140+
fileName = "/var/log/messages"
141+
else:
142+
fileName = "/var/log/syslog"
136143
elif type == "modSec":
137144
fileName = "/usr/local/lsws/logs/auditmodsec.log"
138145
elif type == "cyberpanel":
@@ -195,4 +202,4 @@ def clearLogFile(request):
195202
logging.CyberCPLogFileWriter.writeToFile(str(msg))
196203
data_ret = {'cleanStatus': 0, 'error_message': str(msg)}
197204
json_data = json.dumps(data_ret)
198-
return HttpResponse(json_data)
205+
return HttpResponse(json_data)

upgrade.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
## Script to clear caches after static file changes. Useful for development and testing.
3+
## All credit belongs to Usman Nasir
4+
## To use make it executable
5+
## chmod +x /usr/local/CyberCP/upgrade.sh
6+
## Then run it like below.
7+
## /usr/local/CyberCP/upgrade.sh
8+
9+
cd /usr/local/CyberCP && python manage.py collectstatic --no-input
10+
rm -rf /usr/local/CyberCP/public/static/*
11+
cp -R /usr/local/CyberCP/static/* /usr/local/CyberCP/public/static/
12+
find /usr/local/CyberCP -type d -exec chmod 0755 {} \;
13+
find /usr/local/CyberCP -type f -exec chmod 0644 {} \;
14+
chmod -R 755 /usr/local/CyberCP/bin
15+
chown -R root:root /usr/local/CyberCP
16+
chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin/tmp
17+
systemctl restart lscpd

0 commit comments

Comments
 (0)