From e95bb568d94914c93781718e8941d7c2b18c71e9 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Mon, 7 Oct 2024 17:19:19 +0500 Subject: [PATCH] bug fix: add csf gui --- CyberCP/urls.py | 1 + configservercsf/__init__.py | 1 - configservercsf/admin.py | 6 -- configservercsf/apps.py | 7 --- configservercsf/config | 0 configservercsf/meta.xml | 7 --- configservercsf/migrations/__init__.py | 0 configservercsf/models.py | 6 -- configservercsf/signals.py | 13 ----- .../templates/configservercsf/index.html | 17 ------ .../templates/configservercsf/menu.html | 25 -------- configservercsf/tests.py | 6 -- configservercsf/urls.py | 7 --- configservercsf/views.py | 57 ------------------- plogical/csf.py | 48 ++++++++++------ 15 files changed, 32 insertions(+), 169 deletions(-) delete mode 100644 configservercsf/__init__.py delete mode 100644 configservercsf/admin.py delete mode 100644 configservercsf/apps.py delete mode 100644 configservercsf/config delete mode 100644 configservercsf/meta.xml delete mode 100644 configservercsf/migrations/__init__.py delete mode 100644 configservercsf/models.py delete mode 100644 configservercsf/signals.py delete mode 100644 configservercsf/templates/configservercsf/index.html delete mode 100644 configservercsf/templates/configservercsf/menu.html delete mode 100644 configservercsf/tests.py delete mode 100644 configservercsf/urls.py delete mode 100644 configservercsf/views.py diff --git a/CyberCP/urls.py b/CyberCP/urls.py index 39a993960..256c10c5c 100755 --- a/CyberCP/urls.py +++ b/CyberCP/urls.py @@ -44,5 +44,6 @@ urlpatterns = [ path('container/', include('containerization.urls')), path('CloudLinux/', include('CLManager.urls')), path('IncrementalBackups/', include('IncBackups.urls')), +# path(r'configservercsf/',include('configservercsf.urls')), # path('Terminal/', include('WebTerminal.urls')), ] diff --git a/configservercsf/__init__.py b/configservercsf/__init__.py deleted file mode 100644 index 58ef6a5ea..000000000 --- a/configservercsf/__init__.py +++ /dev/null @@ -1 +0,0 @@ -#default_app_config = 'configservercsf.apps.configservercsfConfig' diff --git a/configservercsf/admin.py b/configservercsf/admin.py deleted file mode 100644 index 13be29d96..000000000 --- a/configservercsf/admin.py +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.contrib import admin - -# Register your models here. diff --git a/configservercsf/apps.py b/configservercsf/apps.py deleted file mode 100644 index fae710cba..000000000 --- a/configservercsf/apps.py +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.apps import AppConfig - -class configservercsfConfig(AppConfig): - name = 'configservercsf' diff --git a/configservercsf/config b/configservercsf/config deleted file mode 100644 index e69de29bb..000000000 diff --git a/configservercsf/meta.xml b/configservercsf/meta.xml deleted file mode 100644 index 4515593e9..000000000 --- a/configservercsf/meta.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - ConfigServer Security and Firewall - plugin - ConfigServer Security and Firewall - 1.0 - diff --git a/configservercsf/migrations/__init__.py b/configservercsf/migrations/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/configservercsf/models.py b/configservercsf/models.py deleted file mode 100644 index 1dfab7604..000000000 --- a/configservercsf/models.py +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models - -# Create your models here. diff --git a/configservercsf/signals.py b/configservercsf/signals.py deleted file mode 100644 index 3db8f8c4a..000000000 --- a/configservercsf/signals.py +++ /dev/null @@ -1,13 +0,0 @@ -from django.dispatch import receiver -from django.shortcuts import redirect -from firewall.signals import preFirewallHome, preCSF - -@receiver(preFirewallHome) -def csfFirewallHome(sender, **kwargs): - request = kwargs['request'] - return redirect('/configservercsf/') - -@receiver(preCSF) -def csfCSF(sender, **kwargs): - request = kwargs['request'] - return redirect('/configservercsf/') diff --git a/configservercsf/templates/configservercsf/index.html b/configservercsf/templates/configservercsf/index.html deleted file mode 100644 index fcae8b1a0..000000000 --- a/configservercsf/templates/configservercsf/index.html +++ /dev/null @@ -1,17 +0,0 @@ -{% extends "baseTemplate/index.html" %} -{% load i18n %} -{% block title %}ConfigServer Security and Firewall{% endblock %} -{% block content %} - -{% load static %} - - - - -{% endblock %} diff --git a/configservercsf/templates/configservercsf/menu.html b/configservercsf/templates/configservercsf/menu.html deleted file mode 100644 index d2888156f..000000000 --- a/configservercsf/templates/configservercsf/menu.html +++ /dev/null @@ -1,25 +0,0 @@ - - - ConfigServer Services - - - - -
  • diff --git a/configservercsf/tests.py b/configservercsf/tests.py deleted file mode 100644 index 5982e6bcd..000000000 --- a/configservercsf/tests.py +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.test import TestCase - -# Create your tests here. diff --git a/configservercsf/urls.py b/configservercsf/urls.py deleted file mode 100644 index 1f47c8774..000000000 --- a/configservercsf/urls.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.urls import path, re_path -from . import views - -urlpatterns = [ - path('', views.configservercsf, name='configservercsf'), - path('iframe/', views.configservercsfiframe, name='configservercsfiframe'), -] \ No newline at end of file diff --git a/configservercsf/views.py b/configservercsf/views.py deleted file mode 100644 index 4c1b84b99..000000000 --- a/configservercsf/views.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -import os -import os.path -import sys -import django - -sys.path.append('/usr/local/CyberCP') -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") -django.setup() -from plogical.acl import ACLManager - -from plogical.processUtilities import ProcessUtilities -from django.views.decorators.csrf import csrf_exempt -import tempfile -from django.http import HttpResponse -from django.views.decorators.clickjacking import xframe_options_exempt -from plogical.httpProc import httpProc - -def configservercsf(request): - proc = httpProc(request, 'configservercsf/index.html', - None, 'admin') - return proc.render() - -@csrf_exempt -@xframe_options_exempt -def configservercsfiframe(request): - userID = request.session['userID'] - currentACL = ACLManager.loadedACL(userID) - - if currentACL['admin'] == 1: - pass - else: - return ACLManager.loadError() - - if request.method == 'GET': - qs = request.GET.urlencode() - elif request.method == 'POST': - qs = request.POST.urlencode() - - try: - tmp = tempfile.NamedTemporaryFile(mode = "w", delete=False) - tmp.write(qs) - tmp.close() - command = "/usr/local/csf/bin/cyberpanel.pl '" + tmp.name + "'" - - try: - output = ProcessUtilities.outputExecutioner(command) - except: - output = "Output Error from csf UI script" - - os.unlink(tmp.name) - except: - output = "Unable to create csf UI temp file" - - return HttpResponse(output) diff --git a/plogical/csf.py b/plogical/csf.py index 87568c3e5..26322e7b6 100755 --- a/plogical/csf.py +++ b/plogical/csf.py @@ -155,6 +155,7 @@ urlpatterns = [ WriteToFile.write(content) WriteToFile.close() + command = "chmod +x install.sh" ProcessUtilities.normalExecutioner(command) @@ -475,30 +476,43 @@ urlpatterns = [ # for cmd in sed_commands: # ProcessUtilities.executioner(cmd) - command = 'rm -Rfv /usr/local/CyberCP/configservercsf' - ProcessUtilities.normalExecutioner(command) + # command = 'rm -Rfv /usr/local/CyberCP/configservercsf' + # ProcessUtilities.normalExecutioner(command) + # + # command = 'rm -fv /home/cyberpanel/plugins/configservercsf' + # ProcessUtilities.normalExecutioner(command) + # + # command = 'rm -Rfv /usr/local/CyberCP/public/static/configservercsf' + # ProcessUtilities.normalExecutioner(command) + # + # command = 'sed -i "/configservercsf/d" /usr/local/CyberCP/CyberCP/settings.py' + # ProcessUtilities.normalExecutioner(command) + # + # command = 'sed -i "/configservercsf/d" /usr/local/CyberCP/CyberCP/urls.py' + # ProcessUtilities.normalExecutioner(command) + # + # if not os.path.exists('/etc/cxs/cxs.pl'): + # + # command = 'sed -i "/configserver/d" /usr/local/CyberCP/baseTemplate/templates/baseTemplate/index.html' + # ProcessUtilities.normalExecutioner(command) + # + # command = 'killall lswsgi' + # ProcessUtilities.normalExecutioner(command) - command = 'rm -fv /home/cyberpanel/plugins/configservercsf' - ProcessUtilities.normalExecutioner(command) + data = open('/usr/local/CyberCP/CyberCP/urls.py', 'r').readlines() - command = 'rm -Rfv /usr/local/CyberCP/public/static/configservercsf' - ProcessUtilities.normalExecutioner(command) + WriteToFile = open('/usr/local/CyberCP/CyberCP/urls.py', 'w') - command = 'sed -i "/configservercsf/d" /usr/local/CyberCP/CyberCP/settings.py' - ProcessUtilities.normalExecutioner(command) - - command = 'sed -i "/configservercsf/d" /usr/local/CyberCP/CyberCP/urls.py' - ProcessUtilities.normalExecutioner(command) - - if not os.path.exists('/etc/cxs/cxs.pl'): - - command = 'sed -i "/configserver/d" /usr/local/CyberCP/baseTemplate/templates/baseTemplate/index.html' - ProcessUtilities.normalExecutioner(command) + for line in data: + if line[0] == '#' and line.find('configservercsf') > -1: + WriteToFile.write(" path(r'configservercsf/',include('configservercsf.urls')),\n") + else: + WriteToFile.write(line) + WriteToFile.close() command = 'killall lswsgi' ProcessUtilities.normalExecutioner(command) - return 1 except BaseException as msg: try: