Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Simple fix for CSF #1328

Closed
SaJeTek-Developer opened this issue Sep 29, 2024 · 6 comments
Closed

Simple fix for CSF #1328

SaJeTek-Developer opened this issue Sep 29, 2024 · 6 comments

Comments

@SaJeTek-Developer
Copy link

SaJeTek-Developer commented Sep 29, 2024

Describe the bug
Cyberpanel has disabled csf as there is an issue with the csf Cyberpanel install. However the issue is quite minor and Cyberpanel can make a small adjustment to have it work instead of disabling it totally.

After upgrading to 2.3.7 and enabling Debugging, I manually installed csf in Cyberpanel which caused an error.
There are 2 issues with configserver:

  1. Using urls which is removed in Django 4
  2. There is a circular import in /usr/local/CyberCP/configservercsf/apps.py

Solution
I know this is not your job to do but:
A simple sed would suffice and allow csf to load instead of totally disabling CSF.
These commands can run after installing CSF from the panel

sed -i "s/url(r'^configservercsf/path('configservercsf/g" /usr/local/CyberCP/CyberCP/urls.py
sed -i "s/from django.conf.urls import url/from django.urls import path/g" /usr/local/CyberCP/configservercsf/urls.py
sed -i "s/import signals/import configservercsf.signals/g" /usr/local/CyberCP/configservercsf/apps.py
sed -i "s/url(r'^$'/path(''/g" /usr/local/CyberCP/configservercsf/urls.py
sed -i "s|url(r'^iframe/$'|path('iframe/'|g" /usr/local/CyberCP/configservercsf/urls.py
`

Operating system:
Almalinux 8.10
Almalinux 9.4
Ubuntu 20.04

CyberPanel version:
2.3.7

@SaJeTek-Developer
Copy link
Author

SaJeTek-Developer commented Sep 30, 2024

I am currently using a script which does this for me and also restores my csf configurated which is stored in a zip file.

sh <(curl https://sajetekengineering.com/wp-content/uploads/cyberpanel/install_csf_cyberpanel.sh || wget -O - https://sajetekengineering.com/wp-content/uploads/cyberpanel/install_csf_cyberpanel.sh)

The script will ask for the absolute path of my zip file, install csf and restore my configurations.
The issue is, that a backup of csf has to be done every time before upgrading Cyberpanel and the script also has to be run after upgrading since the Cyberpanel upgrade script removes csf.

@SaJeTek-Developer
Copy link
Author

I've submitted my findings to Configserver who will provide a fix for the issues.
I've also submitted a fix for the menu which get's truncated on the Configserver page.

All fixes are added to the script.

usmannasir added a commit that referenced this issue Oct 2, 2024
@usmannasir
Copy link
Owner

it is added, thanks alot @SaJeTek-Developer

usmannasir added a commit that referenced this issue Oct 2, 2024
usmannasir added a commit that referenced this issue Oct 2, 2024
@SaJeTek-Developer
Copy link
Author

Hi @usmannasir can you also add the fix for the menu.
Their current implementation breaks the side menu.

sed -i -E "s/from.*, response/from plogical.httpProc import httpProc/g" /usr/local/CyberCP/configservercsf/views.py
sed -i -E "s#^(\s*)return render.*index\.html.*#\1proc = httpProc(request, 'configservercsf/index.html', None, 'admin')\n\1return proc.render()#g" /usr/local/CyberCP/configservercsf/views.py

usmannasir added a commit that referenced this issue Oct 3, 2024
@usmannasir
Copy link
Owner

it is done, thank you

@SaJeTek-Developer
Copy link
Author

SaJeTek-Developer commented Oct 3, 2024

Hi @usmannasir

There was a mistype: Please change response to render:
i.e. change

sed -i -E "s/from.*, response/from plogical.httpProc import httpProc/g" /usr/local/CyberCP/configservercsf/views.py
to
sed -i -E "s/from.*, render/from plogical.httpProc import httpProc/g" /usr/local/CyberCP/configservercsf/views.py

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants