diff --git a/emailPremium/views.py b/emailPremium/views.py index 566ef17d6..734a45dac 100755 --- a/emailPremium/views.py +++ b/emailPremium/views.py @@ -1450,15 +1450,12 @@ def fetchRspamdSettings(request): postdata = ProcessUtilities.outputExecutioner(command).splitlines() for i in postdata: if i.find('smtpd_milters=') > -1 and i.find('non_smtpd_milters') < 0: - tempData = i.split(' ') - x = tempData[0] - y = x.split('=') - smtpd_milters = y[1] + ### non_smtpd_milters = inet:127.0.0.1:8891, inet:127.0.0.1:11332 + tempData = i.split(',') + smtpd_milters = tempData[1].lstrip(' ') if i.find('non_smtpd_milters=') > -1: - tempData = i.split(' ') - x = tempData[0] - y = x.split('=') - non_smtpd_milters = y[1] + tempData = i.split('=') + non_smtpd_milters = tempData[1].lstrip(' ') ###Redis Redispath = "/etc/rspamd/local.d/redis.conf" diff --git a/plogical/mailUtilities.py b/plogical/mailUtilities.py index 08da0dc2c..c98d4b00b 100755 --- a/plogical/mailUtilities.py +++ b/plogical/mailUtilities.py @@ -716,8 +716,6 @@ def installRspamd(install, rspamd): WriteToFile.close() - - appendpath = "/etc/postfix/main.cf" lines = open(appendpath, 'r').readlines() @@ -728,6 +726,7 @@ def installRspamd(install, rspamd): if line.find('inet:127.0.0.1:8891') > -1: cLine = line content = f'{cLine}, inet:127.0.0.1:11332\n' + WriteToFile.write('### Please do not edit this line, editing this line could break configurations\n') WriteToFile.write(content) elif line.find('non_smtpd_milters') > -1: WriteToFile.write('non_smtpd_milters = $smtpd_milters\n') @@ -1030,11 +1029,11 @@ def changePostfixConfig(install , changePostfixConfig): writeDataToFile = open(postfixpath, "w") for i in data: if i.find('smtpd_milters=') > -1 and i.find('non_smtpd_milters') < 0: - newitem = 'smtpd_milters=%s' % smtpd_milters + newitem = f'non_smtpd_milters = inet:127.0.0.1:8891, {smtpd_milters}\n' writeDataToFile.writelines(newitem + '\n') elif i.find('non_smtpd_milters=') > -1: - newitem = 'non_smtpd_milters=%s' % non_smtpd_milters - writeDataToFile.writelines(newitem + '\n') + #newitem = 'non_smtpd_milters=%s' % non_smtpd_milters + writeDataToFile.writelines('non_smtpd_milters = $smtpd_milters\n') else: writeDataToFile.writelines(i + '\n') diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 907c1c376..af5e89baa 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -2250,6 +2250,55 @@ def installLSCPD(branch): except BaseException as msg: Upgrade.stdOut(str(msg) + " [installLSCPD]") + ### disable dkim signing in rspamd in ref to https://github.com/usmannasir/cyberpanel/issues/1176 + @staticmethod + def FixRSPAMDConfig(): + RSPAMDConf = '/etc/rspamd' + postfixConf = '/etc/postfix/main.cf' + + if os.path.exists(RSPAMDConf): + DKIMPath = '/etc/rspamd/local.d/dkim_signing.conf' + + WriteToFile = open(DKIMPath, 'w') + WriteToFile.write('enabled = false;\n') + WriteToFile.close() + + + if os.path.exists(postfixConf): + appendpath = "/etc/postfix/main.cf" + + lines = open(appendpath, 'r').readlines() + + WriteToFile = open(appendpath, 'w') + + for line in lines: + + if line.find('smtpd_milters') > -1: + continue + elif line.find('non_smtpd_milters') > -1: + continue + elif line.find('milter_default_action') > -1: + continue + else: + WriteToFile.write(line) + + + RSPAMDConfContent = ''' +### Please do not edit this line, editing this line could break configurations +smtpd_milters = inet:127.0.0.1:8891, inet:127.0.0.1:11332 +non_smtpd_milters = $smtpd_milters +milter_default_action = accept +''' + WriteToFile.write(RSPAMDConfContent) + + WriteToFile.close() + + command = 'systemctl restart postfix && systemctl restart rspamd' + Upgrade.executioner(command, 'postfix and rspamd restart', 0, True) + + + + @staticmethod def fixPermissions(): try: