From 20254f467cf5c9f9f12b8c35942e614a6fa49afe Mon Sep 17 00:00:00 2001 From: usmannasir Date: Sun, 9 Nov 2025 12:10:43 +0500 Subject: [PATCH] Add support for RHEL 8 and RHEL 9 custom binaries Update OS detection and binary distribution to support separate binaries for AlmaLinux/RHEL 8 and 9. The new structure uses: - rhel8/ directory for AlmaLinux/RHEL 8.x binaries - rhel9/ directory for AlmaLinux/RHEL 9.x binaries - ubuntu/ directory for Ubuntu/Debian binaries Changes: - Enhanced detectBinarySuffix() to distinguish between RHEL 8 and 9 - Updated binary URLs to use new directory structure - Updated ModSecurity checksums for all OS variants - Applied changes to install, upgrade, and ModSecurity modules This ensures proper ABI compatibility by providing OS-specific builds with correct glibc and library dependencies for each platform. --- install/installCyberPanel.py | 43 +++++++++++++++++++----- plogical/modSec.py | 42 +++++++++++++++-------- plogical/upgrade.py | 64 ++++++++++++++++++++++++------------ 3 files changed, 105 insertions(+), 44 deletions(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 97d2fe8cb..66fd02c4d 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -226,18 +226,33 @@ class InstallCyberPanel: def detectBinarySuffix(self): """Detect which binary suffix to use based on OS distribution - Returns 'ubuntu' for Ubuntu/Debian systems with libcrypt.so.1 - Returns 'rhel' for RHEL/AlmaLinux/Rocky systems with libcrypt.so.2 + Returns 'ubuntu' for Ubuntu/Debian systems + Returns 'rhel8' for RHEL/AlmaLinux/Rocky 8.x systems + Returns 'rhel9' for RHEL/AlmaLinux/Rocky 9.x systems """ try: # Ubuntu/Debian → ubuntu suffix if self.distro == ubuntu: return 'ubuntu' - # CentOS 8+/AlmaLinux/Rocky/OpenEuler → rhel suffix - # These systems use libcrypt.so.2 and GLIBC 2.34+ + # CentOS 8+/AlmaLinux/Rocky/OpenEuler → detect version elif self.distro == cent8 or self.distro == openeuler: - return 'rhel' + # Read /etc/os-release to get the version + if os.path.exists('/etc/os-release'): + with open('/etc/os-release', 'r') as f: + os_release = f.read().lower() + + # Extract version number + for line in os_release.split('\n'): + if 'version_id' in line: + version = line.split('=')[1].strip('"').split('.')[0] + if version == '9': + return 'rhel9' + elif version == '8': + return 'rhel8' + + # Default to rhel9 if version detection fails + return 'rhel9' # CentOS 7 → ubuntu suffix (uses libcrypt.so.1) elif self.distro == centos: @@ -371,10 +386,20 @@ class InstallCyberPanel: binary_suffix = self.detectBinarySuffix() InstallCyberPanel.stdOut(f"Detected OS type: using '{binary_suffix}' binaries", 1) - # URLs for custom binaries with OS-specific suffix - BASE_URL = "https://cyberpanel.net" - OLS_BINARY_URL = f"{BASE_URL}/openlitespeed-phpconfig-x86_64-{binary_suffix}" - MODULE_URL = f"{BASE_URL}/cyberpanel_ols_x86_64_{binary_suffix}.so" + # URLs for custom binaries with OS-specific paths + BASE_URL = "https://cyberpanel.net/binaries" + + # Set URLs based on OS type + if binary_suffix == 'rhel8': + OLS_BINARY_URL = f"{BASE_URL}/rhel8/openlitespeed-phpconfig-x86_64-rhel8" + MODULE_URL = f"{BASE_URL}/rhel8/cyberpanel_ols_x86_64_rhel8.so" + elif binary_suffix == 'rhel9': + OLS_BINARY_URL = f"{BASE_URL}/rhel9/openlitespeed-phpconfig-x86_64" + MODULE_URL = f"{BASE_URL}/rhel9/cyberpanel_ols_x86_64.so" + else: # ubuntu + OLS_BINARY_URL = f"{BASE_URL}/ubuntu/openlitespeed-phpconfig-x86_64-ubuntu" + MODULE_URL = f"{BASE_URL}/ubuntu/cyberpanel_ols_x86_64_ubuntu.so" + OLS_BINARY_PATH = "/usr/local/lsws/bin/openlitespeed" MODULE_PATH = "/usr/local/lsws/modules/cyberpanel_ols.so" diff --git a/plogical/modSec.py b/plogical/modSec.py index 6debdc624..3897c718b 100644 --- a/plogical/modSec.py +++ b/plogical/modSec.py @@ -44,25 +44,35 @@ class modSec: @staticmethod def detectBinarySuffix(): - """Detect which binary suffix to use based on OS distribution""" + """Detect which binary suffix to use based on OS distribution + Returns 'ubuntu' for Ubuntu/Debian systems + Returns 'rhel8' for RHEL/AlmaLinux/Rocky 8.x systems + Returns 'rhel9' for RHEL/AlmaLinux/Rocky 9.x systems + """ try: - # Check if we're on RHEL/CentOS/AlmaLinux 8+ (uses libcrypt.so.2) + # Check if we're on RHEL/CentOS/AlmaLinux (check version) if os.path.exists('/etc/os-release'): with open('/etc/os-release', 'r') as f: os_release = f.read().lower() - # AlmaLinux 9+, Rocky 9+, RHEL 9+, CentOS Stream 9+ - if any(x in os_release for x in ['almalinux', 'rocky', 'rhel']) and 'version="9' in os_release: - return 'rhel' - elif 'centos stream 9' in os_release: - return 'rhel' + # Check for RHEL-based distributions + if any(x in os_release for x in ['almalinux', 'rocky', 'rhel', 'centos stream']): + # Extract version number + for line in os_release.split('\n'): + if 'version_id' in line: + version = line.split('=')[1].strip('"').split('.')[0] + if version == '9': + return 'rhel9' + elif version == '8': + return 'rhel8' - # Check CentOS/RHEL path + # Check CentOS/RHEL path (legacy method) if os.path.exists('/etc/redhat-release'): data = open('/etc/redhat-release', 'r').read() - # CentOS/AlmaLinux/Rocky 8+ → rhel suffix - if 'release 8' in data or 'release 9' in data: - return 'rhel' + if 'release 9' in data: + return 'rhel9' + elif 'release 8' in data: + return 'rhel8' # Default to ubuntu return 'ubuntu' @@ -84,12 +94,16 @@ class modSec: # Detect OS and select appropriate ModSecurity binary binary_suffix = modSec.detectBinarySuffix() + BASE_URL = "https://cyberpanel.net/binaries" - if binary_suffix == 'rhel': - MODSEC_URL = "https://cyberpanel.net/mod_security-compatible-rhel.so" + if binary_suffix == 'rhel8': + MODSEC_URL = f"{BASE_URL}/rhel8/mod_security-compatible-rhel8.so" + EXPECTED_SHA256 = "8c769dfb42711851ec539e9b6ea649616c14b0e85a53eb18755d200ce29bc442" + elif binary_suffix == 'rhel9': + MODSEC_URL = f"{BASE_URL}/rhel9/mod_security-compatible-rhel.so" EXPECTED_SHA256 = "db580afc431fda40d46bdae2249ac74690d9175ff6d8b1843f2837d86f8d602f" else: # ubuntu - MODSEC_URL = "https://cyberpanel.net/mod_security-compatible-ubuntu.so" + MODSEC_URL = f"{BASE_URL}/ubuntu/mod_security-compatible-ubuntu.so" EXPECTED_SHA256 = "115971fcd44b74bc7c7b097b9cec33ddcfb0fb07bb9b562ec9f4f0691c388a6b" # Download to temp location diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 8feb5a937..4df79a5f6 100644 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -633,34 +633,41 @@ class Upgrade: @staticmethod def detectBinarySuffix(): """Detect which binary suffix to use based on OS distribution - Returns 'ubuntu' for Ubuntu/Debian systems with libcrypt.so.1 - Returns 'rhel' for RHEL/AlmaLinux/Rocky systems with libcrypt.so.2 + Returns 'ubuntu' for Ubuntu/Debian systems + Returns 'rhel8' for RHEL/AlmaLinux/Rocky 8.x systems + Returns 'rhel9' for RHEL/AlmaLinux/Rocky 9.x systems """ try: - # Check if we're on RHEL/CentOS/AlmaLinux 8+ (uses libcrypt.so.2) + # Check if we're on RHEL/CentOS/AlmaLinux (check version) if os.path.exists('/etc/os-release'): with open('/etc/os-release', 'r') as f: os_release = f.read().lower() - # AlmaLinux 9+, Rocky 9+, RHEL 9+, CentOS Stream 9+ - if any(x in os_release for x in ['almalinux', 'rocky', 'rhel']) and 'version="9' in os_release: - return 'rhel' - elif 'centos stream 9' in os_release: - return 'rhel' + # Check for RHEL-based distributions + if any(x in os_release for x in ['almalinux', 'rocky', 'rhel', 'centos stream']): + # Extract version number + for line in os_release.split('\n'): + if 'version_id' in line: + version = line.split('=')[1].strip('"').split('.')[0] + if version == '9': + return 'rhel9' + elif version == '8': + return 'rhel8' - # Check CentOS/RHEL path + # Check CentOS/RHEL path (legacy method) if os.path.exists(Upgrade.CentOSPath): data = open(Upgrade.CentOSPath, 'r').read() - # CentOS/AlmaLinux/Rocky 8+ → rhel suffix - if 'release 8' in data or 'release 9' in data: - return 'rhel' + if 'release 9' in data: + return 'rhel9' + elif 'release 8' in data: + return 'rhel8' # CentOS 7 → ubuntu suffix (uses libcrypt.so.1) else: return 'ubuntu' - # OpenEuler → rhel suffix + # OpenEuler → rhel9 suffix (assuming latest version) if os.path.exists(Upgrade.openEulerPath): - return 'rhel' + return 'rhel9' # Ubuntu/Debian → ubuntu suffix (default for unknown) return 'ubuntu' @@ -788,10 +795,20 @@ class Upgrade: binary_suffix = Upgrade.detectBinarySuffix() Upgrade.stdOut(f"Detected OS type: using '{binary_suffix}' binaries", 0) - # URLs for custom binaries with OS-specific suffix - BASE_URL = "https://cyberpanel.net" - OLS_BINARY_URL = f"{BASE_URL}/openlitespeed-phpconfig-x86_64-{binary_suffix}" - MODULE_URL = f"{BASE_URL}/cyberpanel_ols_x86_64_{binary_suffix}.so" + # URLs for custom binaries with OS-specific paths + BASE_URL = "https://cyberpanel.net/binaries" + + # Set URLs based on OS type + if binary_suffix == 'rhel8': + OLS_BINARY_URL = f"{BASE_URL}/rhel8/openlitespeed-phpconfig-x86_64-rhel8" + MODULE_URL = f"{BASE_URL}/rhel8/cyberpanel_ols_x86_64_rhel8.so" + elif binary_suffix == 'rhel9': + OLS_BINARY_URL = f"{BASE_URL}/rhel9/openlitespeed-phpconfig-x86_64" + MODULE_URL = f"{BASE_URL}/rhel9/cyberpanel_ols_x86_64.so" + else: # ubuntu + OLS_BINARY_URL = f"{BASE_URL}/ubuntu/openlitespeed-phpconfig-x86_64-ubuntu" + MODULE_URL = f"{BASE_URL}/ubuntu/cyberpanel_ols_x86_64_ubuntu.so" + OLS_BINARY_PATH = "/usr/local/lsws/bin/openlitespeed" MODULE_PATH = "/usr/local/lsws/modules/cyberpanel_ols.so" @@ -915,13 +932,18 @@ class Upgrade: # Detect OS and select appropriate ModSecurity binary binary_suffix = Upgrade.detectBinarySuffix() + BASE_URL = "https://cyberpanel.net/binaries" - if binary_suffix == 'rhel': - MODSEC_URL = "https://cyberpanel.net/mod_security-compatible-rhel.so" + if binary_suffix == 'rhel8': + MODSEC_URL = f"{BASE_URL}/rhel8/mod_security-compatible-rhel8.so" + EXPECTED_SHA256 = "8c769dfb42711851ec539e9b6ea649616c14b0e85a53eb18755d200ce29bc442" + EXPECTED_MD5 = "b7b9eb20de42b7f8c9c8f4c7a019d6ff" + elif binary_suffix == 'rhel9': + MODSEC_URL = f"{BASE_URL}/rhel9/mod_security-compatible-rhel.so" EXPECTED_SHA256 = "db580afc431fda40d46bdae2249ac74690d9175ff6d8b1843f2837d86f8d602f" EXPECTED_MD5 = "1efa1e442fe8eedf4705584ac194fc95" else: # ubuntu - MODSEC_URL = "https://cyberpanel.net/mod_security-compatible-ubuntu.so" + MODSEC_URL = f"{BASE_URL}/ubuntu/mod_security-compatible-ubuntu.so" EXPECTED_SHA256 = "115971fcd44b74bc7c7b097b9cec33ddcfb0fb07bb9b562ec9f4f0691c388a6b" EXPECTED_MD5 = "c3987c41182355c1290530b6553658db"