email: Make rspamd learn spam/ham when the user marks mails as junk or not junk.

Add two sieve scripts for spam/ham learning. When the user moves a mail
from anywhere to junk, or from junk to anywhere (except for trash) the
mail is piped into the respective rspamc learn_spam/learn_ham command.
The rspamc command is run as the mail user and the command requires that
the user can connect to localhost:11334. Because of that, add the mail
user to the allowed users that can access protected services.

The sievec compilation of the new scripts requre the dovecot-antispam
package, so install it and increment the email version number.

Closes: #2487
Imroves: #56

Tests done:
1. Apply the patches on an existing install
2. Confirm the firewall and the email app get updated
3. Move a mail from inbox to junk and confirm that rspamd statistics for
   "Learned" mails increment by one.
4. Move back the mail from junk to inbox and confirm the number
   increments again.
5. Move the mail to trash and confirm the script doesn't execute.
6. Repeat steps 3-5 with mail_debug = yes in /etc/dovecot/dovecot.conf
   and confirm the script esxecution further by reading the debug logs.

[Sunil]

- Split the configuration file 90-freedombox-sieve.conf into
90-freedombox-imap.conf and merge the remaining with 95-freedombox-sieve.conf.

- These changes do not need dovecot-anitspam package. Remove it from packages
list for the app.

Signed-off-by: Benedek Nagy <contact@nbenedek.me>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Benedek Nagy authored and Sunil Mohan Adapa committed 2025-01-23 15:36:32 -08:00
1 parent 861796d21b
commit 00a4ff3b41
8 files changed
+46 -8

No files matched your search

+1 -1
View File
@@ -49,7 +49,7 @@ class FirewallApp(app_module.App):
app_id = 'firewall'
_version = 4
_version = 5
can_be_disabled = False
+1 -1
View File
@@ -111,7 +111,7 @@ def _setup_local_service_protection():
for permanent in [[], ['--permanent']]:
for ip_type in ['ipv4', 'ipv6']:
for owner_type in ['--uid-owner', '--gid-owner']:
for user_group in ['root', 'www-data']:
for user_group in ['root', 'www-data', 'mail']:
_add_rule(permanent, ip_type, '-A', 'OUTPUT', '-m',
'owner', owner_type, user_group, '-j', 'MARK',
'--or-mark', '0x800000')