Commit Graph

109 Commits

Author SHA1 Message Date
usmannasir
a9f5decf9d Merge branch 'v2.4.5' into stable 2026-03-06 19:19:16 +05:00
usmannasir
cc9d830507 Fix SMTP relay on AlmaLinux/RHEL: install cyrus-sasl-plain package
Postfix SASL PLAIN auth fails with "No worthy mechs found" on
RHEL/AlmaLinux because cyrus-sasl-plain is not installed by default.
- Add cyrus-sasl-plain to postfix install in install.py
- Auto-install in configureRelayHost() for existing servers
- Add to upgrade.py setupSieve() for existing installations
2026-03-06 18:36:41 +05:00
usmannasir
1e6e60a0e9 Revert webmail.conf ownership to cyberpanel:cyberpanel
CyberPanel Python app runs as cyberpanel user (lscpd is just the web
server). The webmail.conf must be readable by cyberpanel, not lscpd.
2026-03-06 16:29:34 +05:00
usmannasir
7fe521e1b3 Fix webmail.conf ownership: use lscpd:lscpd instead of cyberpanel:cyberpanel
lscpd worker runs as user lscpd, not cyberpanel. The webmail.conf file
(containing master user credentials) was unreadable by lscpd, causing
master auth to silently fail and fall back to empty password auth.
Also fix ownership on existing installs during upgrade.
2026-03-06 16:24:42 +05:00
usmannasir
1d33ba0107 Improve Sieve: folder dropdown in rules UI, INBOX. prefix fix, robust upgrade regexes
- Replace free text input with folder dropdown for move-to-folder rules
- Auto-prefix INBOX. namespace to folder names in sieve scripts
- Strip INBOX. prefix when parsing sieve scripts back to rules
- Make upgrade setupSieve() regexes more flexible to handle config variations
- Add os.makedirs for conf.d directory in both install and upgrade
- Validate ManageSieve config with both inet_listener and service checks
2026-03-06 03:50:03 +05:00
usmannasir
3a0729156a Fix Sieve storage: add home dir to user_query, sieve plugin paths, and mailbox autocreate
- Add home directory (CONCAT) to dovecot-sql.conf.ext user_query so sieve
  can locate script storage per user
- Add sieve/sieve_dir plugin settings to dovecot.conf templates
- Add lda_mailbox_autocreate/autosubscribe so fileinto creates missing folders
- Update setupSieve() upgrade function to patch all three on existing installs
2026-03-06 03:39:04 +05:00
usmannasir
008cc7da0e Enable Sieve email filtering in install and upgrade for all OS
- Add sieve to dovecot protocols in both dovecot.conf templates
- Add sieve plugin to LDA mail_plugins in dovecot.conf templates
- Write ManageSieve config (20-managesieve.conf) during installSieve()
- Add setupSieve() upgrade function: patches dovecot.conf, installs
  packages (dovecot-sieve/managesieved on Ubuntu, pigeonhole on CentOS),
  writes ManageSieve config, opens firewall port 4190, restarts dovecot
- Call setupSieve() in main upgrade flow
2026-03-06 03:32:04 +05:00
usmannasir
1e00f6eff5 Add CyberMail Email Delivery integration
- New emailDelivery Django app with full platform API integration
- Account connection, domain management, SMTP credentials, relay config
- Auto-configure SPF/DKIM/DMARC DNS records via PowerDNS
- Postfix SMTP relay through CyberMail (configureRelayHost/removeRelayHost)
- Real-time delivery logs, stats, and per-domain analytics
- Single-page AngularJS dashboard with marketing landing page
- Promotional banners on 6 email-related pages with dismiss cookie
- Manual SQL table creation in upgrade.py for existing installs
- Documentation: setup guide, technical reference, user guide
2026-03-06 00:19:53 +05:00
usmannasir
7e86659a55 Fix missing mail TLS certs: copy self-signed certs to /etc/pki/dovecot/ at install and upgrade
On Ubuntu, the install creates /etc/pki/dovecot/ directories but never
populates them with certs. Postfix main.cf references these paths for
STARTTLS. Without them, inbound STARTTLS fails and external mail servers
(Gmail etc.) drop the connection, preventing mail delivery.
2026-03-05 05:54:09 +05:00
usmannasir
632dc3fbe9 Fix critical webmail bugs: XSS, SSRF, install ordering, and UI issues
Security fixes:
- Escape plain text body to prevent XSS via trustAsHtml
- Add SSRF protection to image proxy (block private IPs, require auth)
- Sanitize Content-Disposition filename to prevent header injection
- Escape Sieve script values to prevent script injection
- Escape IMAP search query to prevent search injection

Install/upgrade fixes:
- Move setupWebmail() call to after Dovecot is installed (was running
  before doveadm existed, silently failing on every fresh install)
- Make setupWebmail() a static method callable from install.py
- Fix upgrade idempotency: always run dovecot.conf patching and
  migrations even if webmail.conf already exists (partial failure recovery)

Frontend fixes:
- Fix search being a no-op (was ignoring results and just reloading)
- Fix loading spinner stuck forever on API errors (add errback)
- Fix unread count decrementing on already-read messages
- Fix draft auto-save timer leak when navigating away from compose
- Fix composeToContact missing signature and auto-save
- Fix null subject crash in reply/forward
- Clear stale data when switching accounts
- Fix attachment part_id mismatch between parser and downloader

Backend fixes:
- Fix Sieve _read_response infinite loop on connection drop
- Add login check to apiSaveDraft
2026-03-05 05:10:14 +05:00
usmannasir
6a61e294a9 Fix webmail account switcher and improve error handling
- Fix apiSSO() resetting selected account to first one on every call,
  now preserves previously selected account if still valid
- Fix webmail.conf ownership to use cyberpanel:cyberpanel (Django runs
  as cyberpanel user, not nobody)
- Add error notifications when SSO or folder loading fails
2026-03-05 05:01:45 +05:00
usmannasir
fd7960f790 Automate Dovecot master user setup for webmail SSO in install and upgrade
Adds master passdb config to dovecot.conf templates, setupWebmail() to
the installer and upgrade paths to generate credentials and create
/etc/dovecot/master-users and /etc/cyberpanel/webmail.conf automatically.
The upgrade path is idempotent and patches existing dovecot.conf if needed.
2026-03-05 03:39:00 +05:00
usmannasir
39baa9b05e Update cyberpanel_ols module hashes for SIGSEGV crash fix
Rebuilt module fixes NULL pointer dereference in apply_headers() when
OLS generates error responses (4xx/5xx). The get_req_var_by_id() call
for DOC_ROOT crashed because request variables aren't initialized
during error response generation. Fix adds status code guard to skip
header processing for error responses.
2026-03-04 16:46:21 +05:00
usmannasir
050425c019 Update OLS binary hashes for SSL listener auto-map fix
rhel9:  418d2ea06e29c0f847a2e6cf01f7641d5fb72b65a04e27a8f6b3b54d673cc2df
ubuntu: 60edf815379c32705540ad4525ea6d07c0390cabca232b6be12376ee538f4b1b
rhel8:  d08512da7a77468c09d6161de858db60bcc29aed7ce0abf76dca1c72104dc485
2026-02-14 02:22:03 +05:00
usmannasir
78650a6d60 Update OLS binary hashes for SSL listener auto-map fix
New hashes for all 3 platforms after fixing the bug where VHosts with
SSL context but missing listener map entries served the wrong cert.

rhel9:  04921afbad94e7ee69bc93a73985e318df93f28b2b0d578447b0ef43dc6e3818
ubuntu: ae2564742f362d3e34ea814dff37edeb8f8b73ae9ca1484ba78e2453a3987429
rhel8:  855b6bccb4a7893914506a07185cffd834bd31a7f7c080b5b4190283def7fa3e
2026-02-14 01:18:18 +05:00
usmannasir
0c07293d1a Use regex for Auto-SSL config injection to handle any adminEmails value
The previous string replace only matched 'adminEmails               root@localhost'
exactly. On fresh OLS installs where adminEmails may have a different value
or different spacing, the replace would silently fail and Auto-SSL config
would never be injected. Use re.sub to match the adminEmails line regardless
of its value.
2026-02-14 00:43:30 +05:00
usmannasir
cedbbd27e8 Fix Auto-SSL config injection appending garbage to acmeEmail line
The string replace matched only 'adminEmails' keyword instead of the
full existing line 'adminEmails               root@localhost', causing
the remaining '               root@localhost' to trail onto the acmeEmail
line and break ACME account registration.
2026-02-14 00:16:34 +05:00
usmannasir
aed1f29eb1 Update OLS binary hashes for Ubuntu/RHEL8 and enable Auto-SSL support 2026-02-13 14:47:22 +04:00
usmannasir
6aea18c808 Merge v2.4.4 into stable 2026-02-13 14:14:15 +04:00
usmannasir
5f3b6253a9 Update OLS binary hashes for all 3 platforms (Plesk test verified) 2026-02-13 13:54:25 +04:00
usmannasir
9f244ffca8 Update RHEL 9 OLS binary hash after default VHost wildcard rebuild 2026-02-13 03:10:23 +05:00
usmannasir
fb31c7686c Update OLS binary hashes for Ubuntu and RHEL 8 (default VHost wildcard fix) 2026-02-13 02:59:08 +05:00
usmannasir
dfef3acaac Update OLS binary SHA256 hashes for rebuilt v2.4.4 binaries 2026-02-12 16:07:27 +05:00
usmannasir
7c35b292ad Update OLS binary URLs and hashes to v2.4.4
Universal binaries with all features config-driven (PHPConfig API, Origin
Header Forwarding, ReadApacheConf with Portmap, Auto-SSL ACME v2,
ModSecurity ABI compatibility). Updates install, upgrade, and modSec paths.
2026-02-12 14:08:29 +05:00
usmannasir
06f1f78598 update OLS module to v2.2.0 with progressive throttle
- Update module checksums for all platforms (rhel8, rhel9, ubuntu)
- Simplify module URLs to cyberpanel_ols.so
- Fixed BruteForceAllowedAttempts parsing
- Implemented progressive throttle (2s/5s/15s delays)
2025-12-28 15:24:04 +05:00
usmannasir
30e4d2d28b update OLS module checksums for Phase 2 Brute Force Protection
- Update cyberpanel_ols module URLs to use /binaries/ path structure
- Update SHA256 checksums for all platforms (rhel8, rhel9, ubuntu)
- Enable RHEL 8 module support (was previously disabled)
- Module version 2.2.0 with Phase 2 features
2025-12-28 02:49:41 +05:00
usmannasir
3fc1aba229 fix: update custom OLS binaries and add ModSecurity compatibility
- Update SHA256 checksums for December 2025 OLS build (v1.8.4.1)
- Add RHEL8 module support (cyberpanel_ols_x86_64_rhel8.so)
- Add compatible ModSecurity binaries to prevent ABI crashes
- Auto-detect and replace ModSecurity when custom OLS is installed
- Add auto-rollback feature if new binary fails to start
- Fix OWASP CRS UI toggle detection with multi-location checks

Features included in new binaries:
- PHPConfig support (.htaccess php_value/php_flag)
- Origin header forwarding (CORS/WebSocket support)
- Header unset fix (uses remove_resp_header API)
- Static linking for cross-platform compatibility

Platforms supported:
- Ubuntu 22.04+/Debian 12+ (ubuntu-static)
- AlmaLinux/Rocky/RHEL 9.x (rhel9-static)
- AlmaLinux/Rocky/RHEL 8.x (rhel8-static)
2025-12-27 21:07:16 +05:00
usmannasir
0a099b1b19 Merge branch 'v2.4.4' of github.com:usmannasir/cyberpanel into v2.4.4 2025-12-18 13:10:48 +05:00
usmannasir
94bf2bdeef Merge branch 'v2.4.4' into v2.4.4-dev 2025-12-18 12:18:37 +05:00
usmannasir
eca0c3cbeb security fixes 2025-12-18 12:18:32 +05:00
usmannasir
a2f9cf99eb Fix ACL child domain permission issues for non-admin users
- Fix checkOwnership() to return explicit 0 instead of None when checking child domain ownership
  This resolves permission failures for non-admin ACL users trying to manage child domains

- Improve fetchChildDomainsMain() with more robust child domain filtering
  Changed from .filter(alais=0) to .all() with explicit check to prevent silent failures

- Add error logging with traceback to fetchChildDomainsMain() for better debugging

These changes allow non-admin users with proper ACL permissions to view and manage
child domains for websites they own.
2025-12-14 17:59:19 +04:00
usmannasir
ea635b5f01 Fix n8n container health check to use fuzzy name matching
The container health check was failing because Docker Compose v1 and v2
use different naming conventions:
- v1: project_service_1 (underscores)
- v2: project-service-1 (hyphens)

Changes:
1. Replaced hardcoded container name formatting with fuzzy matching
2. Added find_container_by_service() helper method for dynamic lookup
3. Updated monitor_deployment() to use dynamic container discovery
4. Container names are now found by normalizing and matching patterns

This fixes "Containers failed to reach healthy state" errors during
n8n deployment from CyberPanel UI.

Ticket References: XKTFREZUR, XCGF2HQUH
2025-11-29 04:56:23 +04:00
usmannasir
36f7068e1d Fix: Use upgrade.py for email filtering tables instead of Django migrations
- Remove Django migration file that caused model resolution errors
- Add CREATE TABLE statements to mailServerMigrations() in upgrade.py
- Tables created: e_catchall, e_server_settings, e_plus_override, e_pattern_forwarding
2025-11-28 15:08:49 +05:00
usmannasir
d3621923e5 Fix n8n v1.87.0+ compatibility with OpenLiteSpeed reverse proxy
1. Set NODE_ENV=development for n8n Docker deployments to resolve Origin
   header validation failures.

2. Remove ineffective "RequestHeader set Origin" from vhost configuration
   since OpenLiteSpeed cannot override browser Origin headers anyway.

This is required due to an OpenLiteSpeed architectural limitation - OLS
cannot override browser Origin headers, which n8n v1.87.0+ strictly
validates in production mode. Apache and Nginx can override Origin headers
and work in production mode, but this is not possible with OpenLiteSpeed.

Security Note: This change does NOT reduce security:
- User authentication remains enforced
- Password hashing (bcrypt/argon2) still secure
- HTTPS encryption still active
- Session management secure with N8N_SECURE_COOKIE=true
- CSRF protection still active

Only the origin validation check is bypassed, which fails anyway due to
the OLS limitation.

Ticket References: XKTFREZUR, XCGF2HQUH
2025-11-28 14:16:46 +05:00
usmannasir
ae020ece7b Fix OWASP CRS UI toggle state issues and improve installation reliability
This commit resolves issues where the OWASP CRS toggle in ModSecurity settings
would appear to flip back to OFF even when installation succeeded, and improves
detection of manually installed OWASP CRS rules.

Issues Fixed:
1. Toggle not updating immediately after installation/uninstallation
2. Manual OWASP installations to rules.conf not detected by toggle
3. Silent installation failures without detailed error logging

Changes:

firewall/static/firewall/firewall.js:
- Update toggle state immediately after successful installation (getOWASPAndComodoStatus(true))
- Update toggle state after failed installation to show correct OFF state
- Provides instant visual feedback instead of requiring page refresh

firewall/firewallManager.py (getOWASPAndComodoStatus):
- Expand detection logic to check both httpd_config.conf AND rules.conf
- Detect manual OWASP installations (Include/modsecurity_rules_file with owasp/crs-setup)
- Case-insensitive pattern matching for better compatibility

plogical/modSec.py (setupOWASPRules):
- Add specific error logging for each installation step failure
- Log detailed messages: directory creation, download, extraction, configuration
- Helps diagnose: network issues, missing tools (wget/unzip), permission problems

Impact:
- Toggle correctly reflects OWASP CRS state after enable/disable operations
- Manual installations following external tutorials now detected correctly
- Installation failures are logged with specific error messages for debugging
- Improves UX by eliminating perception that "toggle keeps flipping back"

Fixes: OWASP CRS toggle UI bug
Related: Community thread https://community.cyberpanel.net/t/4-mod-security-rules-packages/133/8
Related: Ticket #GTPDPO7EV
2025-11-24 01:53:36 +05:00
usmannasir
836a6e26a7 Fix custom installation email components bug: Skip email operations when services not installed
This commit resolves the issue where CyberPanel attempts to configure email/DKIM settings
even when email services were explicitly disabled during custom installation, causing
hostname SSL setup and website creation to fail with "No such file or directory: '/etc/postfix/main.cf'" errors.

Changes:
- Added emailServicesInstalled() utility function to check for /home/cyberpanel/postfix marker
- OnBoardingHostName(): Wrap email operations (issueSSLForMailServer, postfix commands) with checks
- OnBoardingHostName(): Allow hostname setup to complete without email services
- issueSSLForMailServer(): Add early return if email services not installed
- issueSSLForMailServer(): Verify /etc/postfix directory exists before operations
- issueSSLForMailServer(): Check /etc/postfix/main.cf exists before reading
- setupAutoDiscover(): Add early return if email services not installed
- setupAutoDiscover(): Check /etc/postfix/main.cf exists before accessing
- mailUtilities.configureOpenDKIM(): Verify main.cf exists before configuration

Impact:
- Hostname SSL setup now completes successfully without email components
- Website creation works correctly on custom installs without email
- No more file not found errors for /etc/postfix/main.cf
- Graceful degradation: operations skip email setup with log messages

Fixes: Custom installation hostname SSL 404 error
Fixes: Website creation DKIM failure on custom installs
Related: Ticket #RMKRFFGKC
2025-11-22 03:49:07 +05:00
usmannasir
bbd0c4e136 Update OpenLiteSpeed custom binaries to v2.0.5 static builds
Updates binary checksums and URLs for OpenLiteSpeed custom builds with
static linking support. Static-linked binaries provide cross-platform
compatibility (Ubuntu 22/24, RHEL 8/9) by embedding libstdc++ and libgcc,
eliminating version-specific crashes.

Changes:
- Updated all SHA256 checksums for static binary builds
- Simplified URLs: removed /binaries/ subdirectory path
- Added -static suffix to binary filenames
- Added conditional module installation (RHEL 8 has no module)
- Updated version references from v2.0.4 to v2.0.5
- Enhanced installation messages to indicate static linking

Binary checksums (v2.0.5):
- Ubuntu static: 89aaf66474e78cb3c1666784e0e7a417550bd317e6ab148201bdc318d36710cb
- RHEL 9 static: 90468fb38767505185013024678d9144ae13100d2355097657f58719d98fbbc4
- RHEL 8 static: 6ce688a237615102cc1603ee1999b3cede0ff3482d31e1f65705e92396d34b3a
- Ubuntu module: e7734f1e6226c2a0a8e00c1f6534ea9f577df9081b046736a774b1c52c28e7e5
- RHEL 9 module: 127227db81bcbebf80b225fc747b69cfcd4ad2f01cea486aa02d5c9ba6c18109

Benefits:
- Cross-platform compatibility across OS versions
- Automatic checksum verification for security
- Graceful handling of platform-specific limitations
- Simplified download URLs for easier maintenance

Files modified:
- install/installCyberPanel.py
- plogical/upgrade.py
2025-11-18 14:02:39 +05:00
usmannasir
e1eefebbfb Add platform-specific OpenLiteSpeed binaries with SHA256 checksum verification
This update adds automatic platform detection and checksum verification for
OpenLiteSpeed custom binaries during installation and upgrade.

Changes:
- Add detectPlatform() method to detect RHEL 8, RHEL 9, and Ubuntu
- Update binary URLs to use platform-specific paths:
  * RHEL 8: /binaries/rhel8/
  * RHEL 9: /binaries/rhel9/
  * Ubuntu: /binaries/ubuntu/
- Add SHA256 checksum verification to downloadCustomBinary()
- Update installCustomOLSBinaries() to use platform-specific checksums

Binary Versions (OpenLiteSpeed v1.8.4.1 - Module v2.0.4):
- RHEL 8 Module: 1cc71f54d8ae5937d0bd2b2dd27678b47f09f4f7afed2583bbd3493ddd05877f
- RHEL 9 Module: 127227db81bcbebf80b225fc747b69cfcd4ad2f01cea486aa02d5c9ba6c18109
- Ubuntu Module: d070952fcfe27fac2f2c95db9ae31252071bade2cdcff19cf3b3f7812fa9413a
- All Binary: a6e07671ee1c9bcc7f2d12de9e95139315cf288709fb23bf431eb417299ad4e9

Files modified:
- install/installCyberPanel.py
- plogical/upgrade.py
2025-11-17 00:42:28 +05:00
usmannasir
4650fa2623 Add verification and retry logic for lssetup configuration
- Verify lscgctl works after running lssetup
- Retry with more slices (-c 10) if first attempt fails
- Add detailed logging to debug setup issues
- Add time.sleep() to give lssetup time to initialize
- Provide clear error messages if setup fails
2025-11-13 00:25:45 +05:00
usmannasir
888a7e0552 Add I/O limit support to resource limits
- Pass --io parameter to lscgctl with bytes/sec value
- Convert ioLimitMBPS from MB/s to bytes/s for lscgctl
- Update log message to include I/O limit information
- Add note about systemd io controller delegation requirement
2025-11-12 23:43:59 +05:00
usmannasir
94969f4e97 Improve lssetup auto-detection for LiteSpeed Containers
- Add test to verify LiteSpeed Containers is actually configured
- Check for 'You must configure LiteSpeed' error in lscgctl output
- Run lssetup with proper flags when configuration is needed
- Fixes issue where lscgctl exists but LiteSpeed Containers not configured
2025-11-11 22:36:15 +05:00
usmannasir
6d66e5739a Add RHEL 8 family cgroups v2 detection and enablement instructions
Detect RHEL 8, AlmaLinux 8, Rocky Linux 8, and CloudLinux 8 systems and provide
clear instructions when cgroups v2 needs manual enablement.

These systems have cgroups v2 backported to kernel 4.18 but it's disabled by
default. When detected without cgroups v2 enabled, the system now:

1. Detects RHEL 8 family by checking /etc/redhat-release
2. Verifies if cgroups v2 is mounted (checks 'mount' output for 'cgroup2')
3. If not enabled, logs detailed instructions:
   - grubby command to add kernel parameter
   - Reboot instruction
   - Verification command
   - Clear step-by-step guide

Changes:
- _check_rhel8_cgroups_v2(): New method for RHEL 8 family detection
- _ensure_cgroups_enabled(): Calls RHEL 8 check before general checks
- check_cgroup_support(): Returns RHEL 8 status in support dict
  - rhel8_family: bool (detected RHEL 8 family)
  - rhel8_needs_enablement: bool (cgroups v2 not mounted)
  - os_name: str (full OS name from release file)

OS Support Status:
 Ubuntu 20.04+ - Native cgroups v2 (kernel 5.4+)
 RHEL/Alma/Rocky 9+ - Native cgroups v2 (kernel 5.14+)
