CSF Installation Disabled After CyberPanel Update: Firewall Settings Hidden and Installation Errors

You are great. You have saved my system. Thank you so much!

What I just saw after using your rollback script is that CSF released a new version 5 days ago

Now I wonder if the problem has been fixed in it? Does anyone know?

Got this on one server:

Can you help?

I have different CyberPanel Server based obn Ubunto20.04LTS and Ubuntu22.04LTS

It seems your Rollback-Script only works on Ubuntu20.04LTS based installs of Cyberpanel. It dosen´t work ob Ubuntu22.04LTS based Cyberpanel machines. After the rollback the Error 500 is back

Ok. So for Ubuntu 22.04 Cyberpanel v2.3.5 I’m getting 500 error.
I pinpointed the error:

Traceback (most recent call last):
  File "/usr/local/CyberCP/CyberCP/wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/conf/__init__.py", line 102, in __getattr__
    self._setup(name)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/conf/__init__.py", line 89, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/conf/__init__.py", line 217, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/local/CyberCP/CyberCP/settings.py", line 14, in <module>
    from django.utils.translation import ugettext_lazy as _
ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation' (/usr/local/CyberCP/lib/python3.10/site-packages/django/utils/translation/__init__.py)
2024-09-03 20:01:22.569851 [UID:1001][1888163] packetLen < 0

ugettext_lazy is deprecated.

As stated before, this doesn’t seem so much of CSF issue as it is Django package version mismatch within CyberCP (control panel itself).

I don’t think that’s an issue particular with Ubuntu 22.
I was checking yesterday with @dcupertino and he also got that issue on Almalinux 9 but was able to solve it.

Check to make sure django is on 3.1.3

python -m django --version

Run the following:

pip install --upgrade pip
pip install --upgrade packaging setuptools
pip install Django==3.1.3
pip install -r /usr/local/CyberCP/requirments.txt --force-reinstall
find /usr/local/CyberCP/ -type d -name __pycache__ -exec rm -r {} \+; service lscpd restart && service lsws restart; killall lsphp

After check to see if that fixes the panel. If not upgrade Django and upgrade Cyberpanel to 2.3.5

pip install --upgrade django
sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh || wget -O - https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh)

After the upgrade, you should be back up to 2.3.5 with No CSF.
Rerun my script and then follow the steps to uninstall and reinstall CSF then restore your CSF config backup.

Double, triple-checked everything:

  1. Django is 3.1.3 version
  2. Rerun everything as you mentioned step by step
  3. Still the same 500 error (only this time packages exist and previous error dissipated)

Here is the error (that previously also occurred):

File "/usr/local/CyberCP/CyberCP/wsgi.py", line 17, in <module>
    application = get_wsgi_application()
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/apps/registry.py", line 83, in populate
    raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
2024-09-03 17:35:51.264906 [UID:1001][1929473] packetLen < 0

Basically what this issue means is that Django’s app registry is being populated more than once.
So this is a good news. Now for the sake of finding out what is the real reason for this - I changed in django/apps/registry.py:

raise RuntimeError("populate() isn't reentrant")

to

self.app_configs = {}

to allow Django continue loading.

Now 500 error disapeared and I tried to install CSF again and got this error during installation:

local variable 'cPort' referenced before assignment [404]Downloading CSF..

Checking out stderr.log i got that module signals is missing:

Traceback (most recent call last):
  File "/usr/local/CyberCP/CyberCP/wsgi.py", line 17, in <module>
    application = get_wsgi_application()
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/apps/registry.py", line 124, in populate
    app_config.ready()
  File "/usr/local/CyberCP/configservercsf/apps.py", line 10, in ready
    import signals
ModuleNotFoundError: No module named 'signals'
2024-09-03 17:52:20.291332 [UID:1001][1972596] packetLen < 0

Continuing investigating… Update coming soon…

[UPDATE]
So the issue lies within /usr/local/CyberCP/configservcsf/ as suspected.
I installed signals and after restart got this error:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/utils/deprecation.py", line 134, in __call__
    response = response or self.get_response(request)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/handlers/exception.py", line 57, in inner
    response = response_for_exception(request, exc)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/handlers/exception.py", line 140, in response_for_exception
    response = handle_uncaught_exception(
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/handlers/exception.py", line 184, in handle_uncaught_exception
    callback = resolver.resolve_error_handler(500)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/urls/resolvers.py", line 729, in resolve_error_handler
    callback = getattr(self.urlconf_module, "handler%s" % view_type, None)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/local/CyberCP/CyberCP/urls.py", line 40, in <module>
    url(r'^configservercsf/',include('configservercsf.urls')),
NameError: name 'url' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/handlers/wsgi.py", line 124, in __call__
    response = self.get_response(request)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/handlers/base.py", line 140, in get_response
    response = self._middleware_chain(request)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/handlers/exception.py", line 57, in inner
    response = response_for_exception(request, exc)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/handlers/exception.py", line 140, in response_for_exception
    response = handle_uncaught_exception(
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/handlers/exception.py", line 184, in handle_uncaught_exception
    callback = resolver.resolve_error_handler(500)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/urls/resolvers.py", line 729, in resolve_error_handler
    callback = getattr(self.urlconf_module, "handler%s" % view_type, None)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/local/CyberCP/CyberCP/urls.py", line 40, in <module>
    url(r'^configservercsf/',include('configservercsf.urls')),
NameError: name 'url' is not define

I suspect its configuration issue from CyberCP side. I’m not confident in messing around CyberCP and configservcsf urls.py atm, so I’ll take a break, look around and maybe continue once I figure out why CSF installation doesn’t provide correct URLs or why CyberCP doesn’t load csf correctly.

That’s it from me now. Hope somebody will have better luck debugging this.
Again, Thanks @sajetek_developer for your effort. :pray:

Edit /usr/local/CyberCP/CyberCP/settings.py and remove the line that contains “configservcsf”
restart lscpd and that will fix the “RuntimeError: populate() isn’t reentrant” error

From there your panel should load

1 Like

Welp, yeah - getting same error:

  File "/usr/local/CyberCP/CyberCP/urls.py", line 40, in <module>
    url(r'^configservercsf/',include('configservercsf.urls')),
NameError: name 'url' is not defined

I tried to rerun everything also with /usr/local/CyberCP/bin/pip and /usr/local/CyberCP/bin/python but I get the same error.

Please redownload the script as there was an update.
Thanks to @richardevcom for helping resolve the issue on Ubuntu 22

1 Like

Thank you @sajetek_developer :pray:

Whoever is still searching for solution, here is the updated one (works on Ubuntu 22.04 as well): https://sajetekengineering.com/blog-article/how-to-re-enable-csf-firewall-on-cyberpanel/

1 Like

Hello, thank you very much for your help. With the latest version of your script I was able to successfully rollback Cyberpanel and reinstall CSF on my Ubuntu22.04LTS based systems.

Thank you very much !!!

1 Like

I have another problem and I’m not sure if it’s related. In any case, my ImunifyAV is no longer working. I can still call it up and log in and also start a manual scan, but it scans NOTHING, as you can see from the fact that there is always a 0 in the “Total Objects Scanned”:

Even a new installation does not help.

I see this error in the system services. This aibolit-resident.socket probably has something to do with Imunify. Does anyone have an idea about this?

Definitely not related. Please create another topic regarding this.

Hello everyone. CyberPanel v2.3.7 Released came out yesterday, has anyone already tried it, does it still have the problem with CSF?

Yes i tried, everything looked ok except for CSF, still not working. i had to revert back to 2.3.5

2 Likes

CSF is discontinued as a feature for upcoming versions. No info from CP developers yet.

This is very sad. For me, this was a very powerful argument in favor. I was ready to give up a lot but not CSF.

2 Likes

Good news, I think I might have found a fix.
I am running Cyberpanel 2.3.7 ALmalinux 8

I do not believe the fix was that easy.

Keep a zip backup of your /etc/csf the script will restore it for you.
The script install csf in Cyberpanel and makes a small fix which would have crashed the panel.

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)

Enjoy CSF in the latest version of Cyberpanel.

N.B. Backup your csf before running CYberpanel Upgrade because it will be removed, then you will have to rerun the script to reinstall csf and restore your backups

2 Likes

Hi @sajetek_developer , does it work from ubuntu 22.04 version?

I don’t see any reason it would not but I haven’t tried it.
You can try it by backing up your csf, upgrading then running the script.

If it does not work, then you can uninstall csf or simply rerun the Cyberpanel Upgrade script to get back a working panel.
From there you have two options, one to use the rollback script or you can install csf generic.

If you want you can try it and if you have any issues pm me so we can debug it.