From fe0a86238b59ebd5d1295649e4820413cff1325e Mon Sep 17 00:00:00 2001 From: usmannasir Date: Fri, 20 Mar 2026 16:01:22 +0500 Subject: [PATCH] Fix Dovecot hard restart killing active IMAP/POP3 connections Replace 'systemctl restart dovecot' with 'doveadm reload' in virtualHostUtilities, mailUtilities, and renew modules. The nightly backup scheduler, SSL operations, and weekly cert renewal were forcefully terminating all client sessions. doveadm reload applies config changes (including updated SSL certs) without dropping existing connections. upgrade.py is intentionally left unchanged as full restarts are appropriate during upgrades. --- plogical/mailUtilities.py | 6 +++--- plogical/renew.py | 2 +- plogical/virtualHostUtilities.py | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plogical/mailUtilities.py b/plogical/mailUtilities.py index 878ca4521..cbb734ee2 100644 --- a/plogical/mailUtilities.py +++ b/plogical/mailUtilities.py @@ -690,7 +690,7 @@ milter_default_action = accept command = 'systemctl restart postfix' subprocess.call(shlex.split(command)) - command = 'systemctl restart dovecot' + command = 'doveadm reload' subprocess.call(shlex.split(command)) except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [restartServices]") @@ -2368,7 +2368,7 @@ class MailServerManagerUtils(multi.Thread): writeToFile.writelines(items) writeToFile.close() - command = "systemctl restart dovecot" + command = "doveadm reload" ProcessUtilities.executioner(command) ## For ubuntu 20 @@ -2720,7 +2720,7 @@ class MailServerManagerUtils(multi.Thread): command = 'systemctl restart postfix' ProcessUtilities.executioner(command) - command = 'systemctl restart dovecot' + command = 'doveadm reload' ProcessUtilities.executioner(command) logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Completed [200].') diff --git a/plogical/renew.py b/plogical/renew.py index d46214f6f..65d6bf2c3 100644 --- a/plogical/renew.py +++ b/plogical/renew.py @@ -81,7 +81,7 @@ class Renew: commands = [ 'postmap -F hash:/etc/postfix/vmail_ssl.map', 'systemctl restart postfix', - 'systemctl restart dovecot', + 'doveadm reload', 'systemctl restart lscpd' ] diff --git a/plogical/virtualHostUtilities.py b/plogical/virtualHostUtilities.py index 12e2af6d7..f8bee2b36 100644 --- a/plogical/virtualHostUtilities.py +++ b/plogical/virtualHostUtilities.py @@ -248,7 +248,7 @@ class virtualHostUtilities: logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, message) logging.CyberCPLogFileWriter.writeToFile(message) - command = 'postmap -F hash:/etc/postfix/vmail_ssl.map && systemctl restart postfix && systemctl restart dovecot' + command = 'postmap -F hash:/etc/postfix/vmail_ssl.map && systemctl restart postfix && doveadm reload' ProcessUtilities.executioner(command, 'root', True) logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Completed. [200]') else: @@ -444,7 +444,7 @@ class virtualHostUtilities: admin.config = json.dumps(config) admin.save() # First update the postfix hash database, then restart services - command = 'postmap -F hash:/etc/postfix/vmail_ssl.map && systemctl restart postfix && systemctl restart dovecot' + command = 'postmap -F hash:/etc/postfix/vmail_ssl.map && systemctl restart postfix && doveadm reload' ProcessUtilities.executioner(command, 'root', True) logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Completed. [200]') else: @@ -500,7 +500,7 @@ local_name %s { writeToFile.close() - command = 'systemctl restart dovecot' + command = 'doveadm reload' ProcessUtilities.executioner(command) ### Update postfix configurations @@ -559,7 +559,7 @@ local_name %s { writeToFile.write(content) writeToFile.close() - command = 'systemctl restart dovecot' + command = 'doveadm reload' ProcessUtilities.executioner(command) ### Update postfix configurations @@ -860,7 +860,7 @@ local_name %s { command = 'systemctl restart postfix' ProcessUtilities.executioner(command) - command = 'systemctl restart dovecot' + command = 'doveadm reload' ProcessUtilities.executioner(command) print("1,None") @@ -891,7 +891,7 @@ local_name %s { command = 'systemctl restart postfix' ProcessUtilities.executioner(command) - command = 'systemctl restart dovecot' + command = 'doveadm reload' ProcessUtilities.executioner(command) print(f"1,{str(retValues[1])}")