Skip to content

Commit

Permalink
bug fix rspamd + dkim #1176
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Jan 13, 2024
1 parent e8ca16f commit 509eae5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 13 deletions.
13 changes: 5 additions & 8 deletions emailPremium/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 4 additions & 5 deletions plogical/mailUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,6 @@ def installRspamd(install, rspamd):
WriteToFile.close()




appendpath = "/etc/postfix/main.cf"

lines = open(appendpath, 'r').readlines()
Expand All @@ -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')
Expand Down Expand Up @@ -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')

Expand Down
49 changes: 49 additions & 0 deletions plogical/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 509eae5

Please sign in to comment.