⚠️ RHEL/Alma/Rocky/CloudLinux 8 - Needs manual enable (kernel 4.18 backported)
2025-11-11 17:27:11 +05:00
usmannasir
e61236c8a2 Add resource limits columns to upgrade script
Add database migrations for 7 new resource limit fields in packages_package table
to support users upgrading from older CyberPanel versions:
- memoryLimitMB (default: 1024)
- cpuCores (default: 1)
- ioLimitMBPS (default: 10)
- inodeLimit (default: 400000)
- maxConnections (default: 10)
- procSoftLimit (default: 400)
- procHardLimit (default: 500)

These columns are automatically added during upgrade via CLMigrations() function.
Uses try/except to safely handle cases where columns already exist.
2025-11-11 17:23:05 +05:00
usmannasir
c679d6ab10 Add comprehensive resource limits with automatic OpenLiteSpeed cgroups setup
This commit implements per-package resource limits for CyberPanel shared hosting
using OpenLiteSpeed's native cgroups v2 integration with automatic server configuration.

Features:
- 7 new package fields: memoryLimitMB, cpuCores, ioLimitMBPS, inodeLimit,
  maxConnections, procSoftLimit, procHardLimit
- Automatic OLS cgroups setup (no manual server configuration required)
- Multi-layer enforcement: OLS config + kernel cgroups v2 + filesystem quotas
- Per-user enforcement (subdomains/addon domains share parent's limits)
- Graceful degradation if cgroups unavailable
- Automatic backup of OLS config before modification

Backend Changes:
- packages/models.py: Added 7 resource limit fields with defaults
- packages/packagesManager.py: CRUD operations for resource limits
- plogical/resourceLimits.py: NEW - Resource manager with auto-setup
  * _ensure_cgroups_enabled(): Automatic OLS cgroups configuration
  * set_user_limits(): Apply limits via lscgctl
  * remove_user_limits(): Cleanup on deletion
  * set_inode_limit(): Filesystem quota management
- plogical/vhostConfs.py: Parameterized hardcoded resource limits
- plogical/vhost.py: Updated signatures to accept resource limits
- plogical/virtualHostUtilities.py: Extract and apply package limits


Frontend Changes:
- packages/templates/packages/createPackage.html: Resource limits UI
- packages/templates/packages/modifyPackage.html: Resource limits UI
- packages/static/packages/packages.js: AngularJS controller updates

Automatic Setup Flow:
When creating a website with enforceDiskLimits=True:
1. Check kernel cgroups v2 support
2. Run lssetup if lscgctl missing
3. Enable cgroups in OLS config if needed
4. Backup and modify /usr/local/lsws/conf/httpd_config.conf
5. Graceful restart of OpenLiteSpeed
6. Apply per-user limits via lscgctl
7. Set inode quotas via setquota

Requirements:
- Linux kernel 5.2+ (cgroups v2)
- OpenLiteSpeed 1.8+ (with lsns support)
- quota tools (optional, for inode limits)

Backward Compatibility:
- Existing packages receive default values via migration
- No manual setup required for new installations
- Graceful fallback if cgroups unavailable
2025-11-11 17:14:39 +05:00
usmannasir
2e8d9d5e8e conflict fix 2025-11-09 19:34:57 +05:00
usmannasir
6b999e5c8b Fix RHEL 9 binary filenames to match server structure
RHEL 9 binaries use '-rhel' suffix instead of '-rhel9':
- openlitespeed-phpconfig-x86_64-rhel (not rhel9)
- cyberpanel_ols_x86_64_rhel.so (not rhel9.so)

Updated URLs in install and upgrade modules to use correct filenames.
2025-11-09 17:14:47 +05:00
usmannasir
7c6ce4cd72 Fix OS detection to prioritize Ubuntu/Debian check
Ubuntu systems were incorrectly being detected as rhel9. Added explicit
Ubuntu/Debian check at the beginning of detectBinarySuffix() before
checking for RHEL-based distributions.

This ensures Ubuntu and Debian systems are properly identified and use
the correct binaries from the ubuntu/ directory instead of rhel9/.
2025-11-09 17:12:23 +05:00
usmannasir
20254f467c 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.
2025-11-09 12:10:43 +05:00
usmannasir
2a20d1ef12 Add ModSecurity compatibility detection for user installations
Handle the scenario where users install ModSecurity after CyberPanel is already
installed with custom OpenLiteSpeed binaries.

Problem:
- When users click "Install ModSecurity" in CyberPanel UI, the system used
  package manager (yum/apt) to install stock ModSecurity
- Stock ModSecurity is NOT ABI-compatible with custom OLS binaries
- This causes immediate server crashes (segfaults) when installed

Solution:
- Detect if custom OLS binary is already installed before installing ModSecurity
- If custom OLS detected, download compatible ModSecurity from cyberpanel.net
- If stock OLS detected, use package manager as usual

Implementation:
- isCustomOLSBinaryInstalled(): Detects custom OLS by scanning binary for markers
- detectBinarySuffix(): Determines Ubuntu vs RHEL binaries needed
- installCompatibleModSecurity(): Downloads, verifies, and installs compatible ModSecurity
- Modified installModSec(): Main entry point - routes to compatible installer if needed

User flow:
1. User with custom OLS clicks "Install ModSecurity" in UI
2. System detects custom OLS binary is installed
3. System writes "Detected custom OpenLiteSpeed binary" to install log
4. System downloads OS-specific compatible ModSecurity from cyberpanel.net
5. System verifies SHA256 checksum
6. System backs up any existing ModSecurity
7. System installs compatible version with OLS restart
8. User sees "ModSecurity Installed (ABI-compatible version).[200]"

Safety features:
- Checksum verification before installation
- Automatic backup of existing ModSecurity
- Graceful OLS restart with timeout handling
- Detailed logging to /home/cyberpanel/modSecInstallLog

This prevents server crashes when users install ModSecurity after custom OLS
binaries are already deployed.
2025-11-08 15:28:34 +05:00
usmannasir
44bc736ee7 Add ModSecurity compatibility handling for custom OLS binaries
Implement automatic detection and update of ModSecurity when upgrading to custom OpenLiteSpeed binaries.

Problem:
- Stock ModSecurity modules are NOT ABI-compatible with custom OLS binaries
- Using stock ModSecurity with custom OLS causes server crashes (segfaults)
- Custom OLS has different memory layout and function signatures
- ModSecurity must be rebuilt against custom OLS headers

Solution:
- Detect if custom OLS binary is installed (check for PHPConfig markers)
- Detect if ModSecurity is currently installed
- Automatically download and install ABI-compatible ModSecurity
- Verify checksums before installation
- Backup existing ModSecurity before replacing

Implementation:
- isCustomOLSBinaryInstalled(): Detects custom OLS by scanning binary for markers
- installCompatibleModSecurity(): Downloads OS-specific compatible ModSecurity
- handleModSecurityCompatibility(): Orchestrates the compatibility check and update
- Integrated into upgrade process after custom binary installation

Binary URLs:
- RHEL/AlmaLinux: https://cyberpanel.net/mod_security-compatible-rhel.so
- Ubuntu/Debian: https://cyberpanel.net/mod_security-compatible-ubuntu.so

Checksums:
- RHEL SHA256: db580afc431fda40d46bdae2249ac74690d9175ff6d8b1843f2837d86f8d602f
- Ubuntu SHA256: 115971fcd44b74bc7c7b097b9cec33ddcfb0fb07bb9b562ec9f4f0691c388a6b

Safety features:
- Checksum verification before installation
- Automatic backup of existing ModSecurity
- Graceful OLS restart with timeout handling
- Non-fatal errors allow upgrade to continue

This prevents server crashes for existing CyberPanel users who have ModSecurity
installed when they upgrade to custom OpenLiteSpeed binaries.
2025-11-08 15:23:59 +05:00