From 0c07293d1adae7b6604789cbd23c578bcfc4d335 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Sat, 14 Feb 2026 00:43:30 +0500 Subject: [PATCH] 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. --- install/installCyberPanel.py | 10 ++++++---- plogical/upgrade.py | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 88e0138b7..3ce5598a4 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -501,15 +501,17 @@ module cyberpanel_ols { # Enable Auto-SSL in httpd_config.conf try: + import re conf_path = '/usr/local/lsws/conf/httpd_config.conf' if os.path.exists(conf_path): with open(conf_path, 'r') as f: content = f.read() if 'autoSSL' not in content: - content = content.replace( - 'adminEmails root@localhost', - 'adminEmails root@localhost\nautoSSL 1\nacmeEmail admin@cyberpanel.net', - 1 + content = re.sub( + r'(adminEmails\s+\S+)', + r'\1\nautoSSL 1\nacmeEmail admin@cyberpanel.net', + content, + count=1 ) with open(conf_path, 'w') as f: f.write(content) diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 551e74eb6..88b2f5f39 100644 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -4598,13 +4598,15 @@ pm.max_spare_servers = 3 # Enable Auto-SSL if not already configured conf_path = '/usr/local/lsws/conf/httpd_config.conf' try: + import re with open(conf_path, 'r') as f: content = f.read() if 'autoSSL' not in content: - content = content.replace( - 'adminEmails root@localhost', - 'adminEmails root@localhost\nautoSSL 1\nacmeEmail admin@cyberpanel.net', - 1 + content = re.sub( + r'(adminEmails\s+\S+)', + r'\1\nautoSSL 1\nacmeEmail admin@cyberpanel.net', + content, + count=1 ) with open(conf_path, 'w') as f: f.write(content)