From 09eac4de1c20728d7a3cff8700cf79aa9c9d8fce Mon Sep 17 00:00:00 2001 From: usmannasir Date: Sun, 31 Aug 2025 19:55:56 +0500 Subject: [PATCH] bug fix: snappymail on ubuntu 24 --- cyberpanel_upgrade.sh | 7 ++++--- install/install.py | 18 ++++++++---------- mailServer/mailserverManager.py | 7 ++----- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/cyberpanel_upgrade.sh b/cyberpanel_upgrade.sh index 95cc929b9..77ca25454 100644 --- a/cyberpanel_upgrade.sh +++ b/cyberpanel_upgrade.sh @@ -1378,9 +1378,10 @@ echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Set SnappyMail data directory permission # Ensure web server users are in the lscpd group for access usermod -a -G lscpd nobody 2>/dev/null || true -usermod -a -G lscpd www-data 2>/dev/null || true -usermod -a -G lscpd systemd-network 2>/dev/null || true -echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Added web server users to lscpd group" | tee -a /var/log/cyberpanel_upgrade_debug.log + +# Fix SnappyMail public directory ownership (critical fix) +chown -R lscpd:lscpd /usr/local/CyberCP/public/snappymail/data 2>/dev/null || true +echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Added web server users to lscpd group and fixed SnappyMail ownership" | tee -a /var/log/cyberpanel_upgrade_debug.log systemctl restart lscpd diff --git a/install/install.py b/install/install.py index dc73fc6a5..e1f417ff3 100644 --- a/install/install.py +++ b/install/install.py @@ -825,6 +825,10 @@ password="%s" command = "usermod -a -G lscpd nobody 2>/dev/null || true" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + # Fix SnappyMail public directory ownership early + command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/snappymail/data 2>/dev/null || true" + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + snappymailinipath = '/usr/local/lscp/cyberpanel/snappymail/data/_data_/_default_/configs/application.ini' command = 'chmod 600 /usr/local/CyberCP/public/snappymail.php' @@ -1460,11 +1464,8 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; command = "usermod -a -G lscpd nobody 2>/dev/null || true" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - command = "usermod -a -G lscpd www-data 2>/dev/null || true" - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - - # Additional fix for Ubuntu 24.04: ensure systemd user has access - command = "usermod -a -G lscpd systemd-network 2>/dev/null || true" + # Fix SnappyMail public directory ownership immediately after creation + command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/snappymail/data 2>/dev/null || true" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) command = "mkdir -p /usr/local/lscp/cyberpanel/rainloop/data" @@ -2919,11 +2920,8 @@ echo $oConfig->Save() ? 'Done' : 'Error'; command = "usermod -a -G lscpd nobody 2>/dev/null || true" subprocess.call(shlex.split(command)) - command = "usermod -a -G lscpd www-data 2>/dev/null || true" - subprocess.call(shlex.split(command)) - - # Additional fix for Ubuntu 24.04: ensure systemd user has access - command = "usermod -a -G lscpd systemd-network 2>/dev/null || true" + # Fix SnappyMail public directory ownership (critical fix) + command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/snappymail/data 2>/dev/null || true" subprocess.call(shlex.split(command)) except: pass diff --git a/mailServer/mailserverManager.py b/mailServer/mailserverManager.py index 101d147c9..0b367ae19 100644 --- a/mailServer/mailserverManager.py +++ b/mailServer/mailserverManager.py @@ -1573,11 +1573,8 @@ milter_default_action = accept command = "usermod -a -G lscpd nobody 2>/dev/null || true" ProcessUtilities.executioner(command) - command = "usermod -a -G lscpd www-data 2>/dev/null || true" - ProcessUtilities.executioner(command) - - # Additional fix for Ubuntu 24.04: ensure systemd user has access - command = "usermod -a -G lscpd systemd-network 2>/dev/null || true" + # Fix SnappyMail public directory ownership (critical fix) + command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/snappymail/data 2>/dev/null || true" ProcessUtilities.executioner(command) command = "chmod 700 /usr/local/CyberCP/cli/cyberPanel.py"