1

I'm trying to get dovecot-antispam working with SpamAssassin' sa-learn. This is my Dovecot configuration:

antispam_backend = pipe
antispam_trash = trash;Trash;Deleted Items; Deleted Messages
antispam_spam = Junk
antispam_pipe_program_spam_arg = --spam
antispam_pipe_program_notspam_arg = --ham
antispam_pipe_program = /usr/bin/sa-learn
antispam_pipe_tmpdir = /tmp

However, I can't seem to get it working. When I try to move a false-negative from/to my Junk folder in my MUA I get the following error:

[SERVERBUG] Failed to send mail

This is what gets logged by dovecot-antispam:

imap: antispam: mail copy: src spam: 1, dst spam: 0, src unsure: 0
imap: antispam: running mailtrain backend program /usr/bin/sa-learn
imap: antispam: running mailtrain backend program /usr/bin/sa-learn
imap: antispam: running mailtrain backend program parameter 1 --ham
imap: antispam: run program failed with exit code 2

So apparently, sa-learn exits with code 2. However, I don't know what that means. sa-learn's documentation doesn't mention anything about exit codes, so I don't know where I should start to debug this.

Compizfox
  • 375
  • 1
  • 6
  • 17
  • 1
    Have a look at my question on the same subject at http://serverfault.com/questions/627931/enabling-bayesian-filter-with-amavisd-new-spamassassin. I asked the question last year, but just answered my own question two days ago. – David W Jul 02 '15 at 17:01
  • @DavidW I'm sorry, but my question doesn't appear in your question/answer anywhere. – Compizfox Jul 02 '15 at 17:38

1 Answers1

3

When you move message, then dovecot invoke the sa-learn with dovecot's UID, so sa-learn hasn't enough permissions to update bayesian databases.

You have to add dovecot's user to the spamd group and ensure you have the next line

bayes_file_mode 0660

in the etc/spamassassin/local.cf file.

Also you have to verify is bayes databases already have permissions 0660. Then restart spamassassin.

Kondybas
  • 6,864
  • 2
  • 19
  • 24
  • Thanks. I added the `vmail` user (that's the user my dovecot is running at) to the `debian-spamd` group. My `local.cf` now reads: `bayes_file_mode 0660 bayes_path /var/spamassassin/bayes_db/bayes` However, that directory is still empty. It still doesn't work, but I get another exit code now: `imap: antispam: run program failed with exit code 13`. It doesn't really help that I don't know what those error codes mean. – Compizfox Jul 02 '15 at 17:40
  • It's fixed: I changed the permissions of the `bayes_db` directory to 777 (for testing purposes) and now it's working! The user/group the files are written by are vmail:mail. – Compizfox Jul 02 '15 at 20:07