Re: Replacing antispam plugin with IMAPSieve not 100% correct?

2022-10-04 Thread hi

On 2022-09-25 14:35, Christian Kivalo wrote:
On September 25, 2022 1:27:23 PM GMT+02:00, Marc 
 wrote:


I think this page[1] is not correct

If you configure this option:

imapsieve_mailbox1_before = 
file:/usr/lib/dovecot/sieve/report-spam.sieve


the file report-spam.svbin cannot be created because users cannot 
write there.
You have to pre-compile all sieve before/global/after scripts with 
sievec
See the end of this section 
https://doc.dovecot.org/configuration_manual/sieve/configuration/#executing-multiple-scripts-sequentially



[1]
https://doc.dovecot.org/configuration_manual/howto/antispam_with_sieve/#howto-antispam-with-imapsieve




I was wondering how you will be able to use sieve in filtering spam?


Re: Replacing antispam plugin with IMAPSieve not 100% correct?

2022-09-25 Thread Christian Kivalo



On September 25, 2022 1:27:23 PM GMT+02:00, Marc  wrote:
>
>I think this page[1] is not correct 
>
>If you configure this option:
>
>imapsieve_mailbox1_before = file:/usr/lib/dovecot/sieve/report-spam.sieve
>
>the file report-spam.svbin cannot be created because users cannot write there.
You have to pre-compile all sieve before/global/after scripts with sievec
See the end of this section 
https://doc.dovecot.org/configuration_manual/sieve/configuration/#executing-multiple-scripts-sequentially
>
>
>[1]
>https://doc.dovecot.org/configuration_manual/howto/antispam_with_sieve/#howto-antispam-with-imapsieve
>
>

-- 
Christian Kivalo


Replacing antispam plugin with IMAPSieve not 100% correct?

2022-09-25 Thread Marc

I think this page[1] is not correct 

If you configure this option:

imapsieve_mailbox1_before = file:/usr/lib/dovecot/sieve/report-spam.sieve

the file report-spam.svbin cannot be created because users cannot write there.




[1]
https://doc.dovecot.org/configuration_manual/howto/antispam_with_sieve/#howto-antispam-with-imapsieve




Re: Antispam plugin

2021-01-17 Thread Håkon Alstadheim



Den 17.01.2021 02:15, skrev Toni Mueller:

Hi,

On Tue, Sep 22, 2020 at 02:01:21PM +0300, Aki Tuomi wrote:

You don't need antispam plugin:

https://doc.dovecot.org/configuration_manual/howto/antispam_with_sieve/

I also don't see any docs about the plugin on the wiki.
Does it mean that this plugin is deprecated?

The link describes how the functionality of the antispam plugin is no 
longer needed, you can set up antispam with built-in functionality of 
dovecot.





Re: Antispam plugin

2021-01-16 Thread Toni Mueller


Hi,

On Tue, Sep 22, 2020 at 02:01:21PM +0300, Aki Tuomi wrote:
> You don't need antispam plugin:
> 
> https://doc.dovecot.org/configuration_manual/howto/antispam_with_sieve/

I also don't see any docs about the plugin on the wiki.
Does it mean that this plugin is deprecated?


Thanks,
Toni



antispam plugin again

2020-10-23 Thread Maciej Milaszewski
Hello
I have a problem with migrating dovecot from 2.2.36 to 2.3.8 -
everything works fine, but a problem with migrating anti-spam plugins

New dovecot 2.3.x has implemented own antispam-plugin like:

 new from dovecot 2.3.8 -
# From elsewhere to Spam folder
  imapsieve_mailbox1_name = Spam
  imapsieve_mailbox1_causes = COPY
  imapsieve_mailbox1_before =
file:/usr/lib64/dovecot/sieve/report-spam.sieve

  # From Spam folder to elsewhere
  imapsieve_mailbox2_name = *
  imapsieve_mailbox2_from = Spam
  imapsieve_mailbox2_causes = COPY
  imapsieve_mailbox2_before = file:/usr/lib64/dovecot/sieve/report-ham.sieve

  sieve_pipe_bin_dir = /usr/lib64/dovecot/sieve

  sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment

  #setting_name = value
  sieve_global_dir = /etc/sieve_global
  sieve_max_redirects = 20
  sieve_vacation_use_original_recipient = yes

  expire = SPAM
  #expire_dict = proxy::expire
  expire_dict = redis:host=127.0.0.1:prefix=expire/
---


In older version dovecot I use antispam_plugin + simple script:

 old from 2.2.36.4 + antispam plugin --
 ...
 antispam_backend = MAILTRAIN
  antispam_mail_spam = --spam
  antispam_mail_notspam = --ham
  antispam_mail_sendmail = /usr/local/bin/spam-learn.sh
  antispam_pipe_tmpdir = /tmp

  antispam_spam_pattern_ignorecase = spam;inbox.spam;Unwanted
  antispam_trash_pattern_ignorecase = trash;Deleted *;Junk*;kosz

  antispam_debug_target = syslog
  antispam_verbose_debug = 1
-

How do I change the bash file to make it work like on the old system (I
use pyzor) like:

cat /usr/local/bin/spam-learn.sh

#!/bin/sh
date >> /tmp/spam.txt
echo $@ >> /tmp/spam.txt

if [ "x$1" = "x--spam" ]; then
    /usr/bin/pyzor report >> /tmp/spam.txt 2>&1
fi
if [ "x$1" = "x--ham" ]; then
    /usr/bin/pyzor whitelist >> /tmp/ham.txt 2>&1
fi




Re: Antispam plugin

2020-09-22 Thread Aki Tuomi


On 22.9.2020 13.59, Maciej Milaszewski wrote:
> Hi
> System centos8 + dovecot-2.3.8 from repo
>
> # 2.3.8 (9df20d2db): /etc/dovecot/dovecot.conf
> # Pigeonhole version 0.5.8 (b7b03ba2)
> # OS: Linux 4.18.0-193.19.1.el8_2.x86_64 x86_64 CentOS Linux release
> 8.2.2004 (Core)
>
>  I need "Antispam plugin". What antispam-plugin I must use ?
>
> In older version dovecot-2.2.36.4 i use "dovecot-antispam-plugin" but in
> centos I had a problem with configure  - probably toold wersion
>
> "./configure: line 3193: DC_DOVECOT: command not found"
>
> In wiki dovect is "antispam-plugin" I try this
> http://hg.dovecot.org/dovecot-antispam-plugin
> but get 404
>
> Backand spamassassin
>
You don't need antispam plugin:

https://doc.dovecot.org/configuration_manual/howto/antispam_with_sieve/

Aki



Antispam plugin

2020-09-22 Thread Maciej Milaszewski
Hi
System centos8 + dovecot-2.3.8 from repo

# 2.3.8 (9df20d2db): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.8 (b7b03ba2)
# OS: Linux 4.18.0-193.19.1.el8_2.x86_64 x86_64 CentOS Linux release
8.2.2004 (Core)

 I need "Antispam plugin". What antispam-plugin I must use ?

In older version dovecot-2.2.36.4 i use "dovecot-antispam-plugin" but in
centos I had a problem with configure  - probably toold wersion

"./configure: line 3193: DC_DOVECOT: command not found"

In wiki dovect is "antispam-plugin" I try this
http://hg.dovecot.org/dovecot-antispam-plugin
but get 404

Backand spamassassin



Re: Dovecot With DSpam AntiSpam Plugin Replacement With Sieve

2018-02-24 Thread Trever L. Adams
Thank you for this. I have a DSPAM setup that did work with the
suggested scrips, but I used the old dovecot antispam plugin and enjoyed
the signature method. I am going to try this out next week to see if it
works for me. If it does, I will love this.

Thanks again.
Trever

On 02/24/2018 02:02 PM, col...@nxtgn.com wrote:
> Hello
>
> I have recently had to rebuild my email server, it is a small server
> for my various email accounts and I also host the email for a clients
> business.
>
> Switched to Dovecot from Courier many years ago, and it has been a
> very reliable solution With the new rebuild I have updated it to
> Dovecot 2.2.33.2 with PigeonHole 4.21, it runs DSpam 3.10.2 to scan
> and tag all incoming mails as Spam or not then a Sieve rule to put the
> Spam emails into the Spam folder, I was also using the DSpam Antispam
> plugin to enable moving messages from one folder to another to teach
> failures to DSpam, this works well for my and my client.
>
> Doing the rebuild I saw that the AntiSpam plugin had been deprecated
> and the preferred solution now was to use Sieve Filters, so I
> implemented that and had struggled with it for a few hours until I
> finally got it working.
>
> It may be something about my setup but I am not sure it is, but the
> suggested way of doing it here
> https://wiki.dovecot.org/HowTo/AntispamWithSieve did not work for me
> and I don't think  it was ever going to.
>
> Here are the shell scripts and sieve filters that I came up with that
> work for me, your mileage may vary.
>
> I use DSpam as a standalone binary not as a daemon so you may need to
> add the --client option on the dspam command line in the shell scripts
> if you run DSpam in daemon mode.
>
> === report-spam.sieve ===
>
> require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment",
> "variables"];
>
>
> if environment :matches "imap.user" "*" {
>   set "userid" "${1}";
>   if header :matches "X-DSPAM-Signature" "*"
>   {
>    set "signature" "${1}";
>   }
> }
>
> pipe :copy "learn-spam.sh" [ "${userid}", "${signature}" ];
>
> === report-ham.sieve ===
>
> require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment",
> "variables"];
>
> if environment :matches "imap.mailbox" "*" {
>   set "mailbox" "${1}";
> }
>
> if string "${mailbox}" "Trash" {
>   stop;
> }
>
> if environment :matches "imap.user" "*" {
>   set "userid" "${1}";
>   if header :matches "X-DSPAM-Signature" "*"
>   {
>    set "signature" "${1}";
>   }
> }
>
> pipe :copy "learn-ham.sh" [ "${userid}", "${signature}" ];
>
> === learn-spam.sh ===
>
> #!/bin/sh
> exec /usr/local/bin/dspam --user ${1} --signature=${2} --class=spam
> --source=error
>
> === learn-ham.sh ===
>
> #!/bin/sh
> exec /usr/local/bin/dspam --user ${1} --signature=${2}
> --class=innocent --source=error
>
>
> I hope this saves someone some time or gives someone some tips
>




signature.asc
Description: OpenPGP digital signature


Dovecot With DSpam AntiSpam Plugin Replacement With Sieve

2018-02-24 Thread colinh

Hello

I have recently had to rebuild my email server, it is a small server for 
my various email accounts and I also host the email for a clients 
business.


Switched to Dovecot from Courier many years ago, and it has been a very 
reliable solution With the new rebuild I have updated it to Dovecot 
2.2.33.2 with PigeonHole 4.21, it runs DSpam 3.10.2 to scan and tag all 
incoming mails as Spam or not then a Sieve rule to put the Spam emails 
into the Spam folder, I was also using the DSpam Antispam plugin to 
enable moving messages from one folder to another to teach failures to 
DSpam, this works well for my and my client.


Doing the rebuild I saw that the AntiSpam plugin had been deprecated and 
the preferred solution now was to use Sieve Filters, so I implemented 
that and had struggled with it for a few hours until I finally got it 
working.


It may be something about my setup but I am not sure it is, but the 
suggested way of doing it here
https://wiki.dovecot.org/HowTo/AntispamWithSieve did not work for me and 
I don't think  it was ever going to.


Here are the shell scripts and sieve filters that I came up with that 
work for me, your mileage may vary.


I use DSpam as a standalone binary not as a daemon so you may need to 
add the --client option on the dspam command line in the shell scripts 
if you run DSpam in daemon mode.


=== report-spam.sieve ===

require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", 
"variables"];



if environment :matches "imap.user" "*" {
  set "userid" "${1}";
  if header :matches "X-DSPAM-Signature" "*"
  {
   set "signature" "${1}";
  }
}

pipe :copy "learn-spam.sh" [ "${userid}", "${signature}" ];

=== report-ham.sieve ===

require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", 
"variables"];


if environment :matches "imap.mailbox" "*" {
  set "mailbox" "${1}";
}

if string "${mailbox}" "Trash" {
  stop;
}

if environment :matches "imap.user" "*" {
  set "userid" "${1}";
  if header :matches "X-DSPAM-Signature" "*"
  {
   set "signature" "${1}";
  }
}

pipe :copy "learn-ham.sh" [ "${userid}", "${signature}" ];

=== learn-spam.sh ===

#!/bin/sh
exec /usr/local/bin/dspam --user ${1} --signature=${2} --class=spam 
--source=error


=== learn-ham.sh ===

#!/bin/sh
exec /usr/local/bin/dspam --user ${1} --signature=${2} --class=innocent 
--source=error



I hope this saves someone some time or gives someone some tips

--
Regards

Colin


Re: antispam plugin with IMAPSieve

2017-10-31 Thread Stephan Bosch

Op 31-10-2017 om 15:33 schreef j.emerlik:

Hi,
my dovecot is configured with IMAP Sieve antispam plugin (sa-learn),
everything seems to be working correctly but in debug mode in my log file I
noticed "dovecot: imap: Error".

Last 14 lines od my log file:
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.040 [10743]
dbg: bayes: tokenized header: 90 tokens
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.067 [10743]
dbg: bayes: seen (8e031cc9fec44b6607dc7f6b37903fc49e9c8526@sa_generated) put
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.067 [10743]
dbg: bayes: learned '8e031cc9fec44b6607dc7f6b37903fc49e9c8526@sa_generated',
atime: 1509457623
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.068 [10743]
dbg: plugin: Mail::SpamAssassin::Plugin::Bayes=HASH(0x2adc340) implements
'learner_close', priority 0
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.033 [10743]
dbg: bayes: using userid: 7
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.037 [10743]
dbg: bayes: tokenized body: 174 tokens
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.037 [10743]
dbg: bayes: tokenized uri: 0 tokens
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.037 [10743]
dbg: bayes: tokenized invisible: 0 tokens
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.040 [10743]
dbg: bayes: tokenized header: 90 tokens
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.067 [10743]
dbg: bayes: seen (8e031cc9fec44b6607dc7f6b37903fc49e9c8526@sa_generated) put
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.067 [10743]
dbg: bayes: learned '8e031cc9fec44b6607dc7f6b37903fc49e9c8526@sa_generated',
atime: 1509457623

Logs looks good and I don't understand "Error:" from log, It looks like
sa-learn is connected to database and learned bayes.

Error in log it's normal or It's means that it not work ?


Looks like something is sent to stderr from the shell script. Afaik, 
that ends up in error log.


Regards,

Stephan.


antispam plugin with IMAPSieve

2017-10-31 Thread j.emerlik
Hi,
my dovecot is configured with IMAP Sieve antispam plugin (sa-learn),
everything seems to be working correctly but in debug mode in my log file I
noticed "dovecot: imap: Error".

Last 14 lines od my log file:
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.040 [10743]
dbg: bayes: tokenized header: 90 tokens
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.067 [10743]
dbg: bayes: seen (8e031cc9fec44b6607dc7f6b37903fc49e9c8526@sa_generated) put
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.067 [10743]
dbg: bayes: learned '8e031cc9fec44b6607dc7f6b37903fc49e9c8526@sa_generated',
atime: 1509457623
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.068 [10743]
dbg: plugin: Mail::SpamAssassin::Plugin::Bayes=HASH(0x2adc340) implements
'learner_close', priority 0
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.033 [10743]
dbg: bayes: using userid: 7
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.037 [10743]
dbg: bayes: tokenized body: 174 tokens
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.037 [10743]
dbg: bayes: tokenized uri: 0 tokens
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.037 [10743]
dbg: bayes: tokenized invisible: 0 tokens
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.040 [10743]
dbg: bayes: tokenized header: 90 tokens
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.067 [10743]
dbg: bayes: seen (8e031cc9fec44b6607dc7f6b37903fc49e9c8526@sa_generated) put
Oct 31 15:05:25 mnode1 dovecot: imap: Error: Oct 31 15:05:25.067 [10743]
dbg: bayes: learned '8e031cc9fec44b6607dc7f6b37903fc49e9c8526@sa_generated',
atime: 1509457623

Logs looks good and I don't understand "Error:" from log, It looks like
sa-learn is connected to database and learned bayes.

Error in log it's normal or It's means that it not work ?

Regards,
Jack


Re: Replacement for antispam plugin

2017-03-01 Thread Tanstaafl
On Wed Mar 01 2017 03:11:48 GMT-0500 (Eastern Standard Time), Aki Tuomi
 wrote:
>> But, if the imapsieve is only matching to literal foldernames, should
>> I just duplicate the trigger lines for each type of junk folder or is
>> there a method to have the sieve script enumerate all the options
>> listed by 'special use'  or is there a better method for this? I want
>> to put the spam-mail-filing script as a global sieve script as all
>> users will need it, rather than duplicating out for each user.
>>
> There is no way to match special use folders at the moment, but I like
> the idea.

If by 'match' you mean, basically, a way to define aliases for different
special use folders to a single mailbox name, I suggested this a long
time ago, and love the idea.

Hopefully you'll at least add this to your official 'ToDo' (or 'maybe
ToDo' list?

:) Thanks


Re: Replacement for antispam plugin

2017-03-01 Thread Aki Tuomi
Some answers inline.

Aki


On 01.03.2017 00:42, Andy R wrote:
> Greetings to the list :)
>
>
> I've been meaning to ask a couple of questions about the imapsieve for
> antispam.
>
>
> Firstly, I guess that the example at the bottom of the page
> "https://wiki2.dovecot.org/Pigeonhole/Sieve/Plugins/IMAPSieve;  is
> meant to link to the new example at
> "https://wiki2.dovecot.org/HowTo/AntispamWithSieve; now?
>
Thanks, fixed.

>
> Also... in "imapsieve_mailboxX_name = ${directory}"  is the string a
> literal, or is it working with the 'special use' flagged directories
> from the xx-mailboxes.conf? I'm asking as though I only have a few
> users to worry about, different mail clients each have their favourite
> special folders. IE thunderbird uses "junk" but one Outlook express
> version likes "Junk E-mail" and I have a different favourite from
> another version of OE too. So in mailboxes.conf I just added extra
> special use lines which seemed to make things happy. Otherwise I ended
> up with the server configured 'spam' folder showing as basic folder,
> and then each client adding it's own chosen spamfolder each time too.
>

It is a mailbox mask, not special use flag.

>
> But, if the imapsieve is only matching to literal foldernames, should
> I just duplicate the trigger lines for each type of junk folder or is
> there a method to have the sieve script enumerate all the options
> listed by 'special use'  or is there a better method for this? I want
> to put the spam-mail-filing script as a global sieve script as all
> users will need it, rather than duplicating out for each user.
>

There is no way to match special use folders at the moment, but I like
the idea.

>
>
> Many thanks ,
>
>
> Andy R
>
>
> On 10/02/2017 09:06, Aki Tuomi wrote:
>> Hi!
>> Since antispam plugin is deprecated and we would really prefer people
>> not to use it, we wrote instructions on how to replace it with
>> IMAPSieve. Comments and suggestions are most welcome.
>>
>> https://wiki.dovecot.org/HowTo/AntispamWithSieve
>>
>> ---
>> Aki Tuomi
>> Dovecot oy
>>


Re: Replacement for antispam plugin

2017-02-28 Thread Andy R

Greetings to the list :)


I've been meaning to ask a couple of questions about the imapsieve for 
antispam.



Firstly, I guess that the example at the bottom of the page 
"https://wiki2.dovecot.org/Pigeonhole/Sieve/Plugins/IMAPSieve;  is meant 
to link to the new example at 
"https://wiki2.dovecot.org/HowTo/AntispamWithSieve; now?



Also... in "imapsieve_mailboxX_name = ${directory}"  is the string a 
literal, or is it working with the 'special use' flagged directories 
from the xx-mailboxes.conf? I'm asking as though I only have a few users 
to worry about, different mail clients each have their favourite special 
folders. IE thunderbird uses "junk" but one Outlook express version 
likes "Junk E-mail" and I have a different favourite from another 
version of OE too. So in mailboxes.conf I just added extra special use 
lines which seemed to make things happy. Otherwise I ended up with the 
server configured 'spam' folder showing as basic folder, and then each 
client adding it's own chosen spamfolder each time too.



But, if the imapsieve is only matching to literal foldernames, should I 
just duplicate the trigger lines for each type of junk folder or is 
there a method to have the sieve script enumerate all the options listed 
by 'special use'  or is there a better method for this? I want to put 
the spam-mail-filing script as a global sieve script as all users will 
need it, rather than duplicating out for each user.




Many thanks ,


Andy R


On 10/02/2017 09:06, Aki Tuomi wrote:

Hi!
Since antispam plugin is deprecated and we would really prefer people
not to use it, we wrote instructions on how to replace it with
IMAPSieve. Comments and suggestions are most welcome.

https://wiki.dovecot.org/HowTo/AntispamWithSieve

---
Aki Tuomi
Dovecot oy



Re: Replacement for antispam plugin

2017-02-27 Thread Jeff Kletsky

Glad I poked around on the list today!

Thanks to all for the suggestions about integration with dspam.

I'll definitely have to look into this, as I rely on moving messages
to a specific folder with various IMAP clients to retrain dspam false
positives and negatives.

A quick pair of questions:

* Does Dovecot support the IMAP "MOVE" command at this time?

* If so, what is the syntax for "COPY or MOVE" for the _causes variables?


I did see messages from 2011 discussing it, but nothing since.


While the script looks like it could be modified for use with dspam
(with the great suggestions from others on the list), it has the same
problem as "antispam" with bulk moves being serialized and tying of
the client until they complete.  I'll probably have to break down and
look into using FreeBSD's auditd to trigger the actions and then
de-queue the successfully processed messages.

Sieve doesn't look like it can handle asynchronous processing, but I'd
certainly be interested if I'm missing something there.  One less thing
to configure and maintain!



Jeff



On 2/12/17 5:52 AM, Aki Tuomi wrote:

On February 10, 2017 at 10:06 AM Aki Tuomi <aki.tu...@dovecot.fi> wrote:


Hi!
Since antispam plugin is deprecated and we would really prefer people
not to use it, we wrote instructions on how to replace it with
IMAPSieve. Comments and suggestions are most welcome.

https://wiki.dovecot.org/HowTo/AntispamWithSieve

---
Aki Tuomi
Dovecot oy

Hi everyone,

thank you all for your feedback, questions and comments. We have upgraded the 
documentation based on this, including information how to exclude Trash folder 
in ham script.

Aki



Re: Replacement for antispam plugin

2017-02-24 Thread Trever L. Adams
On 02/12/2017 05:28 PM, Stephan Bosch wrote:
>
> Actually, Pigeonhole should be able to do that too:
>
> https://github.com/dovecot/pigeonhole/blob/master/doc/plugins/sieve_extprograms.txt#L112
>
> Yes, I need to update the wiki.
>
>
> Regards,
>
> Stephan.
>
For DSPAM, with --client, one also needs a --user set.
http://hg.dovecot.org/dovecot-antispam-plugin/file/5ebc6aae4d7c/src/dspam.c
did this.

Is there a way to feed this into the scripts mentioned? I imagine this
is imap.user or imap.email, but how would one pass it to the script?

Thank you.

Trever




signature.asc
Description: OpenPGP digital signature


Re: Replacement for antispam plugin

2017-02-12 Thread Håkon Alstadheim


Den 12. feb. 2017 23:56, skrev Marcus Rueckert:
> On 2017-02-12 23:00:49 +0100, Håkon Alstadheim wrote:
>> Just follow the wiki and replace sa-learn scripts with calling dspam.
>> Dspam direct pipe needs mail-line-endings (\r\n) translated into unix
>> line-endings (\r).
I had a typo here, (\r\n) gets replaced by just (\n).

> 
> tbh ... what do you do about mails which just use \r as separator?
> 

You are mistaken.

Firstly: s/\r$// will remove \r from the end of any line, do nothing if
there is no \r.
Secondly: All line-endings as seen by transfer-agents is transferred
with the same line endings (MTA-MTA: \r\n; locally: usually the same but
may be different). "Line ending" here pertains to after each header, and
between message-parts. If there are naked (\n) characters in the message
body, that is of no concern. Point of filter is to make Dspam-signature
parseable for dspam. If there is an (\r) at the end of the header, Dspam
will not find a match, and be unable to reclassify the mail.

> s|\r\n|\n| is safer.
> 
> darix
> 
>> like so:
>>
>> - learn-spam.sh -
>> #!/bin/sh
>> sed -e 's/\r$//' | /usr/bin/dspam --source=error --class=spam
>>
>> - learn-ham.sh --
>> #!/bin/sh
>> sed -e 's/\r$//' | /usr/bin/dspam --source=error --class=innocent
>>
>> --
>>
>> Theese will be invoked with the owner of the mailbox as current uid, so
>> that is all.
> 


Re: Replacement for antispam plugin

2017-02-12 Thread Stephan Bosch
Op 2/12/2017 om 11:00 PM schreef Håkon Alstadheim:
>
> Den 12. feb. 2017 21:44, skrev ebr...@whitehorsetc.com:
>>
>> Any opinion on dspam's interoperability with this?
>>
>>
> Just follow the wiki and replace sa-learn scripts with calling dspam.
> Dspam direct pipe needs mail-line-endings (\r\n) translated into unix
> line-endings (\r).
>
> like so:
>
> - learn-spam.sh -
> #!/bin/sh
> sed -e 's/\r$//' | /usr/bin/dspam --source=error --class=spam
>
> - learn-ham.sh --
> #!/bin/sh
> sed -e 's/\r$//' | /usr/bin/dspam --source=error --class=innocent
>
> --
>
> Theese will be invoked with the owner of the mailbox as current uid, so
> that is all.

Actually, Pigeonhole should be able to do that too:

https://github.com/dovecot/pigeonhole/blob/master/doc/plugins/sieve_extprograms.txt#L112

Yes, I need to update the wiki.


Regards,

Stephan.


Re: Replacement for antispam plugin

2017-02-12 Thread Marcus Rueckert
On 2017-02-12 23:00:49 +0100, Håkon Alstadheim wrote:
> Just follow the wiki and replace sa-learn scripts with calling dspam.
> Dspam direct pipe needs mail-line-endings (\r\n) translated into unix
> line-endings (\r).

tbh ... what do you do about mails which just use \r as separator?

s|\r\n|\n| is safer.

darix

> like so:
> 
> - learn-spam.sh -
> #!/bin/sh
> sed -e 's/\r$//' | /usr/bin/dspam --source=error --class=spam
> 
> - learn-ham.sh --
> #!/bin/sh
> sed -e 's/\r$//' | /usr/bin/dspam --source=error --class=innocent
> 
> --
> 
> Theese will be invoked with the owner of the mailbox as current uid, so
> that is all.

-- 
   openSUSE - SUSE Linux is my linux
   openSUSE is good for you
   www.opensuse.org


Re: Replacement for antispam plugin

2017-02-12 Thread Håkon Alstadheim


Den 12. feb. 2017 21:44, skrev ebr...@whitehorsetc.com:
> 
> 
> Any opinion on dspam's interoperability with this?
> 
> 

Just follow the wiki and replace sa-learn scripts with calling dspam.
Dspam direct pipe needs mail-line-endings (\r\n) translated into unix
line-endings (\r).

like so:

- learn-spam.sh -
#!/bin/sh
sed -e 's/\r$//' | /usr/bin/dspam --source=error --class=spam

- learn-ham.sh --
#!/bin/sh
sed -e 's/\r$//' | /usr/bin/dspam --source=error --class=innocent

--

Theese will be invoked with the owner of the mailbox as current uid, so
that is all.


Re: Replacement for antispam plugin

2017-02-12 Thread Håkon Alstadheim


Den 12. feb. 2017 15:12, skrev Ralph Seichter:
> On 12.02.2017 13:25, Stephan Bosch wrote:
> 
>> The "imap.mailbox" environment is the empty string in this case. Why?
>> Well, the Sieve interpreter does not know about it, since the
>> "imapsieve" extension is not activated in the require line.
> 
> Now there's a facepalm moment. ;-) Thank you, with a modified 'require'
> statement things are working for me.
> 
> I see that https://wiki.dovecot.org/HowTo/AntispamWithSieve has already
> been updated, that's nice.

Tried to add a small variation for dSpam, but there is some anti-spam
functionality that I don't understand.

Mind putting this in after the sa-learn-ham.sh: ?
---
Or, if you are using dspam, (dropping 'sa-' as that would be misleading)

learn-spam.sh

{{{
#!/bin/sh

sed -e 's/\r$//' | /usr/bin/dspam --source=error --class=spam
}}}

learn-ham.sh

{{{
#!/bin/sh

sed -e 's/\r$//' | /usr/bin/dspam --debug --source=error --class=innocent
}}}

-

> 
>> You could debug this with the non-standard "vnd.dovecot.debug"
>> extension.
> 
> Thanks again, I will keep this in mind for future debugging.
> 
> -Ralph
> 


Re: Replacement for antispam plugin

2017-02-12 Thread ebroch


Any opinion on dspam's interoperability with this?




On Fri, Feb 10, 2017 at 1:07 AM -0700, "Aki Tuomi" <aki.tu...@dovecot.fi> wrote:










Hi!
Since antispam plugin is deprecated and we would really prefer people
not to use it, we wrote instructions on how to replace it with
IMAPSieve. Comments and suggestions are most welcome.

https://wiki.dovecot.org/HowTo/AntispamWithSieve

---
Aki Tuomi
Dovecot oy


Re: Replacement for antispam plugin

2017-02-12 Thread George Kontostanos
On Sun, Feb 12, 2017 at 8:56 PM, Stephan Bosch <step...@rename-it.nl> wrote:
> Op 2/12/2017 om 5:36 PM schreef George Kontostanos:
>> On Sun, Feb 12, 2017 at 3:52 PM, Aki Tuomi <aki.tu...@dovecot.fi> wrote:
>>
>>>> On February 10, 2017 at 10:06 AM Aki Tuomi <aki.tu...@dovecot.fi> wrote:
>>>>
>>>>
>>>> Hi!
>>>> Since antispam plugin is deprecated and we would really prefer people
>>>> not to use it, we wrote instructions on how to replace it with
>>>> IMAPSieve. Comments and suggestions are most welcome.
>>>>
>>>> https://wiki.dovecot.org/HowTo/AntispamWithSieve
>>>>
>>>> ---
>>>> Aki Tuomi
>>>> Dovecot oy
>>> Hi everyone,
>>>
>>> thank you all for your feedback, questions and comments. We have upgraded
>>> the documentation based on this, including information how to exclude Trash
>>> folder in ham script.
>>>
>>> Aki
>>>
>>
>> Thank you all very much. I am now running into a very weird issue. Whenever
>> an Junk email is “seen” I get the following error:
>>
>> Debug: sieve: vnd.dovecot.execute extension: no bin or socket directory
>> specified; extension is unconfigured (both sieve_execute_bin_dir and
>> sieve_execute_socket_dir are not set)
>> Feb 12 18:02:54 imap(user@domain): Debug: imapsieve: Static mailbox rule
>> [1]: mailbox=`Junk' from=`*' causes=(COPY) =>
>> before=`file:/usr/local/lib/dovecot/sieve/report-spam.sieve' after=(none)
>> Feb 12 18:02:54 imap(user@dmain): Debug: imapsieve: Static mailbox rule
>> [2]: mailbox=`*' from=`Junk' causes=(COPY) =>
>> before=`file:/usr/local/lib/dovecot/sieve/report-ham.sieve' after=(none)
>
> That is not an error. That is merely a debug message indicating that the
> vnd.dovecot.execute extension is unconfigured.
>
> Don't enable that extension if you're not using the "execute"
> command/test. Yes, it is in the example, but it has no function either.
> Only the vnd.dovecot.pipe extension is actually used ("pipe" command).
>
>> Also it automatically creates a .spamassassin/ folder in the user:
>>
>> -rw---  1 vmail  vmail136 Feb 10 17:33 .dovecot.lda-dupes
>> lrwx--  1 vmail  vmail 17 Mar 13  2016 .dovecot.sieve@ ->
>> managesieve.sieve
>> -rw---  1 vmail  vmail322 Feb 11 03:02 .dovecot.svbin
>> drwx--  2 vmail  vmail512 Feb 12 18:04 .spamassassin/
>> drwx--  5 vmail  vmail512 Feb 10 17:32 Drafts/
>> drwx--  5 vmail  vmail512 Feb 12 18:09 Junk/
>> drwx--  5 vmail  vmail512 Feb 11 17:36 Saved/
>> drwx--  5 vmail  vmail512 Jan 16 11:55 Sent/
>> drwx--  5 vmail  vmail512 Feb 12 18:09 Trash/
>> drwx--  2 vmail  vmail   1024 Feb 12 18:07 cur/
>> -rw---  1 vmail  vmail 21 Mar 13  2016 dovecot-acl-list
>> -rw---  1 vmail  vmail 68 Oct 17 13:19 dovecot-keywords
>> -rw---  1 vmail  vmail245 Feb 12 18:07 dovecot-uidlist
>> -rw---  1 vmail  vmail  8 Jun  9  2016 dovecot-uidvalidity
>> -r--r--r--  1 vmail  vmail  0 Mar 12  2016 dovecot-uidvalidity.56e48129
>> -rw---  1 vmail  vmail640 Feb 11 22:24 dovecot.index
>> -rw---  1 vmail  vmail  27788 Feb 12 18:07 dovecot.index.cache
>> -rw---  1 vmail  vmail  25996 Feb 12 18:07 dovecot.index.log
>> -rw---  1 vmail  vmail192 Feb 12 16:04 dovecot.mailbox.log
>> -rw---  1 vmail  vmail181 Feb 10 17:34 managesieve.sieve
>> drwx--  2 vmail  vmail512 Feb 12 17:46 new/
>> -rw---  1 vmail  vmail 39 Jun  9  2016 subscriptions
>> drwx--  2 vmail  vmail512 Feb 12 18:04 tmp/
>>
>> Any ideas ? I am attaching my config.
>
> The likely scenario is that the sa-learn tool is creating a hidden
> directory inside the $HOME directory of the user for user-specific state
> information. According to your mail_home and mail_location
> configuration, that is the same directory as the INBOX mailbox. That is
> why this may be interpreted as a mailbox by the maildir format. It is
> generally a bad idea to have those equal; you should put the mail
> location in a sub-directory of the home directory to prevent problems
> like this.
>
> https://wiki.dovecot.org/VirtualUsers/Home
>
> Regards,
>
> Stephan.
>
>
>
That makes perfect sense. I might need to find a way to migrate now to
the correct structure.

Thanks


-- 
George Kontostanos
---


Re: Replacement for antispam plugin

2017-02-12 Thread Ralph Seichter
On 12.02.17 19:05, George Kontostanos wrote:

> Actually I think that sa-learn is invoked as user vmail. But of course
> I might be wrong.

It might depend on system configuration. On my servers, Sieve scripts are
definitely executed as the OS user that matches the current IMAP user.

> Do you have any suggestions as per the way sa-learn should be executed?

Instead of calling sa-learn directly, I use a script to store the piped
raw message in the file system, using separate directories for ham and
spam. This way, there are no delays. A periodic Cron job, running as my
global SpamAssassin user, later collects the files and invokes sa-learn,
ensuring that sync operations only happen once per run.

-Ralph


Re: Replacement for antispam plugin

2017-02-12 Thread Stephan Bosch
Op 2/12/2017 om 5:36 PM schreef George Kontostanos:
> On Sun, Feb 12, 2017 at 3:52 PM, Aki Tuomi <aki.tu...@dovecot.fi> wrote:
>
>>> On February 10, 2017 at 10:06 AM Aki Tuomi <aki.tu...@dovecot.fi> wrote:
>>>
>>>
>>> Hi!
>>> Since antispam plugin is deprecated and we would really prefer people
>>> not to use it, we wrote instructions on how to replace it with
>>> IMAPSieve. Comments and suggestions are most welcome.
>>>
>>> https://wiki.dovecot.org/HowTo/AntispamWithSieve
>>>
>>> ---
>>> Aki Tuomi
>>> Dovecot oy
>> Hi everyone,
>>
>> thank you all for your feedback, questions and comments. We have upgraded
>> the documentation based on this, including information how to exclude Trash
>> folder in ham script.
>>
>> Aki
>>
>
> Thank you all very much. I am now running into a very weird issue. Whenever
> an Junk email is “seen” I get the following error:
>
> Debug: sieve: vnd.dovecot.execute extension: no bin or socket directory
> specified; extension is unconfigured (both sieve_execute_bin_dir and
> sieve_execute_socket_dir are not set)
> Feb 12 18:02:54 imap(user@domain): Debug: imapsieve: Static mailbox rule
> [1]: mailbox=`Junk' from=`*' causes=(COPY) =>
> before=`file:/usr/local/lib/dovecot/sieve/report-spam.sieve' after=(none)
> Feb 12 18:02:54 imap(user@dmain): Debug: imapsieve: Static mailbox rule
> [2]: mailbox=`*' from=`Junk' causes=(COPY) =>
> before=`file:/usr/local/lib/dovecot/sieve/report-ham.sieve' after=(none)

That is not an error. That is merely a debug message indicating that the
vnd.dovecot.execute extension is unconfigured.

Don't enable that extension if you're not using the "execute"
command/test. Yes, it is in the example, but it has no function either.
Only the vnd.dovecot.pipe extension is actually used ("pipe" command).

> Also it automatically creates a .spamassassin/ folder in the user:
>
> -rw---  1 vmail  vmail136 Feb 10 17:33 .dovecot.lda-dupes
> lrwx--  1 vmail  vmail 17 Mar 13  2016 .dovecot.sieve@ ->
> managesieve.sieve
> -rw---  1 vmail  vmail322 Feb 11 03:02 .dovecot.svbin
> drwx--  2 vmail  vmail512 Feb 12 18:04 .spamassassin/
> drwx--  5 vmail  vmail512 Feb 10 17:32 Drafts/
> drwx--  5 vmail  vmail512 Feb 12 18:09 Junk/
> drwx--  5 vmail  vmail512 Feb 11 17:36 Saved/
> drwx--  5 vmail  vmail512 Jan 16 11:55 Sent/
> drwx--  5 vmail  vmail512 Feb 12 18:09 Trash/
> drwx--  2 vmail  vmail   1024 Feb 12 18:07 cur/
> -rw---  1 vmail  vmail 21 Mar 13  2016 dovecot-acl-list
> -rw---  1 vmail  vmail 68 Oct 17 13:19 dovecot-keywords
> -rw---  1 vmail  vmail245 Feb 12 18:07 dovecot-uidlist
> -rw---  1 vmail  vmail  8 Jun  9  2016 dovecot-uidvalidity
> -r--r--r--  1 vmail  vmail  0 Mar 12  2016 dovecot-uidvalidity.56e48129
> -rw---  1 vmail  vmail640 Feb 11 22:24 dovecot.index
> -rw---  1 vmail  vmail  27788 Feb 12 18:07 dovecot.index.cache
> -rw---  1 vmail  vmail  25996 Feb 12 18:07 dovecot.index.log
> -rw---  1 vmail  vmail192 Feb 12 16:04 dovecot.mailbox.log
> -rw---  1 vmail  vmail181 Feb 10 17:34 managesieve.sieve
> drwx--  2 vmail  vmail512 Feb 12 17:46 new/
> -rw---  1 vmail  vmail 39 Jun  9  2016 subscriptions
> drwx--  2 vmail  vmail512 Feb 12 18:04 tmp/
>
> Any ideas ? I am attaching my config.

The likely scenario is that the sa-learn tool is creating a hidden
directory inside the $HOME directory of the user for user-specific state
information. According to your mail_home and mail_location
configuration, that is the same directory as the INBOX mailbox. That is
why this may be interpreted as a mailbox by the maildir format. It is
generally a bad idea to have those equal; you should put the mail
location in a sub-directory of the home directory to prevent problems
like this.

https://wiki.dovecot.org/VirtualUsers/Home

Regards,

Stephan.


Re: Replacement for antispam plugin

2017-02-12 Thread George Kontostanos
On Sun, Feb 12, 2017 at 7:52 PM, Ralph Seichter  wrote:
> On 12.02.2017 17:36, George Kontostanos wrote:
>
>> it automatically creates a .spamassassin/ folder in the user
>
> That happens because sa-learn is invoked as the user who is logged into
> IMAP. If you want all users to contribute to a global SpamAssassin
> database (like I do), you'll need to create your own learning mechanism
> instead of calling sa-learn directly.
>
> -Ralph

Actually I think that sa-learn is invoked as user vmail. But of course
I might be wrong.

sa-learn-ham.sh

LOG='/var/log/sa-learn.log'
exec /usr/local/bin/sa-learn --ham -D >> $LOG 2>&1

I had to give ownership to vmail to sa-learn.log otherwise it would
refuse to run.

Do you have any suggestions as per the way sa-learn should be executed?

Thanks for your help.

-- 
George Kontostanos
---


Re: Replacement for antispam plugin

2017-02-12 Thread Ralph Seichter
On 12.02.2017 17:36, George Kontostanos wrote:

> it automatically creates a .spamassassin/ folder in the user

That happens because sa-learn is invoked as the user who is logged into
IMAP. If you want all users to contribute to a global SpamAssassin
database (like I do), you'll need to create your own learning mechanism
instead of calling sa-learn directly.

-Ralph


Re: Replacement for antispam plugin

2017-02-12 Thread George Kontostanos
On Sun, Feb 12, 2017 at 3:52 PM, Aki Tuomi <aki.tu...@dovecot.fi> wrote:

>
> > On February 10, 2017 at 10:06 AM Aki Tuomi <aki.tu...@dovecot.fi> wrote:
> >
> >
> > Hi!
> > Since antispam plugin is deprecated and we would really prefer people
> > not to use it, we wrote instructions on how to replace it with
> > IMAPSieve. Comments and suggestions are most welcome.
> >
> > https://wiki.dovecot.org/HowTo/AntispamWithSieve
> >
> > ---
> > Aki Tuomi
> > Dovecot oy
>
> Hi everyone,
>
> thank you all for your feedback, questions and comments. We have upgraded
> the documentation based on this, including information how to exclude Trash
> folder in ham script.
>
> Aki
>


Thank you all very much. I am now running into a very weird issue. Whenever
an Junk email is “seen” I get the following error:

Debug: sieve: vnd.dovecot.execute extension: no bin or socket directory
specified; extension is unconfigured (both sieve_execute_bin_dir and
sieve_execute_socket_dir are not set)
Feb 12 18:02:54 imap(user@domain): Debug: imapsieve: Static mailbox rule
[1]: mailbox=`Junk' from=`*' causes=(COPY) =>
before=`file:/usr/local/lib/dovecot/sieve/report-spam.sieve' after=(none)
Feb 12 18:02:54 imap(user@dmain): Debug: imapsieve: Static mailbox rule
[2]: mailbox=`*' from=`Junk' causes=(COPY) =>
before=`file:/usr/local/lib/dovecot/sieve/report-ham.sieve' after=(none)

Also it automatically creates a .spamassassin/ folder in the user:

-rw---  1 vmail  vmail136 Feb 10 17:33 .dovecot.lda-dupes
lrwx--  1 vmail  vmail 17 Mar 13  2016 .dovecot.sieve@ ->
managesieve.sieve
-rw---  1 vmail  vmail322 Feb 11 03:02 .dovecot.svbin
drwx--  2 vmail  vmail512 Feb 12 18:04 .spamassassin/
drwx--  5 vmail  vmail512 Feb 10 17:32 Drafts/
drwx--  5 vmail  vmail512 Feb 12 18:09 Junk/
drwx--  5 vmail  vmail512 Feb 11 17:36 Saved/
drwx--  5 vmail  vmail512 Jan 16 11:55 Sent/
drwx--  5 vmail  vmail512 Feb 12 18:09 Trash/
drwx--  2 vmail  vmail   1024 Feb 12 18:07 cur/
-rw---  1 vmail  vmail 21 Mar 13  2016 dovecot-acl-list
-rw---  1 vmail  vmail 68 Oct 17 13:19 dovecot-keywords
-rw---  1 vmail  vmail245 Feb 12 18:07 dovecot-uidlist
-rw---  1 vmail  vmail  8 Jun  9  2016 dovecot-uidvalidity
-r--r--r--  1 vmail  vmail  0 Mar 12  2016 dovecot-uidvalidity.56e48129
-rw---  1 vmail  vmail640 Feb 11 22:24 dovecot.index
-rw---  1 vmail  vmail  27788 Feb 12 18:07 dovecot.index.cache
-rw---  1 vmail  vmail  25996 Feb 12 18:07 dovecot.index.log
-rw---  1 vmail  vmail192 Feb 12 16:04 dovecot.mailbox.log
-rw---  1 vmail  vmail181 Feb 10 17:34 managesieve.sieve
drwx--  2 vmail  vmail512 Feb 12 17:46 new/
-rw---  1 vmail  vmail 39 Jun  9  2016 subscriptions
drwx--  2 vmail  vmail512 Feb 12 18:04 tmp/

Any ideas ? I am attaching my config.

Thanks

# 2.2.27 (c0f36b0): /usr/local/etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.16 (fed8554)
# OS: FreeBSD 10.3-RELEASE-p11 amd64  ufs
auth_mechanisms = plain login
auth_verbose = yes
default_client_limit = 2560
default_process_limit = 512
dict {
  acl = mysql:/usr/local/etc/dovecot/dovecot-dict-sql.conf.ext
  quota = mysql:/usr/local/etc/dovecot/dovecot-dict-sql.conf.ext
}
log_path = /var/log/dovecot.log
mail_home = /usr/local/vhosts/mail/%d/%n
mail_location = maildir:/usr/local/vhosts/mail/%d/%n:LAYOUT=fs
mail_max_userip_connections = 20
mail_plugins = quota acl
mail_privileged_group = vmail
mail_shared_explicit_inbox = yes
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character
vacation subaddress comparator-i;ascii-numeric relational regex imap4flags
copy include variables body enotify environment mailbox date index ihave
duplicate mime foreverypart extracttext imapsieve
mbox_write_locks = fcntl
namespace {
  inbox = no
  list = children
  location =
maildir:/usr/local/vhosts/mail/%%d/%%n:LAYOUT=fs:INDEX=/usr/local/vhosts/indexes/%d/%n/shared/%%u:INDEXPVT=/usr/local/vhosts/indexes/%d/%n/shared/%%u
  prefix = shared/%%d/%%n/
  separator = /
  subscriptions = no
  type = shared
}
namespace inbox {
  inbox = yes
  list = yes
  location =
  mailbox Drafts {
auto = subscribe
special_use = \Drafts
  }
  mailbox Junk {
auto = subscribe
special_use = \Junk
  }
  mailbox Sent {
auto = subscribe
special_use = \Sent
  }
  mailbox Trash {
auto = subscribe
special_use = \Trash
  }
  prefix =
  separator = /
  type = private
}
passdb {
  args = /usr/local/etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  acl = vfile
  acl_shared_dict = proxy::acl
  imapsieve_mailbox1_before =
file:/usr/local/lib/dovecot/sieve/report-spam.sieve
  imapsieve_mailbox1_causes = COPY
  imapsieve_mailbox1_name = Junk
  imapsieve_mailbox2_before =
file:/usr/local

Re: Replacement for antispam plugin

2017-02-12 Thread Ralph Seichter
On 12.02.2017 13:25, Stephan Bosch wrote:

> The "imap.mailbox" environment is the empty string in this case. Why?
> Well, the Sieve interpreter does not know about it, since the
> "imapsieve" extension is not activated in the require line.

Now there's a facepalm moment. ;-) Thank you, with a modified 'require'
statement things are working for me.

I see that https://wiki.dovecot.org/HowTo/AntispamWithSieve has already
been updated, that's nice.

> You could debug this with the non-standard "vnd.dovecot.debug"
> extension.

Thanks again, I will keep this in mind for future debugging.

-Ralph


Re: Replacement for antispam plugin

2017-02-12 Thread Aki Tuomi

> On February 10, 2017 at 10:06 AM Aki Tuomi <aki.tu...@dovecot.fi> wrote:
> 
> 
> Hi!
> Since antispam plugin is deprecated and we would really prefer people
> not to use it, we wrote instructions on how to replace it with
> IMAPSieve. Comments and suggestions are most welcome.
> 
> https://wiki.dovecot.org/HowTo/AntispamWithSieve
> 
> ---
> Aki Tuomi
> Dovecot oy

Hi everyone,

thank you all for your feedback, questions and comments. We have upgraded the 
documentation based on this, including information how to exclude Trash folder 
in ham script.

Aki


Re: Replacement for antispam plugin

2017-02-12 Thread Stephan Bosch
Op 2/10/2017 om 10:15 PM schreef George Kontostanos:
> On Fri, Feb 10, 2017 at 9:59 PM, Ralph Seichter 
> wrote:
>
>
> Same problem here. As a workaround I tried the following:
>
> # From Spam folder to Inbox
>   imapsieve_mailbox2_name = Inbox
>   imapsieve_mailbox2_from = Spam
>   imapsieve_mailbox2_causes = COPY
>   imapsieve_mailbox2_before = file:/usr/lib/dovecot/sieve/report-ham.sieve
>
> In theory this should trigger the  report-ham script, only if a mail is
> moved from Spam to Inbox. However, it does not seem to work either.


That is because you found a rather stupid, yet minor bug. The "INBOX"
mailbox is rather special, since it is the only mailbox name that is
treated case-insensitively. The normal form is "INBOX". Due to the bug,
your "Inbox" will not match "INBOX". You can work around this for now by
specifying "INBOX" instead. Well, you will not need this workaround for
a workaround anyway if the fix I proposed in my earlier message also
works for you. But for posterity...


Regards,

Stephan.


Re: Replacement for antispam plugin

2017-02-12 Thread Stephan Bosch
Op 2/10/2017 om 8:59 PM schreef Ralph Seichter:
> On 10.02.17 20:34, Michael Slusarz wrote:
>
>> When you move a message to a new mailbox, that is a "new message"
>> event (a new UID in the target mailbox is created; the message count
>> increases). So imap.mailbox is set to the name of the *target* mailbox.
> My tests seem to indicate otherwise. Deleting a message currently
> located in the Junk folder causes the report-ham.sieve script to be
> invoked, which in my case contains the following:
>
>   require ["vnd.dovecot.pipe", "copy", "environment"];
>   if environment "imap.mailbox" "Trash" {
> stop;
>   } elsif environment "imap.mailbox" "Junk" {
> pipe :copy "debug-junk";
>   } else {
> pipe :copy "learn-ham";
>   }
>
> I can see that "learn-ham" is always invoked when a message is deleted
> from or moved out of the Junk folder, so my guess is that imap.mailbox
> is neither "Trash" nor "Junk" ("debug-junk" is never called, according
> to the Dovecot logs). Unfortunately I don't know how to debug this
> further.
>
> I don't want "learn-ham" to be run when a message located in the Junk
> folder is manually deleted or moved to Trash, and right now I don't know
> how to accomplish this.

The "imap.mailbox" environment is the empty string in this case. Why?
Well, the Sieve interpreter does not know about it, since the
"imapsieve" extension is not activated in the require line.

You could debug this with the non-standard "vnd.dovecot.debug"
extension. I debugged it like this:

require ["imapsieve", "environment", "variables", "vnd.dovecot.debug"];

if environment :matches "imap.mailbox" "*" {
set "mailbox" "${1}";
}

debug_log "imap.mailbox = ${mailbox}";

if string "${mailbox}" "Trash" {
stop;
}

debug_log "REPORT HAM";

This will log one or two info messages, depending on what the target
mailbox is.

I tested this with the example configuration and it works fine. I've
verified this by invoking the imap service directly from the command
line, so that it is immediately logged-in and spews al debug messages
directly to stderr:

$ sudo /usr/lib/dovecot/imap -u harrie
imap(harrie)<>: Debug: Loading modules from directory:
/usr/lib/dovecot/modules
imap(harrie)<>: Debug: Module loaded:
/usr/lib/dovecot/modules/lib15_notify_plugin.so
imap(harrie)<>: Debug: Module loaded:
/usr/lib/dovecot/modules/lib20_fts_plugin.so
imap(harrie)<>: Debug: Module loaded:
/usr/lib/dovecot/modules/lib20_mail_log_plugin.so
imap(harrie)<>: Debug: Module loaded:
/usr/lib/dovecot/modules/lib20_replication_plugin.so
imap(harrie)<>: Debug: Module loaded:
/usr/lib/dovecot/modules/lib20_virtual_plugin.so
imap(harrie)<>: Debug: Module loaded:
/usr/lib/dovecot/modules/lib21_fts_solr_plugin.so
imap(harrie)<>: Debug: Module loaded:
/usr/lib/dovecot/modules/lib95_imap_sieve_plugin.so
imap(harrie)<>: Debug: auth USER input: harrie uid=1000 gid=124
home=/ext/test/home/test/harrie
Debug: Effective uid=1000, gid=124, home=/ext/test/home/test/harrie
Debug: replication: No mail_replica setting - replication disabled
Debug: Namespace inbox: type=private, prefix=, sep=/, inbox=yes,
hidden=no, list=yes, subscriptions=yes location=maildir:~/Maildir
Debug: maildir++: root=/ext/test/home/test/harrie/Maildir, index=,
indexpvt=, control=, inbox=/ext/test/home/test/harrie/Maildir, alt=
Debug: Namespace : type=private, prefix=virtual/, sep=/, inbox=no,
hidden=no, list=yes, subscriptions=yes location=virtual:~/Maildir/virtual
Debug: fs: root=/ext/test/home/test/harrie/Maildir/virtual, index=,
indexpvt=, control=, inbox=, alt=
* PREAUTH [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE
SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT
MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS
LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES
WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE LITERAL+ SEARCH=FUZZY
NOTIFY URLAUTH URLAUTH=BINARY METADATA SPECIAL-USE] Logged in as harrie
23423 SELECT Spam
imap(harrie): Debug: Namespace : Using
permissions from /ext/test/home/test/harrie/Maildir: mode=0700 gid=default
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)]
Flags permitted.
* 1 EXISTS
* 1 RECENT
* OK [UNSEEN 1] First unseen.
* OK [UIDVALIDITY 1485122806] UIDs valid
* OK [UIDNEXT 2] Predicted next UID
23423 OK [READ-WRITE] Select completed (0.000 + 0.000 secs).

This is what happens for moving from Spam to a non-Trash mailbox:

2343 MOVE 1 "Frop"
imap(harrie): Debug: imapsieve: mailbox Frop:
MOVE event
imap(harrie): Debug: sieve: Pigeonhole version
0.5.devel (462a535) initializing
imap(harrie): Debug: sieve: include:
sieve_global is not set; it is currently not possible to include
`:global' scripts.
imap(harrie): Debug: sieve: Pigeonhole Sieve PGP
Encrypt plugin version 0.2.devel loaded
imap(harrie): Debug: sieve: Sieve imapsieve
plugin for Pigeonhole version 0.5.devel (462a535) loaded
imap(harrie): Debug: 

Re: antispam plugin pipe backend error when moving multiple emails

2017-02-12 Thread Sergey Urushkin

Hello,
wondering why it's still an issue with current git, while this old 
working solution exists (tested with dovecot 2.22 and rspamd 1.4) :


https://www.dovecot.org/list/dovecot/2013-November/093810.html

---
Best regards,
Sergey Urushkin


Stéphane Cottin писал 2016-04-18 15:44:

Hello,

I'm bumping this because it still occurs with dovecot 2.2.22.

my dovecot-antispam plugin configuration :

  antispam_allow_append_to_spam = no
  antispam_backend = pipe
  antispam_pipe_program = /usr/bin/rspamc
  antispam_pipe_program_args = -h;127.0.0.1:11334;-P;
  antispam_pipe_program_notspam_arg = learn_ham
  antispam_pipe_program_spam_arg = learn_spam
  antispam_pipe_tmpdir = /var/tmp
  antispam_spam = Junk
  antispam_trash = trash;Trash;Deleted Items;Deleted Messages

zlib enabled:
  zlib_save = gz
  zlib_save_level = 9


When moving 2 or more messages from inbox to the Junk folder:

"J47 NO [CANNOT] Failed to copy to temporary file (0.000 + 0.000
secs).”. Command attempted: “J47 UID MOVE 106318:106319 Junk"

or sometimes

"J123 NO [CANNOT] Failed to read mail beginning (0.000 + 0.000
secs).”. Command attempted: “J123 UID MOVE 170789:170790 Junk"

and still have the "Cached message size smaller..." in dovecot logs.

It occurs at least when header lines of an email contains Non-ASCII
Text (rfc1342).
Batches of full ascii emails are not affected.

I can easily reproduce this from/to the Junk folder, but had
unconfirmed reports of similar errors when batch moving mails across
regular folders.

Stéphane


On 8 Nov 2015, at 11:50, Stéphane Cottin wrote:


Hi,

I've got some trouble with the dovecot antispam plugin and the pipe 
backend.


I'm using dovecot 2.2.18 with maildirs and zlib compression enabled.

When moving 2 or more emails at once from the Junk folder to another 
one, I always have the following error : "Failed to copy to temporary 
file"


In the server logs :

imap(v...@vvv.vvv): Error: 
read(zlib(/data/Maildir/.test/tmp/1446974366.M123890P936.vvv)) failed: 
Cached message size smaller than expected (13553 < 13562, box=test, 
UID=0)


The same operation with one email at a time, on the same emails, works 
as expected.


Stéphane


Re: Replacement for antispam plugin

2017-02-12 Thread Stephan Bosch
Op 2/10/2017 om 8:46 PM schreef David Mehler:
> Hello,
>
> Chiming in on this with a question, and will be getting to it over the
> weekend or later this evening time permitting.
>
> Does retraining a message as either spam or ham alter message headers
> for example x-spam or the spamassassin-modified subject header?
>
> If not is it possible to do so after processing? For example, I have a
> message inadvertently tagged as spam, from Spamassassin it gets an
> x-spam header added as well as a modified subject. Retraining that
> message as ham moving it to say any other folder but spam i'd like for
> that x-spam header to be set to as it is not spam, and the
> spamassassin subject to be removed. Is this doable?

I think you could use the "editheader" extension in the report-ham.sieve
script to do that. You'll need "variables" as well to modify the subject.

Regards,

Stephan.


Re: Replacement for antispam plugin

2017-02-12 Thread Aki Tuomi

> On February 12, 2017 at 1:32 PM Stephan Bosch <step...@rename-it.nl> wrote:
> 
> 
> Op 2/10/2017 om 2:20 PM schreef Alessio Cecchi:
> > Il 10/02/2017 09:06, Aki Tuomi ha scritto:
> >> Hi!
> >> Since antispam plugin is deprecated and we would really prefer people
> >> not to use it, we wrote instructions on how to replace it with
> >> IMAPSieve. Comments and suggestions are most welcome.
> >>
> >> https://wiki.dovecot.org/HowTo/AntispamWithSieve
> > Hi,
> >
> > imap_stats plugin is required?
> 
> No, that is just part of the example.
> 
> Regards,
> 
> Stephan.

And removed from the example too, thank you for pointing this out.

Aki


Re: Replacement for antispam plugin

2017-02-12 Thread Stephan Bosch
Op 2/10/2017 om 2:20 PM schreef Alessio Cecchi:
> Il 10/02/2017 09:06, Aki Tuomi ha scritto:
>> Hi!
>> Since antispam plugin is deprecated and we would really prefer people
>> not to use it, we wrote instructions on how to replace it with
>> IMAPSieve. Comments and suggestions are most welcome.
>>
>> https://wiki.dovecot.org/HowTo/AntispamWithSieve
> Hi,
>
> imap_stats plugin is required?

No, that is just part of the example.

Regards,

Stephan.


Re: Replacement for antispam plugin

2017-02-10 Thread George Kontostanos
On Fri, Feb 10, 2017 at 9:59 PM, Ralph Seichter 
wrote:

> On 10.02.17 20:34, Michael Slusarz wrote:
>
> > When you move a message to a new mailbox, that is a "new message"
> > event (a new UID in the target mailbox is created; the message count
> > increases). So imap.mailbox is set to the name of the *target* mailbox.
>
> My tests seem to indicate otherwise. Deleting a message currently
> located in the Junk folder causes the report-ham.sieve script to be
> invoked, which in my case contains the following:
>
>   require ["vnd.dovecot.pipe", "copy", "environment"];
>   if environment "imap.mailbox" "Trash" {
> stop;
>   } elsif environment "imap.mailbox" "Junk" {
> pipe :copy "debug-junk";
>   } else {
> pipe :copy "learn-ham";
>   }
>
> I can see that "learn-ham" is always invoked when a message is deleted
> from or moved out of the Junk folder, so my guess is that imap.mailbox
> is neither "Trash" nor "Junk" ("debug-junk" is never called, according
> to the Dovecot logs). Unfortunately I don't know how to debug this
> further.
>
> I don't want "learn-ham" to be run when a message located in the Junk
> folder is manually deleted or moved to Trash, and right now I don't know
> how to accomplish this.
>
> -Ralph
>

Same problem here. As a workaround I tried the following:

# From Spam folder to Inbox
  imapsieve_mailbox2_name = Inbox
  imapsieve_mailbox2_from = Spam
  imapsieve_mailbox2_causes = COPY
  imapsieve_mailbox2_before = file:/usr/lib/dovecot/sieve/report-ham.sieve

In theory this should trigger the  report-ham script, only if a mail is
moved from Spam to Inbox. However, it does not seem to work either.
-- 
George Kontostanos
---


Re: Replacement for antispam plugin

2017-02-10 Thread Ralph Seichter
On 10.02.17 20:34, Michael Slusarz wrote:

> When you move a message to a new mailbox, that is a "new message"
> event (a new UID in the target mailbox is created; the message count
> increases). So imap.mailbox is set to the name of the *target* mailbox.

My tests seem to indicate otherwise. Deleting a message currently
located in the Junk folder causes the report-ham.sieve script to be
invoked, which in my case contains the following:

  require ["vnd.dovecot.pipe", "copy", "environment"];
  if environment "imap.mailbox" "Trash" {
stop;
  } elsif environment "imap.mailbox" "Junk" {
pipe :copy "debug-junk";
  } else {
pipe :copy "learn-ham";
  }

I can see that "learn-ham" is always invoked when a message is deleted
from or moved out of the Junk folder, so my guess is that imap.mailbox
is neither "Trash" nor "Junk" ("debug-junk" is never called, according
to the Dovecot logs). Unfortunately I don't know how to debug this
further.

I don't want "learn-ham" to be run when a message located in the Junk
folder is manually deleted or moved to Trash, and right now I don't know
how to accomplish this.

-Ralph


Re: Replacement for antispam plugin

2017-02-10 Thread David Mehler
Hello,

Chiming in on this with a question, and will be getting to it over the
weekend or later this evening time permitting.

Does retraining a message as either spam or ham alter message headers
for example x-spam or the spamassassin-modified subject header?

If not is it possible to do so after processing? For example, I have a
message inadvertently tagged as spam, from Spamassassin it gets an
x-spam header added as well as a modified subject. Retraining that
message as ham moving it to say any other folder but spam i'd like for
that x-spam header to be set to as it is not spam, and the
spamassassin subject to be removed. Is this doable?

Thanks.
Dave.


On 2/10/17, Michael Slusarz  wrote:
>
>> On February 10, 2017 at 12:13 PM Ralph Seichter wrote:
>>
>> On 10.02.17 18:34, Michael Slusarz wrote:
>> > > Can we add an exception for the Trash folder?
>> > This is handled in the sieve script. E.g.:
>> >
>> > require "environment";
>> > if environment "imap.mailbox" "Trash" {
>> >  stop;
>> > }
>>
>> This does not work for me, and I don't really expect it to work either.
>> https://tools.ietf.org/html/rfc6785#section-4.4 states:
>>
>>  The implementation MUST set the Environment [RFC5183] item
>> "imap.mailbox"
>>  to the name of the mailbox that the affected message is in, in the
>>  case of existing messages, or is targeted to be stored into, in the
>>  case of new messages.
>>
>> The message already exists in the Spam folder, hence imap.mailbox should
>> be "Spam" instead of "Trash", correct?
>
> Incorrect.
>
> When you move a message to a new mailbox, that is a "new message" event (a
> new UID in the target mailbox is created; the message count increases).  So
> imap.mailbox is set to the name of the *target* mailbox.
>
>> Is there perhaps another way to ensure that manually deleted spam is not
>> erroneously learned as ham?
>>
>> -Ralph
>


Re: Replacement for antispam plugin

2017-02-10 Thread Michael Slusarz

> On February 10, 2017 at 12:13 PM Ralph Seichter wrote:
> 
> On 10.02.17 18:34, Michael Slusarz wrote:
> > > Can we add an exception for the Trash folder?
> > This is handled in the sieve script. E.g.:
> > 
> > require "environment";
> > if environment "imap.mailbox" "Trash" {
> >  stop;
> > }
> 
> This does not work for me, and I don't really expect it to work either.
> https://tools.ietf.org/html/rfc6785#section-4.4 states:
> 
>  The implementation MUST set the Environment [RFC5183] item "imap.mailbox"
>  to the name of the mailbox that the affected message is in, in the
>  case of existing messages, or is targeted to be stored into, in the
>  case of new messages.
> 
> The message already exists in the Spam folder, hence imap.mailbox should
> be "Spam" instead of "Trash", correct?

Incorrect.

When you move a message to a new mailbox, that is a "new message" event (a new 
UID in the target mailbox is created; the message count increases).  So 
imap.mailbox is set to the name of the *target* mailbox.

> Is there perhaps another way to ensure that manually deleted spam is not
> erroneously learned as ham?
> 
> -Ralph


Re: Replacement for antispam plugin

2017-02-10 Thread Ralph Seichter
On 10.02.17 18:34, Michael Slusarz wrote:

> > Can we add an exception for the Trash folder?
>
> This is handled in the sieve script. E.g.:
>
> require "environment";
> if environment "imap.mailbox" "Trash" {
>   stop;
> }

This does not work for me, and I don't really expect it to work either.
https://tools.ietf.org/html/rfc6785#section-4.4 states:

  The implementation MUST set the Environment [RFC5183] item "imap.mailbox"
  to the name of the mailbox that the affected message is in, in the
  case of existing messages, or is targeted to be stored into, in the
  case of new messages.

The message already exists in the Spam folder, hence imap.mailbox should
be "Spam" instead of "Trash", correct?

Is there perhaps another way to ensure that manually deleted spam is not
erroneously learned as ham?

-Ralph


Re: Replacement for antispam plugin

2017-02-10 Thread Ralph Seichter
On 10.02.17 18:22, Zhang Huangbin wrote:

> My concern is, will you experience any lag while moving message?

I don't use direct calls to sa-learn, but store the piped e-mails on
disk, and a periodic cron-job picks them up and invokes sa-learn. This
way, there is no noticeable lag.

-Ralph


Re: Replacement for antispam plugin

2017-02-10 Thread Michael Slusarz
> On February 10, 2017 at 9:25 AM George Kontostanos  
> wrote:

[snip]

> I think that this needs some change:
> 
>  # From Spam folder to elsewhere
>   imapsieve_mailbox2_name = *
>   imapsieve_mailbox2_from = Spam
>   imapsieve_mailbox2_causes = COPY
>   imapsieve_mailbox2_before = file:/usr/lib/dovecot/sieve/report-ham.sieve
> 
> When a message from Spam is moved to Trash then the report-ham.sieve is
> being executed.
> 
> Can we add an exception for the Trash folder?

This is handled in the sieve script.  E.g.:

require "environment";
if environment "imap.mailbox" "Trash" {
stop;
}

michael


Re: Replacement for antispam plugin

2017-02-10 Thread Zhang Huangbin

> On Feb 11, 2017, at 12:50 AM, Ralph Seichter <dovecot...@seichter.de> wrote:
> 
> Check out https://wiki.dovecot.org/Pigeonhole/Sieve/Plugins/IMAPSieve,

My concern is, will you experience any lag while moving message?

According to the doc, this plugin works like “pipe” backend of old “antispam” 
plugin, when you move a message from INBOX to Junk, the antispam plugin calls 
sa-learn, and you will experience noticeable lag on webmail (i used Roundcube 
webmail for testing) until sa-learn finished. It's much worse if you move 
multiple emails at the same time, because we have to wait for sa-learn to learn 
all moved messages.

I switched to “spool2dir” backend of old “antispam” plugin, and call sa-learn 
hourly to learn spam/ham. Since it simply copies moved message(s), no lag on 
webmail side at all, our users are satisfied.


Zhang Huangbin, founder of iRedMail project: http://www.iredmail.org/
Time zone: GMT+8 (China/Beijing).


Re: Replacement for antispam plugin

2017-02-10 Thread Ralph Seichter
On 10.02.2017 16:09, Darac Marjal wrote:

> Check out https://wiki.dovecot.org/Pigeonhole/Sieve/Plugins/IMAPSieve,
> which explains that sieve is normally only used at delivery time, but
> the sieve_imapsieve plugin runs a *different* sieve script based on
> IMAP actions (for example, COPY).

Thanks for the pointer, Darac. The following confirms that imapsieve_*
is not involved during delivery: "Note that the imapsieve extension can
only be used in a Sieve script that is invoked from IMAP. When it is
used in the active delivery script, it will cause runtime errors."

-Ralph


Re: Replacement for antispam plugin

2017-02-10 Thread George Kontostanos
On Fri, Feb 10, 2017 at 6:25 PM, George Kontostanos <gkontos.m...@gmail.com>
wrote:

>
>
> On Fri, Feb 10, 2017 at 5:09 PM, Darac Marjal <mailingl...@darac.org.uk>
> wrote:
>
>> On Fri, Feb 10, 2017 at 03:52:52PM +0100, Ralph Seichter wrote:
>>
>>> On 10.02.2017 09:06, Aki Tuomi wrote:
>>>
>>> Since antispam plugin is deprecated and we would really prefer people
>>>> not to use it, we wrote instructions on how to replace it with
>>>> IMAPSieve.
>>>>
>>>
>>> In my setup, I use the following sieve script globally for all users:
>>>
>>>  if header :is "X-Spam-Flag" "YES" {
>>>fileinto "Junk";
>>>stop;
>>>  }
>>>
>>> This allows processing based on spam flags set by Amavis/SpamAssassin.
>>> I wonder if the method shown in
>>>
>>>  https://wiki.dovecot.org/HowTo/AntispamWithSieve
>>>
>>> will cause incoming mail (via LMTP) that is already flagged as spam to
>>> be processed by report-spam.sieve and, in consequence, will be learned
>>> as spam for a second time, which would of course be undesirable?
>>>
>>
>> It shouldn't do. Check out https://wiki.dovecot.org/Pigeo
>> nhole/Sieve/Plugins/IMAPSieve, which explains that sieve is normally
>> only used at delivery time, but the sieve_imapsieve plugin runs a
>> *different* sieve script based on IMAP actions (for example, COPY).
>>
>> So, when you deliver, your main script tells dovecot WHERE to deliver to.
>> When you issue and IMAP COPY command, the Antispam scripts tell dovecot to
>> pipe the message to spamassassin. The delivery does not involve IMAP and
>> the IMAP COPY does not constitute redelivery.
>>
>>
>> --
>> For more information, please reread.
>>
>
> I think that this needs some change:
>
>  # From Spam folder to elsewhere
>   imapsieve_mailbox2_name = *
>   imapsieve_mailbox2_from = Spam
>   imapsieve_mailbox2_causes = COPY
>   imapsieve_mailbox2_before = file:/usr/lib/dovecot/sieve/report-ham.sieve
>
> When a message from Spam is moved to Trash then the report-ham.sieve is
> being executed.
>
> Can we add an exception for the Trash folder?
>
> Thanks
>
>
> --
> George Kontostanos
> ---
>

Could we use something like this:

imapsieve_mailbox2_name = ! Trash

-- 
George Kontostanos
---


Re: Replacement for antispam plugin

2017-02-10 Thread George Kontostanos
On Fri, Feb 10, 2017 at 5:09 PM, Darac Marjal <mailingl...@darac.org.uk>
wrote:

> On Fri, Feb 10, 2017 at 03:52:52PM +0100, Ralph Seichter wrote:
>
>> On 10.02.2017 09:06, Aki Tuomi wrote:
>>
>> Since antispam plugin is deprecated and we would really prefer people
>>> not to use it, we wrote instructions on how to replace it with IMAPSieve.
>>>
>>
>> In my setup, I use the following sieve script globally for all users:
>>
>>  if header :is "X-Spam-Flag" "YES" {
>>fileinto "Junk";
>>stop;
>>  }
>>
>> This allows processing based on spam flags set by Amavis/SpamAssassin.
>> I wonder if the method shown in
>>
>>  https://wiki.dovecot.org/HowTo/AntispamWithSieve
>>
>> will cause incoming mail (via LMTP) that is already flagged as spam to
>> be processed by report-spam.sieve and, in consequence, will be learned
>> as spam for a second time, which would of course be undesirable?
>>
>
> It shouldn't do. Check out https://wiki.dovecot.org/Pigeo
> nhole/Sieve/Plugins/IMAPSieve, which explains that sieve is normally only
> used at delivery time, but the sieve_imapsieve plugin runs a *different*
> sieve script based on IMAP actions (for example, COPY).
>
> So, when you deliver, your main script tells dovecot WHERE to deliver to.
> When you issue and IMAP COPY command, the Antispam scripts tell dovecot to
> pipe the message to spamassassin. The delivery does not involve IMAP and
> the IMAP COPY does not constitute redelivery.
>
>
> --
> For more information, please reread.
>

I think that this needs some change:

 # From Spam folder to elsewhere
  imapsieve_mailbox2_name = *
  imapsieve_mailbox2_from = Spam
  imapsieve_mailbox2_causes = COPY
  imapsieve_mailbox2_before = file:/usr/lib/dovecot/sieve/report-ham.sieve

When a message from Spam is moved to Trash then the report-ham.sieve is
being executed.

Can we add an exception for the Trash folder?

Thanks


-- 
George Kontostanos
---


Re: Replacement for antispam plugin

2017-02-10 Thread Darac Marjal

On Fri, Feb 10, 2017 at 03:52:52PM +0100, Ralph Seichter wrote:

On 10.02.2017 09:06, Aki Tuomi wrote:


Since antispam plugin is deprecated and we would really prefer people
not to use it, we wrote instructions on how to replace it with IMAPSieve.


In my setup, I use the following sieve script globally for all users:

 if header :is "X-Spam-Flag" "YES" {
   fileinto "Junk";
   stop;
 }

This allows processing based on spam flags set by Amavis/SpamAssassin.
I wonder if the method shown in

 https://wiki.dovecot.org/HowTo/AntispamWithSieve

will cause incoming mail (via LMTP) that is already flagged as spam to
be processed by report-spam.sieve and, in consequence, will be learned
as spam for a second time, which would of course be undesirable?


It shouldn't do. Check out 
https://wiki.dovecot.org/Pigeonhole/Sieve/Plugins/IMAPSieve, which 
explains that sieve is normally only used at delivery time, but the 
sieve_imapsieve plugin runs a *different* sieve script based on IMAP 
actions (for example, COPY).


So, when you deliver, your main script tells dovecot WHERE to deliver 
to. When you issue and IMAP COPY command, the Antispam scripts tell 
dovecot to pipe the message to spamassassin. The delivery does not 
involve IMAP and the IMAP COPY does not constitute redelivery.



--
For more information, please reread.


Re: Replacement for antispam plugin

2017-02-10 Thread Ralph Seichter
On 10.02.2017 09:06, Aki Tuomi wrote:

> Since antispam plugin is deprecated and we would really prefer people
> not to use it, we wrote instructions on how to replace it with IMAPSieve.

In my setup, I use the following sieve script globally for all users:

  if header :is "X-Spam-Flag" "YES" {
fileinto "Junk";
stop;
  }

This allows processing based on spam flags set by Amavis/SpamAssassin.
I wonder if the method shown in

  https://wiki.dovecot.org/HowTo/AntispamWithSieve

will cause incoming mail (via LMTP) that is already flagged as spam to
be processed by report-spam.sieve and, in consequence, will be learned
as spam for a second time, which would of course be undesirable?

-Ralph


Re: Replacement for antispam plugin

2017-02-10 Thread Alessio Cecchi

Il 10/02/2017 09:06, Aki Tuomi ha scritto:

Hi!
Since antispam plugin is deprecated and we would really prefer people
not to use it, we wrote instructions on how to replace it with
IMAPSieve. Comments and suggestions are most welcome.

https://wiki.dovecot.org/HowTo/AntispamWithSieve

Hi,

imap_stats plugin is required?

--
Alessio Cecchi
Postmaster @ http://www.qboxmail.it
https://www.linkedin.com/in/alessice


Re: Replacement for antispam plugin

2017-02-10 Thread Tamsy

Aki Tuomi wrote on 10.02.2017 15:06:

Hi!
Since antispam plugin is deprecated and we would really prefer people
not to use it, we wrote instructions on how to replace it with
IMAPSieve. Comments and suggestions are most welcome.

https://wiki.dovecot.org/HowTo/AntispamWithSieve

---
Aki Tuomi
Dovecot oy
We just implemented this according to the wiki. Works great and without 
any hiccups. Thanks, Aki


Re: Replacement for antispam plugin

2017-02-10 Thread Håkon Alstadheim
Nice. Finally got around to switching. Had to add filter to my dspam
pipe (another one I'm overdue for replacing) . Antispam plugin seems to
have automatically converted line endings from "mail-type" '\r\n' into
linux plain '\n' .

Like so:
sed -e 's/\r$//' | dspam ...


Den 10. feb. 2017 09:06, skrev Aki Tuomi:
> Hi!
> Since antispam plugin is deprecated and we would really prefer people
> not to use it, we wrote instructions on how to replace it with
> IMAPSieve. Comments and suggestions are most welcome.
> 
> https://wiki.dovecot.org/HowTo/AntispamWithSieve
> 
> ---
> Aki Tuomi
> Dovecot oy
> 


Re: Replacement for antispam plugin

2017-02-10 Thread Aki Tuomi


On 10.02.2017 10:35, Tom Hendrikx wrote:
>
> On 10-02-17 09:06, Aki Tuomi wrote:
>> Hi!
>> Since antispam plugin is deprecated and we would really prefer people
>> not to use it, we wrote instructions on how to replace it with
>> IMAPSieve. Comments and suggestions are most welcome.
>>
>> https://wiki.dovecot.org/HowTo/AntispamWithSieve
>>
> Could you elaborate on the fact that it's deprecated? I never saw
> anything about that? The wiki page wasn't mentioning that it's
> deprecated since this morning?
>
> Kind regards,
>   Tom

It has not been maintained for ages and we have decided to officially
deprecate it now. We believe that IMAPSieve does this much better than
this plugin.

Aki


Re: Replacement for antispam plugin

2017-02-10 Thread Tom Hendrikx


On 10-02-17 09:06, Aki Tuomi wrote:
> Hi!
> Since antispam plugin is deprecated and we would really prefer people
> not to use it, we wrote instructions on how to replace it with
> IMAPSieve. Comments and suggestions are most welcome.
> 
> https://wiki.dovecot.org/HowTo/AntispamWithSieve
> 

Could you elaborate on the fact that it's deprecated? I never saw
anything about that? The wiki page wasn't mentioning that it's
deprecated since this morning?

Kind regards,
Tom


Replacement for antispam plugin

2017-02-10 Thread Aki Tuomi
Hi!
Since antispam plugin is deprecated and we would really prefer people
not to use it, we wrote instructions on how to replace it with
IMAPSieve. Comments and suggestions are most welcome.

https://wiki.dovecot.org/HowTo/AntispamWithSieve

---
Aki Tuomi
Dovecot oy


Re: Antispam plugin: insufficent error messages

2016-12-18 Thread Timo Sirainen
On 18 Dec 2016, at 0.57, Tom Talpey <t...@talpey.com> wrote:
> 
> 
> I too encountered this same issue after upgrading to 2.2.27. I traced it
> to an apparent change in Dovecot's mail_get_headers() function, which
> now returns a non-zero value even when the header is found. This wasn't
> the behavior in 2.2.24, though I'm not sure if it was in .25 or .26.
> I haven't tracked down the details further.
> 
> Anyway, the antispam plugin uses this API to find the X-DSPAM-Signature
> header, and the change causes the plugin to abort. This happens in the
> plugin's antispam-plugin.h wrapper, which I modified as follows.
> 
> I'm confused why the dovecot API behavior changed, but I hope this
> helps!

It was mostly an accident. There was a mismatch between mail_get_headers() and 
mail_get_headers_utf8() return values, which was fixed the wrong way. Also I 
think there might have been some code that assumed that mail_get_headers() 
would return > 0 on success. Anyway, too late to change back now...

> ! const char *const *ret = NULL;
> ! mail_get_headers(mail, hdr, );
>   return ret;

That works, but maybe a nicer way that works for both old and new API and 
checks also the return value:

if (mail_get_headers(mail, hdr, ) < 0)
  return NULL;

>  }
> 
> --- 268,276 
>  static inline const char *const *
>  get_mail_headers(struct mail *mail, const char *hdr)
>  {
> ! const char *const *ret;
> ! if (mail_get_headers(mail, hdr, ))
> ! return NULL;
>   return ret;
>  }


Re: Antispam plugin: insufficent error messages

2016-12-17 Thread Volker Wysk
Am Samstag, 17. Dezember 2016, 17:57:54 CET schrieb Tom Talpey:
> I too encountered this same issue after upgrading to 2.2.27. I traced it
> to an apparent change in Dovecot's mail_get_headers() function, which
> now returns a non-zero value even when the header is found. This wasn't
> the behavior in 2.2.24, though I'm not sure if it was in .25 or .26.
> I haven't tracked down the details further.
> 
> Anyway, the antispam plugin uses this API to find the X-DSPAM-Signature
> header, and the change causes the plugin to abort. This happens in the
> plugin's antispam-plugin.h wrapper, which I modified as follows.
> 
> I'm confused why the dovecot API behavior changed, but I hope this
> helps!

Thank you for your help, but I've already done it differently now. I'm using 
the spam filter capabilities of my mail reader (KMail). This uses an external 
spam filter (I've chosen CRM114). That's not optimal, because I have two spam 
filters now (on my desktop and my laptop), and no spam filter for my 
smartphone, 
but it works.

Bye
Volker


Re: Antispam plugin: insufficent error messages

2016-12-17 Thread Tom Talpey

On 11/28/2016 3:28 PM, Volker Wysk wrote:

Hi!

"Dovecot always logs a detailed error message if something goes wrong.
If it doesn't, it's considered a bug and will be fixed." (http://
wiki2.dovecot.org/Logging)

I'm trying to set up a spam filter with dovecot-antispam and dspam as backend.

When I move a spam message from INBOX to Spam, I get this in syslog:

Nov 28 21:15:58 desktop imap: antispam: mailbox_is_unsure(Spam): 0
Nov 28 21:15:58 desktop imap: antispam: mailbox_is_trash(INBOX): 0
Nov 28 21:15:58 desktop imap: antispam: mailbox_is_trash(Spam): 0
Nov 28 21:15:58 desktop imap: antispam: mail copy: from trash: 0, to trash: 0
Nov 28 21:15:58 desktop imap: antispam: mailbox_is_spam(INBOX): 0
Nov 28 21:15:58 desktop imap: antispam: mailbox_is_spam(Spam): 1
Nov 28 21:15:58 desktop imap: antispam: mailbox_is_unsure(INBOX): 0
Nov 28 21:15:58 desktop imap: antispam: mail copy: src spam: 0, dst spam: 1,
src unsure: 0

There are no log entries about how dspam is called, or what goes on. Indeed,
dspam doesn't get called at all. I know, because I've examined the antispam-
plugin source code. There would be a log message if dspam was called.

It's hard to study the source code, because there are hardly any comments.

I have been able to trace the problem to function signature_extract_to_list()
in signature.c. There, -1 is returned:

int signature_extract_to_list(const struct signature_config *cfg,
  struct mailbox_transaction_context *t,
  struct mail *mail, struct siglist **list,
  enum classification wanted)
{
const char *const *signatures;
struct siglist *item;

signatures = get_mail_headers(mail, cfg->signature_hdr);
if (!signatures || !signatures[0]) {
if (!cfg->signature_nosig_ignore) {

mail_storage_set_error(t->box->storage,
   ME(NOTPOSSIBLE)
   "antispam signature not found");
return -1;   /* <-- HERE */
} else {
return 0;
}
}

while (signatures[1])
signatures++;

item = i_new(struct siglist, 1);
item->next = *list;
item->wanted = wanted;
item->sig = i_strdup(signatures[0]);

*list = item;

return 0;
}

So, what's happening is "antispam signature not found".  My question: What
does this mean? What's going on?




I too encountered this same issue after upgrading to 2.2.27. I traced it
to an apparent change in Dovecot's mail_get_headers() function, which
now returns a non-zero value even when the header is found. This wasn't
the behavior in 2.2.24, though I'm not sure if it was in .25 or .26.
I haven't tracked down the details further.

Anyway, the antispam plugin uses this API to find the X-DSPAM-Signature
header, and the change causes the plugin to abort. This happens in the
plugin's antispam-plugin.h wrapper, which I modified as follows.

I'm confused why the dovecot API behavior changed, but I hope this
helps!

Tom.


*** antispam-plugin.h   2016-12-17 17:25:48.571704442 -0500
--- antispam-plugin.h.orig  2016-12-17 17:24:55.010093416 -0500
***
*** 268,275 
  static inline const char *const *
  get_mail_headers(struct mail *mail, const char *hdr)
  {
!   const char *const *ret = NULL;
!   mail_get_headers(mail, hdr, );
return ret;
  }

--- 268,276 
  static inline const char *const *
  get_mail_headers(struct mail *mail, const char *hdr)
  {
!   const char *const *ret;
!   if (mail_get_headers(mail, hdr, ))
!   return NULL;
return ret;
  }


Re: Antispam plugin: insufficent error messages

2016-11-30 Thread Volker Wysk
Am Mittwoch, 30. November 2016, 16:23:13 CET schrieb Volker Wysk:
> Do you know any documentation about the Dovecot
> plugin API? I couldn't find any.

I've found it. No need to tell me.

Volker


Re: Antispam plugin: insufficent error messages

2016-11-30 Thread Volker Wysk
Am Dienstag, 29. November 2016, 13:59:52 CET schrieb Stephan Bosch:
> However, AntiSpam is 
> not part of the normal Dovecot distribution, nor is it a plugin created 
> by Dovecot developers. From what I know, Dovecot has mirrored/hosted the 
> AntiSpam Mercurial repository in the past and contributed a few small 
> fixes, but nothing more. Also, it doesn't look like it is actively 
> maintained at the moment.

So, if I would debug the antispam plugin, adding more log messages, finding the 
reason it doesn't work now, would my changes be included in the antispam 
distribution? Do you know any documentation about the Dovecot plugin API? I 
couldn't find any.

> Pigeonhole Sieve recently gained support for the IMAPSieve extension 
> (http://wiki2.dovecot.org/Pigeonhole/Sieve/Plugins/IMAPSieve). When 
> combined with the exprograms plugin 
> (http://wiki2.dovecot.org/Pigeonhole/Sieve/Plugins/Extprograms), you 
> should be able achieve something quite similar using a Sieve script, 
> although I have never tried that myself.

Thanks for the hint. This looks interesing, but also quite complicated. I've 
read the two pages you specified. Is there any good documentation? I have Peer 
Heinlein's Dovecot book. But there isn't much in it about plugins.

Bye
Volker


Re: Antispam plugin: insufficent error messages

2016-11-29 Thread Stephan Bosch



Op 28-11-2016 om 21:28 schreef Volker Wysk:

Hi!

"Dovecot always logs a detailed error message if something goes wrong.
If it doesn't, it's considered a bug and will be fixed." (http://
wiki2.dovecot.org/Logging)


Yes, that is indeed what Dovecot and Pigeonhole do. However, AntiSpam is 
not part of the normal Dovecot distribution, nor is it a plugin created 
by Dovecot developers. From what I know, Dovecot has mirrored/hosted the 
AntiSpam Mercurial repository in the past and contributed a few small 
fixes, but nothing more. Also, it doesn't look like it is actively 
maintained at the moment.


Pigeonhole Sieve recently gained support for the IMAPSieve extension 
(http://wiki2.dovecot.org/Pigeonhole/Sieve/Plugins/IMAPSieve). When 
combined with the exprograms plugin 
(http://wiki2.dovecot.org/Pigeonhole/Sieve/Plugins/Extprograms), you 
should be able achieve something quite similar using a Sieve script, 
although I have never tried that myself.


Regards,

Stephan.


Re: Antispam plugin: insufficent error messages

2016-11-28 Thread Volker Wysk
One more point:

The spam message, which has been moved to the Spam folder for training dspam, 
doesn't get moved. When I refresh (in KMail), the message reappears in INBOX.

Bye
V.W.


Antispam plugin: insufficent error messages

2016-11-28 Thread Volker Wysk
Hi!

"Dovecot always logs a detailed error message if something goes wrong. 
If it doesn't, it's considered a bug and will be fixed." (http://
wiki2.dovecot.org/Logging)

I'm trying to set up a spam filter with dovecot-antispam and dspam as backend.

When I move a spam message from INBOX to Spam, I get this in syslog:

Nov 28 21:15:58 desktop imap: antispam: mailbox_is_unsure(Spam): 0
Nov 28 21:15:58 desktop imap: antispam: mailbox_is_trash(INBOX): 0
Nov 28 21:15:58 desktop imap: antispam: mailbox_is_trash(Spam): 0
Nov 28 21:15:58 desktop imap: antispam: mail copy: from trash: 0, to trash: 0
Nov 28 21:15:58 desktop imap: antispam: mailbox_is_spam(INBOX): 0
Nov 28 21:15:58 desktop imap: antispam: mailbox_is_spam(Spam): 1
Nov 28 21:15:58 desktop imap: antispam: mailbox_is_unsure(INBOX): 0
Nov 28 21:15:58 desktop imap: antispam: mail copy: src spam: 0, dst spam: 1, 
src unsure: 0

There are no log entries about how dspam is called, or what goes on. Indeed, 
dspam doesn't get called at all. I know, because I've examined the antispam-
plugin source code. There would be a log message if dspam was called.

It's hard to study the source code, because there are hardly any comments.

I have been able to trace the problem to function signature_extract_to_list() 
in signature.c. There, -1 is returned:

int signature_extract_to_list(const struct signature_config *cfg,
  struct mailbox_transaction_context *t,
  struct mail *mail, struct siglist **list,
  enum classification wanted)
{
const char *const *signatures;
struct siglist *item;

signatures = get_mail_headers(mail, cfg->signature_hdr);
if (!signatures || !signatures[0]) {
if (!cfg->signature_nosig_ignore) {

mail_storage_set_error(t->box->storage,
   ME(NOTPOSSIBLE)
   "antispam signature not found");
return -1;   /* <-- HERE */
} else {
return 0;
}
}

while (signatures[1])
signatures++;

item = i_new(struct siglist, 1);
item->next = *list;
item->wanted = wanted;
item->sig = i_strdup(signatures[0]);

*list = item;

return 0;
}

So, what's happening is "antispam signature not found".  My question: What 
does this mean? What's going on?

My "dovecot -n" output is attached.

Bye
Volker# 2.2.22 (fe789d2): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.13 (7b14904)
# OS: Linux 4.4.0-47-generic x86_64 Ubuntu 16.04.1 LTS 
auth_username_format = %n
auth_verbose = yes
hostname = volker-wysk.de
log_path = /var/log/dovecot.log
mail_debug = yes
mail_location = mdbox:~/lib/Dovecot-Mail
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character 
vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy 
include variables body enotify environment mailbox date index ihave duplicate 
mime foreverypart extracttext
namespace inbox {
  inbox = yes
  location = 
  mailbox Drafts {
special_use = \Drafts
  }
  mailbox Entwürfe {
special_use = \Drafts
  }
  mailbox Junk {
special_use = \Junk
  }
  mailbox Papierkorb {
special_use = \Trash
  }
  mailbox Sent {
special_use = \Sent
  }
  mailbox "Sent Messages" {
special_use = \Sent
  }
  mailbox Trash {
special_use = \Trash
  }
  mailbox "Versendete Nachrichten" {
special_use = \Sent
  }
  prefix = 
  separator = .
}
passdb {
  driver = pam
}
plugin {
  antispam_backend = dspam
  antispam_debug_target = syslog
  antispam_dspam_binary = /usr/bin/dspam
  antispam_dspam_env = HOME=%h;USER=%u
  antispam_signature = X-DSPAM-Signature
  antispam_signature_missing = error
  antispam_spam = Spam
  antispam_trash = Papierkorb
  antispam_verbose_debug = 1
  sieve = ~/.dovecot.sieve
  sieve_dir = ~/lib/Sieve
}
postmaster_address = p...@volker-wysk.de
protocols = imap lmtp sieve
ssl = required
ssl_cert = 

Patch for dovecot-antispam-plugin to support IMAP Flags indicating Junk status

2016-11-25 Thread Jonas Wielicki
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Dear list,

I made a patch which extends dovecot-antispam-plugin with support to take the 
addition and removal of a specific set of flags as trigger for learning.

This allows for very tight integration with Thunderbird and KMail, which both 
set flags for Junk messages (Thunderbird sets "Junk", KMail sets "JUNK"). With 
this patch and according configuration, dovecot-antispam-plugin can trigger on 
the addition (learn as spam) and removal (learn as ham) of these flags.

Combined with a sieve script which sets these flags for incoming mail which 
has been classified as spam, this allows for a tight and intuitive feedback 
loop between users and the server-side spam classification system.

I tested that patch with dovecot 2.2 from Debian stretch and so far it works 
pretty well.


I realise that dovecot-antispam-plugin has not been updated since 2013. It 
also has not been migrated to Github yet. If it is to be migrated there, I 
would be happy to submit a pull request there for discussion and merging. 
Otherwise, someone would have to indicate how to go forward with applying this 
patch to the official version, if that is desired.


The patch is based on current tip and feedback is appreciated. I took some 
inspiration from dovecot-core/src/plugins/notify/notify-storage.c -- this 
requires the use of struct mail_private to be able to override the vfunc for 
mail_update_keywords, which I actually do not like. However, when I tried to 
make this patch base on the use of the notify plugin (via notify_register), I 
ran into the issue that the transaction is partially freed before the 
transaction_commit event from notify is emitted, which is unfortunate and 
breaks at least the mailtrain backend (which I use). This is in theory 
fixable, but I wanted to keep the patch as small as possible, as I have no 
idea whether this will eventually end up upstream or whether I’ll have to 
maintain that for myself.


If upstream is not interested in this patch, please let me know! In that case, 
I would consider making an own plugin, which fewer backends (possibly only a 
mailtrain-like one) out of this, but frankly, I would consider that a waste of 
resources. 


In the hope that this is useful for others and hoping for feedback,
Jonas Wielicki
-BEGIN PGP SIGNATURE-

iQIzBAEBCgAdFiEEG/EPV+Xzd5wEoQQIwGIDJZdiWIoFAlg4Fd0ACgkQwGIDJZdi
WIpM3Q//TWVHDFx5LK14y0jOnxzE7kGthc6hakILnWqYgl7B/wlljD1HLrec//hg
9LEancjURnv3sPU/kEEpl6RRDX5kDMbXXKXMq7/1R7bNdmeMz5NEebAo7ktlCii7
ikk7MPL0F8UViY7IoW7y5NxfqMUldYseejn0GwKiVkEyqlyGLRbP7ijyzMWjpIWp
eqOg/b5bNX6ARMC1O/hKhvHw4AhvSO2j73da60Xchu39gvDa2kC+MTU/kX4wb6po
kPOEgFxGhpxG0+UMzUEBPLYwY3Q9x+R/PzlpUF6xEjYxgE7leVRVfCHiZLsMUGH1
itozwSzoAyDYV+Rbzk8OEBL6EGBJQHqYmNybULZsJkxhUenNeC4GRf7NcJ0jAisG
rSfwr/+kD9+ErKNgtNJzfceLYGNWti44whV6kXxRxqGlIfJsJB7ZMdrj8+wSdn0p
slXUoyHMUkRkN92tIPqZF5cb+5Ke+O+5hHE07Wohxw3eNoBSqtQWo81aigjaCraC
ivcZX3HswTapyKtpgWMzjoWqp982crr+wtAI+AlEUKoCEqF54EnxM1kB1qoe0HcH
nMgMdIkXI4VzPaUNUK206ffEtlnKNIqF3SkOkBX263L0ZJgXyCFRRj6W3z78VDdP
He62tN/FPPBtmeVrmCj2ZDE+6gqtMQN52FsN4mpaq4BrCYlYB7g=
=3+CU
-END PGP SIGNATURE-
>From 6589757e6f97028c66a20357f30205d58f00a0ff Mon Sep 17 00:00:00 2001
From: Jonas Wielicki <j.wieli...@sotecware.net>
Date: Fri, 25 Nov 2016 11:30:20 +0100
Subject: [PATCH] Trigger learning on change of configurable IMAP Flags

This allows tight integration with Thunderbird and KMail.
---
 src/antispam-plugin.c |   2 +
 src/mailbox.c | 106 ++
 src/mailbox.h |   1 +
 src/user.c|  25 ++--
 src/user.h|   2 +
 5 files changed, 133 insertions(+), 3 deletions(-)

diff --git a/src/antispam-plugin.c b/src/antispam-plugin.c
index 52694a3..e9cb260 100644
--- a/src/antispam-plugin.c
+++ b/src/antispam-plugin.c
@@ -1,5 +1,6 @@
 #include "lib.h"
 #include "mail-storage-hooks.h"
+#include "notify-plugin.h"
 
 #include "antispam-plugin.h"
 #include "user.h"
@@ -8,6 +9,7 @@
 
 static struct mail_storage_hooks antispam_plugin_hooks = {
 .mail_user_created = antispam_user_created,
+.mail_allocated = antispam_mail_allocated,
 .mailbox_allocated = antispam_mailbox_allocated
 };
 
diff --git a/src/mailbox.c b/src/mailbox.c
index 5a0a413..3334275 100644
--- a/src/mailbox.c
+++ b/src/mailbox.c
@@ -4,12 +4,17 @@
 #include "mailbox.h"
 #include "backends.h"
 
+#include 
+
 static MODULE_CONTEXT_DEFINE_INIT(antispam_storage_module,
 	_storage_module_register);
 static MODULE_CONTEXT_DEFINE_INIT(antispam_transaction_module,
 	_storage_module_register);
+static MODULE_CONTEXT_DEFINE_INIT(antispam_mail_module,
+	_module_register);
 
 #define TRANSACTION_CONTEXT(obj) MODULE_CONTEXT(obj, antispam_transaction_module)
+#define MAIL_CONTEXT(obj) MODULE_CONTEXT(obj, antispam_mail_module)
 
 struct antispam_transaction
 {
@@ -25,6 +30,35 @@ enu

antispam plugin not working correctly

2016-11-23 Thread Felix Zielcke
Hi,

I've configured the antispam plugin like in the wiki to use the sa-
learn-pipe.sh shell script.
But it's not creating the log file in /tmp.
Even if I add a "touch /tmp/x" in sa-learn-pipe.sh it's not created.

So how I can check if it works correctly?

dovecot version 2.2.26.0

/var/log/debug although contains:

Nov 23 18:36:49 daedalus imap [fziel...@z-51.de 80.187.96.201 UID MOVE]: 
antispam: mail copy: src spam: 1, dst spam: 0, src unsure: 0
Nov 23 18:36:49 daedalus imap [fziel...@z-51.de 80.187.96.201 UID MOVE]: 
antispam: running mailtrain backend program /usr/bin/sa-learn-pipe.sh
Nov 23 18:36:49 daedalus imap [fziel...@z-51.de 80.187.96.201 UID MOVE]: 
antispam: running mailtrain backend program /usr/bin/sa-learn-pipe.sh
Nov 23 18:36:49 daedalus imap [fziel...@z-51.de 80.187.96.201 UID MOVE]: 
antispam: running mailtrain backend program parameter 1 --ham

# doveconf -n |grep antispam
  antispam_backend = pipe
  antispam_debug_target = syslog
  antispam_pipe_program = /usr/bin/sa-learn-pipe.sh
  antispam_pipe_program_notspam_arg = --ham
  antispam_pipe_program_spam_arg = --spam
  antispam_pipe_tmpdir = /tmp
  antispam_spam_pattern_ignorecase = SPAM
  antispam_trash_pattern_ignorecase = trash;Deleted *
  antispam_verbose_debug = 1
  mail_plugins = acl zlib quota imap_zlib imap_acl imap_quota antispam


Re: dovecot-antispam plugin not work

2016-11-04 Thread basti
Hello,
I already use this documentation.  and after I get this errors I read
the man page at https://johannes.sipsolutions.net/files/antispam.html

Regards,
Basti


On 04.11.2016 15:52, Tom Hendrikx wrote:
> Hi,
>
> The package in debian/ubuntu is based on
> http://wiki2.dovecot.org/Plugins/Antispam, which is a fork/rewrite of
> the plugin by johannes@sipsolutions. Try to set it again using the
> correct documentation :)
>
> Regards,
>   Tom
>
> On 03-11-16 21:12, basti wrote:
>> Hello,
>> I try to use the plugin for my dovecot in debian.
>> It seem that the /usr/bin/sa-learn-pipe.sh is not execute.
>> When I run /usr/bin/sa-learn-pipe.sh from commandline logfiles are created.
>> I also read https://johannes.sipsolutions.net/files/antispam.html
>>
>> In syslog you can see fist move a mail from "z_SPAM" to INBOX and then
>> move a mail from INBOX to "z_SPAM".
>>
>> Can you please help?
>> Best regards
>>
>> Config and log's are append.
>>
>> dpkg -l | grep dovecot
>> ii  dovecot-antispam  2.0+20130912-2   
>> amd64Dovecot plugins for training spam filters
>> ii  dovecot-core  1:2.2.13-12~deb8u1   
>> amd64secure POP3/IMAP server - core files
>> ii  dovecot-imapd 1:2.2.13-12~deb8u1   
>> amd64secure POP3/IMAP server - IMAP daemon
>> ii  dovecot-pgsql 1:2.2.13-12~deb8u1   
>> amd64secure POP3/IMAP server - PostgreSQL support
>>
>> ### log
>> root@vsrv78105:/etc/dovecot# /etc/init.d/dovecot restart
>> [ ok ] Restarting dovecot (via systemctl): dovecot.service.
>> root@vsrv78105:/etc/dovecot# tail -f /var/log/syslog | grep imap
>> Nov  3 20:02:45 vsrv78105 dovecot: imap-login: Warning: Killed with
>> signal 15 (by pid=1 uid=0 code=kill)
>> Nov  3 20:02:48 vsrv78105 dovecot: master: Dovecot v2.2.13 starting up
>> for imap (core dumps disabled)
>> Nov  3 20:03:03 vsrv78105 dovecot: imap-login: Login: user=,
>> method=PLAIN, rip=xxx, lip=xxx, mpid=14954, TLS, session=
>> Nov  3 20:03:03 vsrv78105 imap: antispam: plugin initialising (2.0-notgit)
>> Nov  3 20:03:03 vsrv78105 imap: antispam: verbose debug enabled
>> Nov  3 20:03:03 vsrv78105 imap: antispam: "Spam" is exact match spam folder
>> Nov  3 20:03:03 vsrv78105 imap: antispam: "SPAM" is exact match spam folder
>> Nov  3 20:03:03 vsrv78105 imap: antispam: "z_SPAM" is exact match spam
>> folder
>> Nov  3 20:03:03 vsrv78105 imap: antispam: no unsure folders
>> Nov  3 20:03:03 vsrv78105 imap: antispam: "Trash" is exact match trash
>> folder
>> Nov  3 20:03:03 vsrv78105 imap: antispam: "trash" is exact match trash
>> folder
>> Nov  3 20:03:03 vsrv78105 imap: antispam: pipe backend tmpdir /tmp
>> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_unsure(INBOX): 0
>> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_trash(z_SPAM): 0
>> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_trash(INBOX): 0
>> Nov  3 20:03:13 vsrv78105 imap: antispam: mail copy: from trash: 0, to
>> trash: 0
>> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_spam(z_SPAM): 0
>> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_spam(INBOX): 0
>> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_unsure(z_SPAM): 0
>> Nov  3 20:03:13 vsrv78105 imap: antispam: mail copy: src spam: 0, dst
>> spam: 0, src unsure: 0
>> Nov  3 20:03:14 vsrv78105 dovecot: imap-login: Login: user=,
>> method=PLAIN, rip=xxx, lip=xxx, mpid=14959, TLS, session=
>> Nov  3 20:03:14 vsrv78105 imap: antispam: plugin initialising (2.0-notgit)
>> Nov  3 20:03:14 vsrv78105 imap: antispam: verbose debug enabled
>> Nov  3 20:03:14 vsrv78105 imap: antispam: "Spam" is exact match spam folder
>> Nov  3 20:03:14 vsrv78105 imap: antispam: "SPAM" is exact match spam folder
>> Nov  3 20:03:14 vsrv78105 imap: antispam: "z_SPAM" is exact match spam
>> folder
>> Nov  3 20:03:14 vsrv78105 imap: antispam: no unsure folders
>> Nov  3 20:03:14 vsrv78105 imap: antispam: "Trash" is exact match trash
>> folder
>> Nov  3 20:03:14 vsrv78105 imap: antispam: "trash" is exact match trash
>> folder
>> Nov  3 20:03:14 vsrv78105 imap: antispam: pipe backend tmpdir /tmp
>> Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_unsure(z_SPAM): 0
>> Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_trash(INBOX): 0
>> Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_trash(z_SPAM): 0
>> Nov  3 20:0

Re: dovecot-antispam plugin not work

2016-11-04 Thread Tom Hendrikx
Hi,

The package in debian/ubuntu is based on
http://wiki2.dovecot.org/Plugins/Antispam, which is a fork/rewrite of
the plugin by johannes@sipsolutions. Try to set it again using the
correct documentation :)

Regards,
Tom

On 03-11-16 21:12, basti wrote:
> Hello,
> I try to use the plugin for my dovecot in debian.
> It seem that the /usr/bin/sa-learn-pipe.sh is not execute.
> When I run /usr/bin/sa-learn-pipe.sh from commandline logfiles are created.
> I also read https://johannes.sipsolutions.net/files/antispam.html
> 
> In syslog you can see fist move a mail from "z_SPAM" to INBOX and then
> move a mail from INBOX to "z_SPAM".
> 
> Can you please help?
> Best regards
> 
> Config and log's are append.
> 
> dpkg -l | grep dovecot
> ii  dovecot-antispam  2.0+20130912-2   
> amd64Dovecot plugins for training spam filters
> ii  dovecot-core  1:2.2.13-12~deb8u1   
> amd64secure POP3/IMAP server - core files
> ii  dovecot-imapd 1:2.2.13-12~deb8u1   
> amd64secure POP3/IMAP server - IMAP daemon
> ii  dovecot-pgsql 1:2.2.13-12~deb8u1   
> amd64secure POP3/IMAP server - PostgreSQL support
> 
> ### log
> root@vsrv78105:/etc/dovecot# /etc/init.d/dovecot restart
> [ ok ] Restarting dovecot (via systemctl): dovecot.service.
> root@vsrv78105:/etc/dovecot# tail -f /var/log/syslog | grep imap
> Nov  3 20:02:45 vsrv78105 dovecot: imap-login: Warning: Killed with
> signal 15 (by pid=1 uid=0 code=kill)
> Nov  3 20:02:48 vsrv78105 dovecot: master: Dovecot v2.2.13 starting up
> for imap (core dumps disabled)
> Nov  3 20:03:03 vsrv78105 dovecot: imap-login: Login: user=,
> method=PLAIN, rip=xxx, lip=xxx, mpid=14954, TLS, session=
> Nov  3 20:03:03 vsrv78105 imap: antispam: plugin initialising (2.0-notgit)
> Nov  3 20:03:03 vsrv78105 imap: antispam: verbose debug enabled
> Nov  3 20:03:03 vsrv78105 imap: antispam: "Spam" is exact match spam folder
> Nov  3 20:03:03 vsrv78105 imap: antispam: "SPAM" is exact match spam folder
> Nov  3 20:03:03 vsrv78105 imap: antispam: "z_SPAM" is exact match spam
> folder
> Nov  3 20:03:03 vsrv78105 imap: antispam: no unsure folders
> Nov  3 20:03:03 vsrv78105 imap: antispam: "Trash" is exact match trash
> folder
> Nov  3 20:03:03 vsrv78105 imap: antispam: "trash" is exact match trash
> folder
> Nov  3 20:03:03 vsrv78105 imap: antispam: pipe backend tmpdir /tmp
> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_unsure(INBOX): 0
> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_trash(z_SPAM): 0
> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_trash(INBOX): 0
> Nov  3 20:03:13 vsrv78105 imap: antispam: mail copy: from trash: 0, to
> trash: 0
> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_spam(z_SPAM): 0
> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_spam(INBOX): 0
> Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_unsure(z_SPAM): 0
> Nov  3 20:03:13 vsrv78105 imap: antispam: mail copy: src spam: 0, dst
> spam: 0, src unsure: 0
> Nov  3 20:03:14 vsrv78105 dovecot: imap-login: Login: user=,
> method=PLAIN, rip=xxx, lip=xxx, mpid=14959, TLS, session=
> Nov  3 20:03:14 vsrv78105 imap: antispam: plugin initialising (2.0-notgit)
> Nov  3 20:03:14 vsrv78105 imap: antispam: verbose debug enabled
> Nov  3 20:03:14 vsrv78105 imap: antispam: "Spam" is exact match spam folder
> Nov  3 20:03:14 vsrv78105 imap: antispam: "SPAM" is exact match spam folder
> Nov  3 20:03:14 vsrv78105 imap: antispam: "z_SPAM" is exact match spam
> folder
> Nov  3 20:03:14 vsrv78105 imap: antispam: no unsure folders
> Nov  3 20:03:14 vsrv78105 imap: antispam: "Trash" is exact match trash
> folder
> Nov  3 20:03:14 vsrv78105 imap: antispam: "trash" is exact match trash
> folder
> Nov  3 20:03:14 vsrv78105 imap: antispam: pipe backend tmpdir /tmp
> Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_unsure(z_SPAM): 0
> Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_trash(INBOX): 0
> Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_trash(z_SPAM): 0
> Nov  3 20:04:05 vsrv78105 imap: antispam: mail copy: from trash: 0, to
> trash: 0
> Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_spam(INBOX): 0
> Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_spam(z_SPAM): 0
> Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_unsure(INBOX): 0
> Nov  3 20:04:05 vsrv78105 imap: antispam: mail copy: src spam: 0, dst
> spam: 0, src unsure: 0
> ^C
> 
> root@vsrv78105:/etc/dovecot# ls -la /tmp/
> insgesamt 8864
> drwxrwxrwt  8 root root   12288 Nov  3 20:07 .
> drwx

dovecot-antispam plugin not work

2016-11-03 Thread basti
Hello,
I try to use the plugin for my dovecot in debian.
It seem that the /usr/bin/sa-learn-pipe.sh is not execute.
When I run /usr/bin/sa-learn-pipe.sh from commandline logfiles are created.
I also read https://johannes.sipsolutions.net/files/antispam.html

In syslog you can see fist move a mail from "z_SPAM" to INBOX and then
move a mail from INBOX to "z_SPAM".

Can you please help?
Best regards

Config and log's are append.

dpkg -l | grep dovecot
ii  dovecot-antispam  2.0+20130912-2   
amd64Dovecot plugins for training spam filters
ii  dovecot-core  1:2.2.13-12~deb8u1   
amd64secure POP3/IMAP server - core files
ii  dovecot-imapd 1:2.2.13-12~deb8u1   
amd64secure POP3/IMAP server - IMAP daemon
ii  dovecot-pgsql 1:2.2.13-12~deb8u1   
amd64secure POP3/IMAP server - PostgreSQL support

### log
root@vsrv78105:/etc/dovecot# /etc/init.d/dovecot restart
[ ok ] Restarting dovecot (via systemctl): dovecot.service.
root@vsrv78105:/etc/dovecot# tail -f /var/log/syslog | grep imap
Nov  3 20:02:45 vsrv78105 dovecot: imap-login: Warning: Killed with
signal 15 (by pid=1 uid=0 code=kill)
Nov  3 20:02:48 vsrv78105 dovecot: master: Dovecot v2.2.13 starting up
for imap (core dumps disabled)
Nov  3 20:03:03 vsrv78105 dovecot: imap-login: Login: user=,
method=PLAIN, rip=xxx, lip=xxx, mpid=14954, TLS, session=
Nov  3 20:03:03 vsrv78105 imap: antispam: plugin initialising (2.0-notgit)
Nov  3 20:03:03 vsrv78105 imap: antispam: verbose debug enabled
Nov  3 20:03:03 vsrv78105 imap: antispam: "Spam" is exact match spam folder
Nov  3 20:03:03 vsrv78105 imap: antispam: "SPAM" is exact match spam folder
Nov  3 20:03:03 vsrv78105 imap: antispam: "z_SPAM" is exact match spam
folder
Nov  3 20:03:03 vsrv78105 imap: antispam: no unsure folders
Nov  3 20:03:03 vsrv78105 imap: antispam: "Trash" is exact match trash
folder
Nov  3 20:03:03 vsrv78105 imap: antispam: "trash" is exact match trash
folder
Nov  3 20:03:03 vsrv78105 imap: antispam: pipe backend tmpdir /tmp
Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_unsure(INBOX): 0
Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_trash(z_SPAM): 0
Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_trash(INBOX): 0
Nov  3 20:03:13 vsrv78105 imap: antispam: mail copy: from trash: 0, to
trash: 0
Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_spam(z_SPAM): 0
Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_spam(INBOX): 0
Nov  3 20:03:13 vsrv78105 imap: antispam: mailbox_is_unsure(z_SPAM): 0
Nov  3 20:03:13 vsrv78105 imap: antispam: mail copy: src spam: 0, dst
spam: 0, src unsure: 0
Nov  3 20:03:14 vsrv78105 dovecot: imap-login: Login: user=,
method=PLAIN, rip=xxx, lip=xxx, mpid=14959, TLS, session=
Nov  3 20:03:14 vsrv78105 imap: antispam: plugin initialising (2.0-notgit)
Nov  3 20:03:14 vsrv78105 imap: antispam: verbose debug enabled
Nov  3 20:03:14 vsrv78105 imap: antispam: "Spam" is exact match spam folder
Nov  3 20:03:14 vsrv78105 imap: antispam: "SPAM" is exact match spam folder
Nov  3 20:03:14 vsrv78105 imap: antispam: "z_SPAM" is exact match spam
folder
Nov  3 20:03:14 vsrv78105 imap: antispam: no unsure folders
Nov  3 20:03:14 vsrv78105 imap: antispam: "Trash" is exact match trash
folder
Nov  3 20:03:14 vsrv78105 imap: antispam: "trash" is exact match trash
folder
Nov  3 20:03:14 vsrv78105 imap: antispam: pipe backend tmpdir /tmp
Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_unsure(z_SPAM): 0
Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_trash(INBOX): 0
Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_trash(z_SPAM): 0
Nov  3 20:04:05 vsrv78105 imap: antispam: mail copy: from trash: 0, to
trash: 0
Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_spam(INBOX): 0
Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_spam(z_SPAM): 0
Nov  3 20:04:05 vsrv78105 imap: antispam: mailbox_is_unsure(INBOX): 0
Nov  3 20:04:05 vsrv78105 imap: antispam: mail copy: src spam: 0, dst
spam: 0, src unsure: 0
^C

root@vsrv78105:/etc/dovecot# ls -la /tmp/
insgesamt 8864
drwxrwxrwt  8 root root   12288 Nov  3 20:07 .
drwxr-xr-x 22 root root4096 Jun 17 14:41 ..
drwxrwxrwt  2 root root4096 Nov  1 14:16 .font-unix
drwxrwxrwt  2 root root4096 Nov  1 14:16 .ICE-unix
drwxrwxrwt  2 root root4096 Nov  1 14:16 .Test-unix
drwxrwxrwt  2 root root4096 Nov  1 14:16 .X11-unix
drwxrwxrwt  2 root root4096 Nov  1 14:16 .XIM-unix

root@vsrv78105:/etc/dovecot# ls -la /etc/dovecot/sa-learn-pipe.sh
-rwxr-xr-x 1 root root 769 Nov  3 19:38 /etc/dovecot/sa-learn-pipe.sh

#

config

###
90-plugin.conf

plugin {
  #setting_name = value

  antispam_backend = pipe
  antispam_debug_target = syslog
  antispam_verbose_debug = 1
# a

Re: [patch] Improved error checking for the dovecot-antispam-plugin

2016-09-30 Thread Robert Munteanu
Hi,

Has this slipped off the radar or is it somehow not suitable for inclusion?

Thanks,

Robert

On Thu, Aug 18, 2016 at 6:16 PM, Robert Munteanu
 wrote:
> (snip)
>
>> I have no issue in resending a new version of the patch with better
>> error reporting, will do so in the following days.
>>
>> Robert
>
> I've attached a second version of the patch, feel free to consider any
> of them for inclusion.
>
> Thanks,
>
> Robert
>
>
> --
> http://robert.muntea.nu/



-- 
http://robert.muntea.nu/


Re: [patch] Improved error checking for the dovecot-antispam-plugin

2016-08-19 Thread Harlan Stenn
Robert,

First, thanks!

Second, I'm not a committer on the dovecot project. But I've written a lot of 
software where if an end user has a problem and either they want to know why or 
if they report it and ask for help, I've found it is MUCH better to have enough 
info in the message given to the user/logged somewhere. Something like:

"subroutine: open(%s) failed: %m"

It reduces our support load and gives us the information we need to quickly 
resolve issues. 

Sent from my iPhone - please excuse brevity and typos

> On Aug 18, 2016, at 8:16 AM, Robert Munteanu  
> wrote:
> 
> (snip)
> 
>> I have no issue in resending a new version of the patch with better
>> error reporting, will do so in the following days.
>> 
>> Robert
> 
> I've attached a second version of the patch, feel free to consider any
> of them for inclusion.
> 
> Thanks,
> 
> Robert
> 
> 
> -- 
> http://robert.muntea.nu/
> 


Re: antispam plugin pipe script seems not to be called when it "should be"

2016-08-19 Thread Edgar Pettijohn


Sent from my iPhone

> On Aug 19, 2016, at 11:17 AM, b...@indietorrent.org wrote:
> 
>> On 2016-08-18 22:58, Edgar Pettijohn wrote:
>>> On 16-08-18 22:43:32, Ben Johnson wrote:
>>> On 8/18/2016 10:26 PM, Ben Johnson wrote:
>>> > Hello,
>>> >
>>> > (Full "doveconf -n" output is at the end of this message.)
>>> >
>>> > I'm attempting to recreate a "recipe" I had used successfully for quite
>>> > some time (in Ubuntu 12.04 LTS), which allowed me to train
>>> > SpamAssassin's Bayes database when someone dragged an email message from
>>> > one sub-folder of the account to another.
>>> >
>>> > I later tried to re-implement it (in Ubuntu 14.04 LTS), and core-dumps
>>> > resulted. I posted to this list about it several times, but nobody was
>>> > ever able to help me solve the problem.
>>> >
>>> > I just tried the same (in Ubuntu 16.04 LTS), hoping that the source had
>>> > evolved since then, and while I don't see a core-dump, the pipe script
>>> > doesn't seem to be called.
>>> >
>>> > I've booby-trapped the pipe script with quite a bit of debugging output,
>>> > which should be written to a file, but I don't see any indication that
>>> > the pipe script is ever executed.
>>> >
>>> > When logged-in as an IMAP user, and I drag a message from the user's
>>> > Inbox into the "Spam" folder, I do see the following activity in the 
>>> > syslog:
>>> >
>>> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_unsure(Junk): 0
>>> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_trash(INBOX): 0
>>> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_trash(Junk): 0
>>> > Aug 18 22:12:15 example.com imap: antispam: mail copy: from trash: 0, to
>>> > trash: 0
>>> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_spam(INBOX): 0
>>> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_spam(Junk): 1
>>> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_unsure(INBOX): 0
>>> > Aug 18 22:12:15 example.com imap: antispam: mail copy: src spam: 0, dst
>>> > spam: 1, src unsure: 0
>>> > Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
>>> > program /bin/bash
>>> > Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
>>> > program /bin/bash
>>> > Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
>>> > program parameter 1 /usr/local/bin/sa-learn-pipe.sh
>>> > Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
>>> > program parameter 2 --spam
>>> >
>>> > But the piped message is never delivered to the target mailbox.
>>> > The mail log at /var/log/mail.log does not register any activity when I
>>> > move messages (and maybe that's expected).
>>> >
>>> > Here are the contents of the /usr/local/bin/sa-learn-pipe.sh script:
>>> >
>>> > http://pastebin.com/7vm74jmk
>>> >
>>> > The permissions and mode on the script seem appropriate:
>>> >
>>> > $ stat /usr/local/bin/sa-learn-pipe.sh
>>> >   File: '/usr/local/bin/sa-learn-pipe.sh'
>>> >   Size: 1765Blocks: 8  IO Block: 4096   regular file
>>> > Device: fd01h/64769dInode: 669345  Links: 1
>>> > Access: (0755/-rwxr-xr-x)  Uid: ( 5000/   vmail)   Gid: ( 5000/   vmail)
>>> > Access: 2016-08-18 19:09:47.307392919 -0400
>>> > Modify: 2016-08-18 19:09:31.231391749 -0400
>>> > Change: 2016-08-18 19:09:31.231391749 -0400
>>> >  Birth: -
>>> >
>>> > What might I be doing incorrectly here?
>>> >
>>> > Please let me know if I can provide any other information.
>>> >
>>> > Thank you in advance,
>>> >
>>> > -Ben
>>> >
>>> >
>>> >
>>> > Full "doveconf -n" output:
>>> >
>>> > $ doveconf -n
>>> > # 2.2.22 (fe789d2): /etc/dovecot/dovecot.conf
>>> > # Pigeonhole version 0.4.13 (7b14904)
>>> > # OS: Linux 4.4.0-34-generic x86_64 Ubuntu 16.04.1 LTS
>>> > auth_mechanisms = plain login
>>> > disable_plaintext_auth = no
>>> > listen = *,[::]
>>> > log_timestamp = "%Y-%m-%d %H:%M:%S "
>>> > mail_max_userip_connections = 100
>>> > mail_plugins = " quota"
>>> > mail_privileged_group = vmail
>>> > passdb {
>>> >   args = /etc/dovecot/dovecot-sql.conf
>>> >   driver = sql
>>> > }
>>> > plugin {
>>> >   antispam_backend = pipe
>>> >   antispam_debug_target = syslog
>>> >   antispam_pipe_program = /bin/bash
>>> >   antispam_pipe_program_args = /usr/local/bin/sa-learn-pipe.sh
>>> >   antispam_pipe_program_notspam_arg = --ham
>>> >   antispam_pipe_program_spam_arg = --spam
>>> >   antispam_pipe_tmpdir = /tmp
>>> >   antispam_spam_pattern_ignorecase = SPAM;JUNK
>>> >   antispam_trash_pattern_ignorecase = trash;Deleted *
>>> >   antispam_verbose_debug = 1
>>> >   quota = dict:user::file:/var/vmail/%d/%n/.quotausage
>>> >   quota_rule2 = Trash:storage=+100M
>>> >   quota_rule3 = Junk:ignore
>>> >   quota_rule4 = INBOX:storage=+100M
>>> >   quota_warning = storage=100%% quota-reached 100 %u %d
>>> >   quota_warning2 = storage=95%% quota-warning 95 %u %d
>>> >   quota_warning3 = storage=80%% quota-warning 80 %u %d
>>> >   quota_warning4 = -storage=100%% quota-below below %u %d
>>> >   

Re: antispam plugin pipe script seems not to be called when it "should be"

2016-08-19 Thread ben

On 2016-08-18 22:58, Edgar Pettijohn wrote:

On 16-08-18 22:43:32, Ben Johnson wrote:

On 8/18/2016 10:26 PM, Ben Johnson wrote:
> Hello,
>
> (Full "doveconf -n" output is at the end of this message.)
>
> I'm attempting to recreate a "recipe" I had used successfully for quite
> some time (in Ubuntu 12.04 LTS), which allowed me to train
> SpamAssassin's Bayes database when someone dragged an email message from
> one sub-folder of the account to another.
>
> I later tried to re-implement it (in Ubuntu 14.04 LTS), and core-dumps
> resulted. I posted to this list about it several times, but nobody was
> ever able to help me solve the problem.
>
> I just tried the same (in Ubuntu 16.04 LTS), hoping that the source had
> evolved since then, and while I don't see a core-dump, the pipe script
> doesn't seem to be called.
>
> I've booby-trapped the pipe script with quite a bit of debugging output,
> which should be written to a file, but I don't see any indication that
> the pipe script is ever executed.
>
> When logged-in as an IMAP user, and I drag a message from the user's
> Inbox into the "Spam" folder, I do see the following activity in the syslog:
>
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_unsure(Junk): 0
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_trash(INBOX): 0
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_trash(Junk): 0
> Aug 18 22:12:15 example.com imap: antispam: mail copy: from trash: 0, to
> trash: 0
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_spam(INBOX): 0
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_spam(Junk): 1
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_unsure(INBOX): 0
> Aug 18 22:12:15 example.com imap: antispam: mail copy: src spam: 0, dst
> spam: 1, src unsure: 0
> Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> program /bin/bash
> Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> program /bin/bash
> Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> program parameter 1 /usr/local/bin/sa-learn-pipe.sh
> Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> program parameter 2 --spam
>
> But the piped message is never delivered to the target mailbox.
> The mail log at /var/log/mail.log does not register any activity when I
> move messages (and maybe that's expected).
>
> Here are the contents of the /usr/local/bin/sa-learn-pipe.sh script:
>
> http://pastebin.com/7vm74jmk
>
> The permissions and mode on the script seem appropriate:
>
> $ stat /usr/local/bin/sa-learn-pipe.sh
>   File: '/usr/local/bin/sa-learn-pipe.sh'
>   Size: 1765Blocks: 8  IO Block: 4096   regular file
> Device: fd01h/64769dInode: 669345  Links: 1
> Access: (0755/-rwxr-xr-x)  Uid: ( 5000/   vmail)   Gid: ( 5000/   vmail)
> Access: 2016-08-18 19:09:47.307392919 -0400
> Modify: 2016-08-18 19:09:31.231391749 -0400
> Change: 2016-08-18 19:09:31.231391749 -0400
>  Birth: -
>
> What might I be doing incorrectly here?
>
> Please let me know if I can provide any other information.
>
> Thank you in advance,
>
> -Ben
>
>
>
> Full "doveconf -n" output:
>
> $ doveconf -n
> # 2.2.22 (fe789d2): /etc/dovecot/dovecot.conf
> # Pigeonhole version 0.4.13 (7b14904)
> # OS: Linux 4.4.0-34-generic x86_64 Ubuntu 16.04.1 LTS
> auth_mechanisms = plain login
> disable_plaintext_auth = no
> listen = *,[::]
> log_timestamp = "%Y-%m-%d %H:%M:%S "
> mail_max_userip_connections = 100
> mail_plugins = " quota"
> mail_privileged_group = vmail
> passdb {
>   args = /etc/dovecot/dovecot-sql.conf
>   driver = sql
> }
> plugin {
>   antispam_backend = pipe
>   antispam_debug_target = syslog
>   antispam_pipe_program = /bin/bash
>   antispam_pipe_program_args = /usr/local/bin/sa-learn-pipe.sh
>   antispam_pipe_program_notspam_arg = --ham
>   antispam_pipe_program_spam_arg = --spam
>   antispam_pipe_tmpdir = /tmp
>   antispam_spam_pattern_ignorecase = SPAM;JUNK
>   antispam_trash_pattern_ignorecase = trash;Deleted *
>   antispam_verbose_debug = 1
>   quota = dict:user::file:/var/vmail/%d/%n/.quotausage
>   quota_rule2 = Trash:storage=+100M
>   quota_rule3 = Junk:ignore
>   quota_rule4 = INBOX:storage=+100M
>   quota_warning = storage=100%% quota-reached 100 %u %d
>   quota_warning2 = storage=95%% quota-warning 95 %u %d
>   quota_warning3 = storage=80%% quota-warning 80 %u %d
>   quota_warning4 = -storage=100%% quota-below below %u %d
>   sieve = /var/vmail/%d/%n/.sieve
>   sieve_max_redirects = 25
> }
> postmaster_address = postmas...@example.com
> protocols = imap pop3
> service auth {
>   unix_listener /var/spool/postfix/private/auth {
> group = postfix
> mode = 0660
> user = postfix
>   }
>   unix_listener auth-userdb {
> group = vmail
> mode = 0600
> user = vmail
>   }
>   user = root
> }
> service imap-login {
>   client_limit = 1000
>   process_limit = 512
> }
> service lmtp {
>   unix_listener /var/spool/postfix/private/dovecot-lmtp {
> 

Re: antispam plugin pipe script seems not to be called when it "should be"

2016-08-18 Thread Edgar Pettijohn
On 16-08-18 22:43:32, Ben Johnson wrote:
> On 8/18/2016 10:26 PM, Ben Johnson wrote:
> > Hello,
> > 
> > (Full "doveconf -n" output is at the end of this message.)
> > 
> > I'm attempting to recreate a "recipe" I had used successfully for quite
> > some time (in Ubuntu 12.04 LTS), which allowed me to train
> > SpamAssassin's Bayes database when someone dragged an email message from
> > one sub-folder of the account to another.
> > 
> > I later tried to re-implement it (in Ubuntu 14.04 LTS), and core-dumps
> > resulted. I posted to this list about it several times, but nobody was
> > ever able to help me solve the problem.
> > 
> > I just tried the same (in Ubuntu 16.04 LTS), hoping that the source had
> > evolved since then, and while I don't see a core-dump, the pipe script
> > doesn't seem to be called.
> > 
> > I've booby-trapped the pipe script with quite a bit of debugging output,
> > which should be written to a file, but I don't see any indication that
> > the pipe script is ever executed.
> > 
> > When logged-in as an IMAP user, and I drag a message from the user's
> > Inbox into the "Spam" folder, I do see the following activity in the syslog:
> > 
> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_unsure(Junk): 0
> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_trash(INBOX): 0
> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_trash(Junk): 0
> > Aug 18 22:12:15 example.com imap: antispam: mail copy: from trash: 0, to
> > trash: 0
> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_spam(INBOX): 0
> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_spam(Junk): 1
> > Aug 18 22:12:15 example.com imap: antispam: mailbox_is_unsure(INBOX): 0
> > Aug 18 22:12:15 example.com imap: antispam: mail copy: src spam: 0, dst
> > spam: 1, src unsure: 0
> > Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> > program /bin/bash
> > Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> > program /bin/bash
> > Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> > program parameter 1 /usr/local/bin/sa-learn-pipe.sh
> > Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> > program parameter 2 --spam
> > 
> > But the piped message is never delivered to the target mailbox.
> > The mail log at /var/log/mail.log does not register any activity when I
> > move messages (and maybe that's expected).
> > 
> > Here are the contents of the /usr/local/bin/sa-learn-pipe.sh script:
> > 
> > http://pastebin.com/7vm74jmk
> > 
> > The permissions and mode on the script seem appropriate:
> > 
> > $ stat /usr/local/bin/sa-learn-pipe.sh
> >   File: '/usr/local/bin/sa-learn-pipe.sh'
> >   Size: 1765Blocks: 8  IO Block: 4096   regular file
> > Device: fd01h/64769dInode: 669345  Links: 1
> > Access: (0755/-rwxr-xr-x)  Uid: ( 5000/   vmail)   Gid: ( 5000/   vmail)
> > Access: 2016-08-18 19:09:47.307392919 -0400
> > Modify: 2016-08-18 19:09:31.231391749 -0400
> > Change: 2016-08-18 19:09:31.231391749 -0400
> >  Birth: -
> > 
> > What might I be doing incorrectly here?
> > 
> > Please let me know if I can provide any other information.
> > 
> > Thank you in advance,
> > 
> > -Ben
> > 
> > 
> > 
> > Full "doveconf -n" output:
> > 
> > $ doveconf -n
> > # 2.2.22 (fe789d2): /etc/dovecot/dovecot.conf
> > # Pigeonhole version 0.4.13 (7b14904)
> > # OS: Linux 4.4.0-34-generic x86_64 Ubuntu 16.04.1 LTS
> > auth_mechanisms = plain login
> > disable_plaintext_auth = no
> > listen = *,[::]
> > log_timestamp = "%Y-%m-%d %H:%M:%S "
> > mail_max_userip_connections = 100
> > mail_plugins = " quota"
> > mail_privileged_group = vmail
> > passdb {
> >   args = /etc/dovecot/dovecot-sql.conf
> >   driver = sql
> > }
> > plugin {
> >   antispam_backend = pipe
> >   antispam_debug_target = syslog
> >   antispam_pipe_program = /bin/bash
> >   antispam_pipe_program_args = /usr/local/bin/sa-learn-pipe.sh
> >   antispam_pipe_program_notspam_arg = --ham
> >   antispam_pipe_program_spam_arg = --spam
> >   antispam_pipe_tmpdir = /tmp
> >   antispam_spam_pattern_ignorecase = SPAM;JUNK
> >   antispam_trash_pattern_ignorecase = trash;Deleted *
> >   antispam_verbose_debug = 1
> >   quota = dict:user::file:/var/vmail/%d/%n/.quotausage
> >   quota_rule2 = Trash:storage=+100M
> >   quota_rule3 = Junk:ignore
> >   quota_rule4 = INBOX:storage=+100M
> >   quota_warning = storage=100%% quota-reached 100 %u %d
> >   quota_warning2 = storage=95%% quota-warning 95 %u %d
> >   quota_warning3 = storage=80%% quota-warning 80 %u %d
> >   quota_warning4 = -storage=100%% quota-below below %u %d
> >   sieve = /var/vmail/%d/%n/.sieve
> >   sieve_max_redirects = 25
> > }
> > postmaster_address = postmas...@example.com
> > protocols = imap pop3
> > service auth {
> >   unix_listener /var/spool/postfix/private/auth {
> > group = postfix
> > mode = 0660
> > user = postfix
> >   }
> >   unix_listener auth-userdb {
> > group = vmail
> >  

Re: antispam plugin pipe script seems not to be called when it "should be"

2016-08-18 Thread Ben Johnson
On 8/18/2016 10:26 PM, Ben Johnson wrote:
> Hello,
> 
> (Full "doveconf -n" output is at the end of this message.)
> 
> I'm attempting to recreate a "recipe" I had used successfully for quite
> some time (in Ubuntu 12.04 LTS), which allowed me to train
> SpamAssassin's Bayes database when someone dragged an email message from
> one sub-folder of the account to another.
> 
> I later tried to re-implement it (in Ubuntu 14.04 LTS), and core-dumps
> resulted. I posted to this list about it several times, but nobody was
> ever able to help me solve the problem.
> 
> I just tried the same (in Ubuntu 16.04 LTS), hoping that the source had
> evolved since then, and while I don't see a core-dump, the pipe script
> doesn't seem to be called.
> 
> I've booby-trapped the pipe script with quite a bit of debugging output,
> which should be written to a file, but I don't see any indication that
> the pipe script is ever executed.
> 
> When logged-in as an IMAP user, and I drag a message from the user's
> Inbox into the "Spam" folder, I do see the following activity in the syslog:
> 
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_unsure(Junk): 0
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_trash(INBOX): 0
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_trash(Junk): 0
> Aug 18 22:12:15 example.com imap: antispam: mail copy: from trash: 0, to
> trash: 0
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_spam(INBOX): 0
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_spam(Junk): 1
> Aug 18 22:12:15 example.com imap: antispam: mailbox_is_unsure(INBOX): 0
> Aug 18 22:12:15 example.com imap: antispam: mail copy: src spam: 0, dst
> spam: 1, src unsure: 0
> Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> program /bin/bash
> Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> program /bin/bash
> Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> program parameter 1 /usr/local/bin/sa-learn-pipe.sh
> Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
> program parameter 2 --spam
> 
> But the piped message is never delivered to the target mailbox.
> The mail log at /var/log/mail.log does not register any activity when I
> move messages (and maybe that's expected).
> 
> Here are the contents of the /usr/local/bin/sa-learn-pipe.sh script:
> 
> http://pastebin.com/7vm74jmk
> 
> The permissions and mode on the script seem appropriate:
> 
> $ stat /usr/local/bin/sa-learn-pipe.sh
>   File: '/usr/local/bin/sa-learn-pipe.sh'
>   Size: 1765Blocks: 8  IO Block: 4096   regular file
> Device: fd01h/64769dInode: 669345  Links: 1
> Access: (0755/-rwxr-xr-x)  Uid: ( 5000/   vmail)   Gid: ( 5000/   vmail)
> Access: 2016-08-18 19:09:47.307392919 -0400
> Modify: 2016-08-18 19:09:31.231391749 -0400
> Change: 2016-08-18 19:09:31.231391749 -0400
>  Birth: -
> 
> What might I be doing incorrectly here?
> 
> Please let me know if I can provide any other information.
> 
> Thank you in advance,
> 
> -Ben
> 
> 
> 
> Full "doveconf -n" output:
> 
> $ doveconf -n
> # 2.2.22 (fe789d2): /etc/dovecot/dovecot.conf
> # Pigeonhole version 0.4.13 (7b14904)
> # OS: Linux 4.4.0-34-generic x86_64 Ubuntu 16.04.1 LTS
> auth_mechanisms = plain login
> disable_plaintext_auth = no
> listen = *,[::]
> log_timestamp = "%Y-%m-%d %H:%M:%S "
> mail_max_userip_connections = 100
> mail_plugins = " quota"
> mail_privileged_group = vmail
> passdb {
>   args = /etc/dovecot/dovecot-sql.conf
>   driver = sql
> }
> plugin {
>   antispam_backend = pipe
>   antispam_debug_target = syslog
>   antispam_pipe_program = /bin/bash
>   antispam_pipe_program_args = /usr/local/bin/sa-learn-pipe.sh
>   antispam_pipe_program_notspam_arg = --ham
>   antispam_pipe_program_spam_arg = --spam
>   antispam_pipe_tmpdir = /tmp
>   antispam_spam_pattern_ignorecase = SPAM;JUNK
>   antispam_trash_pattern_ignorecase = trash;Deleted *
>   antispam_verbose_debug = 1
>   quota = dict:user::file:/var/vmail/%d/%n/.quotausage
>   quota_rule2 = Trash:storage=+100M
>   quota_rule3 = Junk:ignore
>   quota_rule4 = INBOX:storage=+100M
>   quota_warning = storage=100%% quota-reached 100 %u %d
>   quota_warning2 = storage=95%% quota-warning 95 %u %d
>   quota_warning3 = storage=80%% quota-warning 80 %u %d
>   quota_warning4 = -storage=100%% quota-below below %u %d
>   sieve = /var/vmail/%d/%n/.sieve
>   sieve_max_redirects = 25
> }
> postmaster_address = postmas...@example.com
> protocols = imap pop3
> service auth {
>   unix_listener /var/spool/postfix/private/auth {
> group = postfix
> mode = 0660
> user = postfix
>   }
>   unix_listener auth-userdb {
> group = vmail
> mode = 0600
> user = vmail
>   }
>   user = root
> }
> service imap-login {
>   client_limit = 1000
>   process_limit = 512
> }
> service lmtp {
>   unix_listener /var/spool/postfix/private/dovecot-lmtp {
> group = postfix
> mode = 0600
> user = postfix
>   }
> }
> 

antispam plugin pipe script seems not to be called when it "should be"

2016-08-18 Thread Ben Johnson
Hello,

(Full "doveconf -n" output is at the end of this message.)

I'm attempting to recreate a "recipe" I had used successfully for quite
some time (in Ubuntu 12.04 LTS), which allowed me to train
SpamAssassin's Bayes database when someone dragged an email message from
one sub-folder of the account to another.

I later tried to re-implement it (in Ubuntu 14.04 LTS), and core-dumps
resulted. I posted to this list about it several times, but nobody was
ever able to help me solve the problem.

I just tried the same (in Ubuntu 16.04 LTS), hoping that the source had
evolved since then, and while I don't see a core-dump, the pipe script
doesn't seem to be called.

I've booby-trapped the pipe script with quite a bit of debugging output,
which should be written to a file, but I don't see any indication that
the pipe script is ever executed.

When logged-in as an IMAP user, and I drag a message from the user's
Inbox into the "Spam" folder, I do see the following activity in the syslog:

Aug 18 22:12:15 example.com imap: antispam: mailbox_is_unsure(Junk): 0
Aug 18 22:12:15 example.com imap: antispam: mailbox_is_trash(INBOX): 0
Aug 18 22:12:15 example.com imap: antispam: mailbox_is_trash(Junk): 0
Aug 18 22:12:15 example.com imap: antispam: mail copy: from trash: 0, to
trash: 0
Aug 18 22:12:15 example.com imap: antispam: mailbox_is_spam(INBOX): 0
Aug 18 22:12:15 example.com imap: antispam: mailbox_is_spam(Junk): 1
Aug 18 22:12:15 example.com imap: antispam: mailbox_is_unsure(INBOX): 0
Aug 18 22:12:15 example.com imap: antispam: mail copy: src spam: 0, dst
spam: 1, src unsure: 0
Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
program /bin/bash
Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
program /bin/bash
Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
program parameter 1 /usr/local/bin/sa-learn-pipe.sh
Aug 18 22:12:15 example.com imap: antispam: running mailtrain backend
program parameter 2 --spam

But the piped message is never delivered to the target mailbox.
The mail log at /var/log/mail.log does not register any activity when I
move messages (and maybe that's expected).

Here are the contents of the /usr/local/bin/sa-learn-pipe.sh script:

http://pastebin.com/7vm74jmk

The permissions and mode on the script seem appropriate:

$ stat /usr/local/bin/sa-learn-pipe.sh
  File: '/usr/local/bin/sa-learn-pipe.sh'
  Size: 1765Blocks: 8  IO Block: 4096   regular file
Device: fd01h/64769dInode: 669345  Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 5000/   vmail)   Gid: ( 5000/   vmail)
Access: 2016-08-18 19:09:47.307392919 -0400
Modify: 2016-08-18 19:09:31.231391749 -0400
Change: 2016-08-18 19:09:31.231391749 -0400
 Birth: -

What might I be doing incorrectly here?

Please let me know if I can provide any other information.

Thank you in advance,

-Ben



Full "doveconf -n" output:

$ doveconf -n
# 2.2.22 (fe789d2): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.13 (7b14904)
# OS: Linux 4.4.0-34-generic x86_64 Ubuntu 16.04.1 LTS
auth_mechanisms = plain login
disable_plaintext_auth = no
listen = *,[::]
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_max_userip_connections = 100
mail_plugins = " quota"
mail_privileged_group = vmail
passdb {
  args = /etc/dovecot/dovecot-sql.conf
  driver = sql
}
plugin {
  antispam_backend = pipe
  antispam_debug_target = syslog
  antispam_pipe_program = /bin/bash
  antispam_pipe_program_args = /usr/local/bin/sa-learn-pipe.sh
  antispam_pipe_program_notspam_arg = --ham
  antispam_pipe_program_spam_arg = --spam
  antispam_pipe_tmpdir = /tmp
  antispam_spam_pattern_ignorecase = SPAM;JUNK
  antispam_trash_pattern_ignorecase = trash;Deleted *
  antispam_verbose_debug = 1
  quota = dict:user::file:/var/vmail/%d/%n/.quotausage
  quota_rule2 = Trash:storage=+100M
  quota_rule3 = Junk:ignore
  quota_rule4 = INBOX:storage=+100M
  quota_warning = storage=100%% quota-reached 100 %u %d
  quota_warning2 = storage=95%% quota-warning 95 %u %d
  quota_warning3 = storage=80%% quota-warning 80 %u %d
  quota_warning4 = -storage=100%% quota-below below %u %d
  sieve = /var/vmail/%d/%n/.sieve
  sieve_max_redirects = 25
}
postmaster_address = postmas...@example.com
protocols = imap pop3
service auth {
  unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
  }
  unix_listener auth-userdb {
group = vmail
mode = 0600
user = vmail
  }
  user = root
}
service imap-login {
  client_limit = 1000
  process_limit = 512
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
  }
}
service quota-below {
  executable = script /usr/local/bin/quota-below.sh
  unix_listener quota-below {
group = vmail
mode = 0666
user = vmail
  }
  user = vmail
}
service quota-reached {
  executable = script /usr/local/bin/quota-reached.sh
  unix_listener quota-reached {
group = vmail
mode = 0666

Re: [patch] Improved error checking for the dovecot-antispam-plugin

2016-08-18 Thread Robert Munteanu
(snip)

> I have no issue in resending a new version of the patch with better
> error reporting, will do so in the following days.
>
> Robert

I've attached a second version of the patch, feel free to consider any
of them for inclusion.

Thanks,

Robert


-- 
http://robert.muntea.nu/
changeset:   52:cce5dec86998
tag: tip
user:Robert Munteanu 
date:Fri Aug 12 15:33:12 2016 +0300
summary: Validate that mail_sendfile exists and is executable

diff -r 5ebc6aae4d7c -r cce5dec86998 src/mailtrain.c
--- a/src/mailtrain.c	Mon Apr 29 14:59:26 2013 +0200
+++ b/src/mailtrain.c	Fri Aug 12 15:33:12 2016 +0300
@@ -26,6 +26,7 @@
 #include "str.h"
 #include "istream.h"
 #include "ostream.h"
+#include "unistd.h"
 
 #include "aux.h"
 #include "backends.h"
@@ -107,6 +108,21 @@
 const char *dest = spam ? cfg->spam : cfg->non_spam;
 pid_t pid;
 int status;
+const char *err_msg;
+
+if (access(cfg->binary, F_OK) == -1)
+{
+err_msg = t_strdup_printf("Unable to read antispam_mail_sendfile file '%s'", cfg->binary);
+mail_storage_set_error(storage, MAIL_ERROR_TEMP, err_msg);
+return -1;
+}
+
+if (access(cfg->binary, X_OK) == -1)
+{
+err_msg = t_strdup_printf("Missing execute permissions on antispam_mail_sendfile file '%s'", cfg->binary);
+mail_storage_set_error(storage, MAIL_ERROR_TEMP, err_msg);
+return -1;
+}
 
 pid = fork();
 



Re: [patch] Improved error checking for the dovecot-antispam-plugin

2016-08-18 Thread Robert Munteanu
Hi Harlan,

On Wed, Aug 17, 2016 at 2:18 AM, Harlan Stenn <har...@pfcs.com> wrote:
> On 8/16/16 1:24 PM, Robert Munteanu wrote:
>> Hi,
>>
>> Hopefully this is the right channel for such a patch. I have a minor
>> enhancement to submit for the antispam plugin
>>
>>   http://hg.dovecot.org/dovecot-antispam-plugin
>>
>> It adds minimal error checking for the sendmail_binary, otherwise the
>> reported error in case of a missing binary or one with missing
>> permissions is generic and not useful.
>>
>> Thanks,
>>
>> Robert
>
> Robert, I like that you did this.
>
> Beyond that and without even looking at the actual code, I'm curious why
> you:
>
> +if (access(cfg->binary, F_OK) == -1)
> +{
> +mail_storage_set_error(storage, MAIL_ERROR_TEMP, "mail_sendmail
> file does not exist");
>
> instead of finding a way to include the value of cfg->binary in the
> error message string.
>
> This might not be needed if it's really obvious from the config file
> what the path to the executable is, but if there is any doubt it might
> be friendlier to show the exact path with the problem.  I'd also be
> inclined to show the decoded value of errno instead of assuming that
> 'mail_sendmail file does not exist'.
>
> Perhaps something along the lines of:
>
> "access(%s, F_OK) failed: %m", cfg->binary
>
> if that makes sense.

Thanks for the review . I was not sure that it's OK to show the path
to the script in an error message which will be shown to the user. But
I have no issue in resending a new version of the patch with better
error reporting, will do so in the following days.

Robert



-- 
http://robert.muntea.nu/


Re: [patch] Improved error checking for the dovecot-antispam-plugin

2016-08-17 Thread Aki Tuomi


On 17.08.2016 02:18, Harlan Stenn wrote:
> On 8/16/16 1:24 PM, Robert Munteanu wrote:
>> Hi,
>>
>> Hopefully this is the right channel for such a patch. I have a minor
>> enhancement to submit for the antispam plugin
>>
>>   http://hg.dovecot.org/dovecot-antispam-plugin
>>
>> It adds minimal error checking for the sendmail_binary, otherwise the
>> reported error in case of a missing binary or one with missing
>> permissions is generic and not useful.
>>
>> Thanks,
>>
>> Robert
> Robert, I like that you did this.
>
> Beyond that and without even looking at the actual code, I'm curious why
> you:
>
> +if (access(cfg->binary, F_OK) == -1)
> +{
> +mail_storage_set_error(storage, MAIL_ERROR_TEMP, "mail_sendmail
> file does not exist");
>
> instead of finding a way to include the value of cfg->binary in the
> error message string.
>
> This might not be needed if it's really obvious from the config file
> what the path to the executable is, but if there is any doubt it might
> be friendlier to show the exact path with the problem.  I'd also be
> inclined to show the decoded value of errno instead of assuming that
> 'mail_sendmail file does not exist'.
>
> Perhaps something along the lines of:
>
>   "access(%s, F_OK) failed: %m", cfg->binary
>
> if that makes sense.
>
> H
Hi!

Thank you for your patch, we'll take it under consideration!

Aki


Re: [patch] Improved error checking for the dovecot-antispam-plugin

2016-08-16 Thread Harlan Stenn
On 8/16/16 1:24 PM, Robert Munteanu wrote:
> Hi,
> 
> Hopefully this is the right channel for such a patch. I have a minor
> enhancement to submit for the antispam plugin
> 
>   http://hg.dovecot.org/dovecot-antispam-plugin
> 
> It adds minimal error checking for the sendmail_binary, otherwise the
> reported error in case of a missing binary or one with missing
> permissions is generic and not useful.
> 
> Thanks,
> 
> Robert

Robert, I like that you did this.

Beyond that and without even looking at the actual code, I'm curious why
you:

+if (access(cfg->binary, F_OK) == -1)
+{
+mail_storage_set_error(storage, MAIL_ERROR_TEMP, "mail_sendmail
file does not exist");

instead of finding a way to include the value of cfg->binary in the
error message string.

This might not be needed if it's really obvious from the config file
what the path to the executable is, but if there is any doubt it might
be friendlier to show the exact path with the problem.  I'd also be
inclined to show the decoded value of errno instead of assuming that
'mail_sendmail file does not exist'.

Perhaps something along the lines of:

"access(%s, F_OK) failed: %m", cfg->binary

if that makes sense.

H


[patch] Improved error checking for the dovecot-antispam-plugin

2016-08-16 Thread Robert Munteanu
Hi,

Hopefully this is the right channel for such a patch. I have a minor
enhancement to submit for the antispam plugin

  http://hg.dovecot.org/dovecot-antispam-plugin

It adds minimal error checking for the sendmail_binary, otherwise the
reported error in case of a missing binary or one with missing
permissions is generic and not useful.

Thanks,

Robert

-- 
http://robert.muntea.nu/
# HG changeset patch
# User Robert Munteanu <rob...@lmn.ro>
# Date 1471005192 -10800
#  Fri Aug 12 15:33:12 2016 +0300
# Node ID 21a6999ba3d0ce670f790ce314d106bb9e23e337
# Parent  5ebc6aae4d7ce9ad4c53c1efe5b7f280e967d8a9
Validate that mail_sendfile exists and is executable

This prevents more cryptic errors from being raised to the users.

diff -r 5ebc6aae4d7c -r 21a6999ba3d0 src/mailtrain.c
--- a/src/mailtrain.c	Mon Apr 29 14:59:26 2013 +0200
+++ b/src/mailtrain.c	Fri Aug 12 15:33:12 2016 +0300
@@ -26,6 +26,7 @@
 #include "str.h"
 #include "istream.h"
 #include "ostream.h"
+#include "unistd.h"
 
 #include "aux.h"
 #include "backends.h"
@@ -108,6 +109,18 @@
 pid_t pid;
 int status;
 
+if (access(cfg->binary, F_OK) == -1)
+{
+mail_storage_set_error(storage, MAIL_ERROR_TEMP, "mail_sendmail file does not exist");
+return -1;
+}
+
+if (access(cfg->binary, X_OK) == -1)
+{
+mail_storage_set_error(storage, MAIL_ERROR_TEMP, "missing execute permissions on mail_sendmail");
+return -1;
+}
+
 pid = fork();
 
 if (pid == -1)


Suggested improvement for antispam plugin documentation

2016-07-21 Thread Ralph Seichter
Hello,

I struggled a bit with getting the antispam plugin to work, because the
plugin configuration in http://wiki2.dovecot.org/Plugins/Antispam is
incomplete. After some twiddling, I ended up with this:

  # /etc/dovecot/conf.d/90-plugin.conf
  plugin {
antispam_backend = mailtrain
antispam_mail_spam = spam
antispam_mail_notspam = ham
antispam_mail_sendmail = /path/to/mailtrain/script
antispam_spam = Junk;Spam
antispam_trash = Deleted Messages;Trash
  }

I know that the antispam plugin has not yet been officially released,
but I think it might be worth updating the documentation anyway. Your
thoughts?

-Ralph


Re: antispam plugin pipe backend error when moving multiple emails

2016-04-18 Thread Stéphane Cottin

Hello,

I'm bumping this because it still occurs with dovecot 2.2.22.

my dovecot-antispam plugin configuration :

  antispam_allow_append_to_spam = no
  antispam_backend = pipe
  antispam_pipe_program = /usr/bin/rspamc
  antispam_pipe_program_args = -h;127.0.0.1:11334;-P;
  antispam_pipe_program_notspam_arg = learn_ham
  antispam_pipe_program_spam_arg = learn_spam
  antispam_pipe_tmpdir = /var/tmp
  antispam_spam = Junk
  antispam_trash = trash;Trash;Deleted Items;Deleted Messages

zlib enabled:
  zlib_save = gz
  zlib_save_level = 9


When moving 2 or more messages from inbox to the Junk folder:

"J47 NO [CANNOT] Failed to copy to temporary file (0.000 + 0.000 
secs).”. Command attempted: “J47 UID MOVE 106318:106319 Junk"


or sometimes

"J123 NO [CANNOT] Failed to read mail beginning (0.000 + 0.000 
secs).”. Command attempted: “J123 UID MOVE 170789:170790 Junk"


and still have the "Cached message size smaller..." in dovecot logs.

It occurs at least when header lines of an email contains Non-ASCII Text 
(rfc1342).

Batches of full ascii emails are not affected.

I can easily reproduce this from/to the Junk folder, but had unconfirmed 
reports of similar errors when batch moving mails across regular 
folders.


Stéphane


On 8 Nov 2015, at 11:50, Stéphane Cottin wrote:


Hi,

I've got some trouble with the dovecot antispam plugin and the pipe 
backend.


I'm using dovecot 2.2.18 with maildirs and zlib compression enabled.

When moving 2 or more emails at once from the Junk folder to another 
one, I always have the following error : "Failed to copy to temporary 
file"


In the server logs :

imap(v...@vvv.vvv): Error: 
read(zlib(/data/Maildir/.test/tmp/1446974366.M123890P936.vvv)) failed: 
Cached message size smaller than expected (13553 < 13562, box=test, 
UID=0)


The same operation with one email at a time, on the same emails, works 
as expected.


Stéphane


Re: antispam plugin, pipe backend, how to make it work?

2016-04-13 Thread deano-dovecot

Johannes -

I'm running 2.2.9 under Ubuntu 14.04.  I gave up on using the pipe 
backend, just could not get the damn thing to work.  I would up using 
spool2dir and incron, which works perfectly.  The issue was that 
sa-learn would cause a pthread_cancel error with libgcc_s.so.1


Below is an excerpt from my install script :


  # Enable antispam - Damn, not working right with pipe backend
  # now using spool2dir and incron
  if [ -e /etc/spamassassin ]; then
sed -i "
  s/^  #mail_plugins.*/  mail_plugins = \$mail_plugins antispam 
${DOVENOTIFY}/

  s/^  #mail_max_userip.*/mail_max_userip_connections = 20/
" /etc/dovecot/conf.d/20-imap.conf
cat > /etc/dovecot/conf.d/99-Installerbox-antispam.conf << EOF
##
## antispam configuration
##
plugin {
  antispam_debug_target = syslog
  # antispam_verbose_debug = 1
  antispam_trash_pattern = Trash;Deleted *
  antispam_spam = Junk;Spam

  antispam_backend = spool2dir
  antispam_spool2dir_spam = 
/var/cache/dovecot-antispam/spam/%%020lu-%u-%%05luS
  antispam_spool2dir_notspam =  
/var/cache/dovecot-antispam/ham/%%020lu-%u-%%05luH


  # pipe backend not working with sa-learn - causes pthread_cancel error 
with libgcc_s.so.1

  # antispam_backend = pipe
  # antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
  # antispam_pipe_program_args = --for;%u
  # antispam_pipe_program_spam_arg = --spam
  # antispam_pipe_program_notspam_arg = --ham
  # antispam_pipe_tmpdir = /tmp
}
EOF

# incron watches the spam/ham spool dirs, calls sa-learn-pipe.sh to 
handle

echo "root" >> /etc/incron.allow
mkdir -p /var/cache/dovecot-antispam/spam 
/var/cache/dovecot-antispam/ham

chown -R ${VMAIL_ID}.dovecot /var/cache/dovecot-antispam/
cat > /var/spool/incron/root << "EOF"
/var/cache/dovecot-antispam/spam IN_CLOSE_WRITE 
/usr/local/bin/sa-learn-pipe.sh --spam 
/var/cache/dovecot-antispam/spam/$#
/var/cache/dovecot-antispam/ham IN_CLOSE_WRITE 
/usr/local/bin/sa-learn-pipe.sh --ham /var/cache/dovecot-antispam/ham/$#

EOF
chgrp incron /var/spool/incron/root
chmod 600 /var/spool/incron/root

# inotify needs a little more room to breath - default of 128 too 
low

cat > /etc/sysctl.d/60-inotify.conf << EOF
# inotify changes for Dovecot
# http://dovecot.org/list/dovecot/2011-March/058300.html

# Defaults are
# fs.inotify.max_queued_events = 16384
# fs.inotify.max_user_instances = 128
# fs.inotify.max_user_watches = 8192

fs.inotify.max_user_instances = 2048
EOF

# spamassassin learning script
cat > /usr/local/bin/sa-learn-pipe.sh << "EOFSPAM"
#!/bin/bash
# Pipe script to learn/unlearn single email file
# Set to read from file or from stdin
# From stdin to accomodate dovecot-antispam pipe backend (nor currently 
working)


# echo /usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt
FILE=`echo $* | sed "s/^.* //"`
echo "$$-start ($*)" >> /var/log/sa-learn-pipe.log
echo -n "$$ " >> /var/log/sa-learn-pipe.log
egrep --no-filename "^Subject: " /tmp/sendmail-msg-$$.txt ${FILE} | head 
-1 >> /var/log/sa-learn-pipe.log

cat<&0 >> /tmp/sendmail-msg-$$.txt
/usr/bin/sa-learn --progress $* /tmp/sendmail-msg-$$.txt >> 
/tmp/sa-learn-pipe.$$.log 2>&1

echo $$ sa-learn rc=$? id=$(id) HOME=$HOME >> /var/log/sa-learn-pipe.log

while read line; do
  echo $$-sa-learn "$line" >> /var/log/sa-learn-pipe.log
done < /tmp/sa-learn-pipe.$$.log

rm -f /tmp/sendmail-msg-$$.txt /tmp/sa-learn-pipe.$$.log
rm -f ${FILE}
echo "$$-end" >> /var/log/sa-learn-pipe.log

exit 0
EOFSPAM
chmod 755 /usr/local/bin/sa-learn-pipe.sh
touch /var/log/sa-learn-pipe.log
chown ${VMAIL_ID}.dovecot /var/log/sa-learn-pipe.log
chmod 660 /var/log/sa-learn-pipe.log
cat > /etc/logrotate.d/sa-learn-pipe.log << EOFLOG
/var/log/sa-learn-pipe.log {
daily
missingok
rotate 10
compress
delaycompress
notifempty
create 660 ${VMAIL_ID} dovecot
}
EOFLOG
  fi # spamassassin




On 2016-04-12 14:14, Johannes Rohr wrote:

Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise with
the antispam plugin in version  2.0+20120225-2 and spamassassin at
version 3.2.2

I have been trying and failed to get the pipe backend of the antispam
plugin to work. Spamassin by itself works, a manual call of sa-learn
works fine. Bayes data is stored in a mysql DB.

I have the following configuration in 
/etc/dovecot/conf.d/90-plugin.conf


plugin {
  #setting_name = value
  sieve=~/.dovecot.sieve
  sieve_dir=~/sieve
antispam_pipe_program_spam_arg = --spam
antispam_pipe_program_notspam_arg  = --ham
antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
antispam_pipe_program_args = --username=%u # % expansion done by 
dovec

Re: antispam plugin, pipe backend, how to make it work?

2016-04-13 Thread Florian Mutter

> Am 13.04.2016 um 12:14 schrieb Johannes Rohr :
> 
> Yikes! Our server is running a fairly dated Ubuntu Precise, what's your 
> version? Did an upgrade fail to fix it? I am not seeing this error on Debian 
> Sid but I am not using virtual users over here, so that might be the cause. 
> Did you report the bug to the Spamassassin bugzilla?

I’m running Debian 8 (Jessie). Dovecot is version 2.2.13, Dovecot Antispam is 
2.0+20130912-2 and SpamAssassin is 3.4.0. I did not fill a bug but I see you 
already did it.

Re: antispam plugin, pipe backend, how to make it work?

2016-04-13 Thread Johannes Rohr

Am 13.04.2016 um 11:54 schrieb Florian Mutter:

Am 13.04.2016 um 10:35 schrieb Johannes Rohr :

tweaked the wrapper script to make it work. It seems like the sa-learn call 
silently fails:

"/usr/local/bin/sa-learn-pipe.sh" 10L, 350C geschrieben
root@vm10:/etc/dovecot/conf.d# cat /tmp/sa-learn-pipe.log
starting log
25200-start (--username=johan...@rohr.org --spam)
libgcc_s.so.1 must be installed for pthread_cancel to work
25200-end

Does the above error message have anything to do with it? Running the script & 
sa-learn manually works fine. do virtual users change something how dovecot calls 
programs, such as chrooting them?

Here [1] is an old thread about that problem.In short: It seems to be a problem 
in sa-learn that is triggered by the privilege drop that dovecot does when 
starting.

I have the same problem and I have not found a solution yet.


I have just filed a bug with spamassassin, 
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7309


I am not sure that they will act upon it, as it is an old version, and 
SA isn't the ultimate cause anyway.


Cheers,

Johannes




[1] http://www.dovecot.org/list/dovecot/2013-November/093378.html


Cheers,

Johannes


Re: antispam plugin, pipe backend, how to make it work?

2016-04-13 Thread Johannes Rohr

Am 13.04.2016 um 11:54 schrieb Florian Mutter:

Am 13.04.2016 um 10:35 schrieb Johannes Rohr :

tweaked the wrapper script to make it work. It seems like the sa-learn call 
silently fails:

"/usr/local/bin/sa-learn-pipe.sh" 10L, 350C geschrieben
root@vm10:/etc/dovecot/conf.d# cat /tmp/sa-learn-pipe.log
starting log
25200-start (--username=johan...@rohr.org --spam)
libgcc_s.so.1 must be installed for pthread_cancel to work
25200-end

Does the above error message have anything to do with it? Running the script & 
sa-learn manually works fine. do virtual users change something how dovecot calls 
programs, such as chrooting them?

Here [1] is an old thread about that problem.In short: It seems to be a problem 
in sa-learn that is triggered by the privilege drop that dovecot does when 
starting.

I have the same problem and I have not found a solution yet.


Yikes! Our server is running a fairly dated Ubuntu Precise, what's your 
version? Did an upgrade fail to fix it? I am not seeing this error on 
Debian Sid but I am not using virtual users over here, so that might be 
the cause. Did you report the bug to the Spamassassin bugzilla?


Cheers,

Johannes


[1] http://www.dovecot.org/list/dovecot/2013-November/093378.html


Cheers,

Johannes


Re: antispam plugin, pipe backend, how to make it work?

2016-04-13 Thread Johannes Rohr

Am 13.04.2016 um 11:31 schrieb Steffen Kaiser:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Wed, 13 Apr 2016, Johannes Rohr wrote:

tweaked the wrapper script to make it work. It seems like the 
sa-learn call


See the page again.


Can you kindly be more precise? The wrapper script at the page is 
broken, it cannot work, as it fails to write the message passed from the 
plugin to  /tmp/sendmail-msg-$$.txt. So the input passed to sa-learn is 
missing, which I fixed by inserting "cat > /tmp/sendmail-msg-$$.txt" at 
the beginning of the script. However, this is not the actual issue, as 
sa-learn even fails even when the script is fixed.



silently fails:

"/usr/local/bin/sa-learn-pipe.sh" 10L, 350C geschrieben
root@vm10:/etc/dovecot/conf.d# cat /tmp/sa-learn-pipe.log
starting log
25200-start (--username=johan...@rohr.org --spam)
libgcc_s.so.1 must be installed for pthread_cancel to work
25200-end

Does the above error message have anything to do with it? Running the 
script & sa-learn manually works fine. do virtual users change 
something how dovecot calls programs, such as chrooting them?


Maybe, the script uses different search paths? Uncomment "# env" to 
verify.


I'll try later, although I doubt that environment variables are to 
blame. (For now we have a cronjob which is scanning the Junk directories 
periodically as a workaround.) I have to change back a whole bunch of 
config files to enable the plugin again. It seems to be a bug which hits 
daemons that run as a limited user, see 
https://bugs.launchpad.net/ubuntu/+source/gcc-3.3/+bug/40285/comments/30


I am a bit worried because the same error is reported from newer Ubuntu 
versions, so unless the spamassassin guys have fixed it their way, it 
might not go away by upgrading


Cheers,

Johannes




Cheers,

Johannes


Am 13.04.2016 um 09:45 schrieb Johannes Rohr:

Am 13.04.2016 um 09:17 schrieb Tom Hendrikx:

On 13-04-16 08:27, Johannes Rohr wrote:

Hi List,

does the antispam plugin any way of actually seeing how it is
calling the pipe program and how it is failing? I can't reproduce the
failure when I call sa-learn manually. Can someone tell me, with
which UID the call happens, is it the UID the current dovecot process
is running under (which would be vmail, as it is a virtual user
setup) Cheers,


Hi Johannes,
http://wiki2.dovecot.org/Pigeonhole/Sieve/Troubleshooting
This is exactly what the wrapper script is supposed to log for you, or
which is trivially to add to its output. The wrapper script is not
actually useful for production, but it is for debugging. That is why I
asked for its logging, and any differences between manual run and a
dovecot run.


When I used the wrapper script recommended at 
http://wiki2.dovecot.org/Plugins/Antispam, it merely reported the 
PID and parameters (--username=s...@na.me --ham). The wrapper script 
noted in the dovecot wiki seems broken. Note the commented out line:


#echo $* > /tmp/sendmail-parms.txt cat<&0 >> /tmp/sendmail-msg-$$.txt

It seems like the second half of the line "cat<&0 >> 
/tmp/sendmail-msg-$$.txt" was originally a separate line, catting 
the message, which has been passed by the plugin via STDOUT to a 
file. Without that command, the call of sa-learn in the next line 
has no file to read from:


/usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt && rm -f 
/tmp/sendmail-msg-$$.txt &


So I moved the cat command to a separate uncommented line and to be 
sure I also commented out the


rm -f /tmp/sendmail-msg-$$.txt &

to verify that the file actually contains something, (why is there 
an "&" terminating the line, which would have the rm command 
executed in the background?)


But it seems the

/tmp/sendmail-msg-$$.txt &

was empty and the whole operation continued to fail. Could it be 
that the plugin fails to pass the actual message?


Cheers,

Johannes



Regards,
Tom



Johannes

Am 12.04.2016 um 23:09 schrieb Johannes Rohr:

Hi Tom,

Am 12.04.2016 um 22:26 schrieb Tom Hendrikx:

On 12-04-16 20:14, Johannes Rohr wrote:

Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise
with the antispam plugin in version  2.0+20120225-2 and
spamassassin at version 3.2.2

I have been trying and failed to get the pipe backend of the
antispam plugin to work. Spamassin by itself works, a manual
call of sa-learn works fine. Bayes data is stored in a mysql
DB.

I have the following configuration in
/etc/dovecot/conf.d/90-plugin.conf

plugin { #setting_name = value sieve=~/.dovecot.sieve
sieve_dir=~/sieve antispam_pipe_program_spam_arg = --spam
antispam_pipe_program_notspam_arg  = --ham
antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
antispam_pipe_program_args = --username=%u # % expansion done
by dovecot

You need to specify the argument list as a list seperated by
semicolons, per example on the wiki:

antispam_pipe_program_args = --username;%u

Not sure about that, because sa-

Re: antispam plugin, pipe backend, how to make it work?

2016-04-13 Thread Florian Mutter
Am 13.04.2016 um 10:35 schrieb Johannes Rohr :
> 
> tweaked the wrapper script to make it work. It seems like the sa-learn call 
> silently fails:
> 
> "/usr/local/bin/sa-learn-pipe.sh" 10L, 350C geschrieben
> root@vm10:/etc/dovecot/conf.d# cat /tmp/sa-learn-pipe.log
> starting log
> 25200-start (--username=johan...@rohr.org --spam)
> libgcc_s.so.1 must be installed for pthread_cancel to work
> 25200-end
> 
> Does the above error message have anything to do with it? Running the script 
> & sa-learn manually works fine. do virtual users change something how dovecot 
> calls programs, such as chrooting them?

Here [1] is an old thread about that problem.In short: It seems to be a problem 
in sa-learn that is triggered by the privilege drop that dovecot does when 
starting.

I have the same problem and I have not found a solution yet.

[1] http://www.dovecot.org/list/dovecot/2013-November/093378.html

> 
> Cheers,
> 
> Johannes


Re: antispam plugin, pipe backend, how to make it work?

2016-04-13 Thread Steffen Kaiser

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Wed, 13 Apr 2016, Johannes Rohr wrote:


tweaked the wrapper script to make it work. It seems like the sa-learn call


See the page again.


silently fails:

"/usr/local/bin/sa-learn-pipe.sh" 10L, 350C geschrieben
root@vm10:/etc/dovecot/conf.d# cat /tmp/sa-learn-pipe.log
starting log
25200-start (--username=johan...@rohr.org --spam)
libgcc_s.so.1 must be installed for pthread_cancel to work
25200-end

Does the above error message have anything to do with it? Running the script 
& sa-learn manually works fine. do virtual users change something how dovecot 
calls programs, such as chrooting them?


Maybe, the script uses different search paths? Uncomment "# env" to 
verify.




Cheers,

Johannes


Am 13.04.2016 um 09:45 schrieb Johannes Rohr:

Am 13.04.2016 um 09:17 schrieb Tom Hendrikx:

On 13-04-16 08:27, Johannes Rohr wrote:

Hi List,

does the antispam plugin any way of actually seeing how it is
calling the pipe program and how it is failing? I can't reproduce the
failure when I call sa-learn manually. Can someone tell me, with
which UID the call happens, is it the UID the current dovecot process
is running under (which would be vmail, as it is a virtual user
setup) Cheers,


Hi Johannes,
http://wiki2.dovecot.org/Pigeonhole/Sieve/Troubleshooting
This is exactly what the wrapper script is supposed to log for you, or
which is trivially to add to its output. The wrapper script is not
actually useful for production, but it is for debugging. That is why I
asked for its logging, and any differences between manual run and a
dovecot run.


When I used the wrapper script recommended at 
http://wiki2.dovecot.org/Plugins/Antispam, it merely reported the PID and 
parameters (--username=s...@na.me --ham). The wrapper script noted in the 
dovecot wiki seems broken. Note the commented out line:


#echo $* > /tmp/sendmail-parms.txt cat<&0 >> /tmp/sendmail-msg-$$.txt

It seems like the second half of the line "cat<&0 >> 
/tmp/sendmail-msg-$$.txt" was originally a separate line, catting the 
message, which has been passed by the plugin via STDOUT to a file. Without 
that command, the call of sa-learn in the next line has no file to read 
from:


/usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt && rm -f 
/tmp/sendmail-msg-$$.txt &


So I moved the cat command to a separate uncommented line and to be sure I 
also commented out the


rm -f /tmp/sendmail-msg-$$.txt &

to verify that the file actually contains something, (why is there an "&" 
terminating the line, which would have the rm command executed in the 
background?)


But it seems the

/tmp/sendmail-msg-$$.txt &

was empty and the whole operation continued to fail. Could it be that the 
plugin fails to pass the actual message?


Cheers,

Johannes



Regards,
Tom



Johannes

Am 12.04.2016 um 23:09 schrieb Johannes Rohr:

Hi Tom,

Am 12.04.2016 um 22:26 schrieb Tom Hendrikx:

On 12-04-16 20:14, Johannes Rohr wrote:

Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise
with the antispam plugin in version  2.0+20120225-2 and
spamassassin at version 3.2.2

I have been trying and failed to get the pipe backend of the
antispam plugin to work. Spamassin by itself works, a manual
call of sa-learn works fine. Bayes data is stored in a mysql
DB.

I have the following configuration in
/etc/dovecot/conf.d/90-plugin.conf

plugin { #setting_name = value sieve=~/.dovecot.sieve
sieve_dir=~/sieve antispam_pipe_program_spam_arg = --spam
antispam_pipe_program_notspam_arg  = --ham
antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
antispam_pipe_program_args = --username=%u # % expansion done
by dovecot

You need to specify the argument list as a list seperated by
semicolons, per example on the wiki:

antispam_pipe_program_args = --username;%u

Not sure about that, because sa-learn expects the parameter
--username=u...@na.me, this is one parameter, not two, and it
works for me locally, where I also set up dovecot to test. The
main differences are that the versions I have here are newer, I'm
running Debian sid, the server is on Ubuntu Precise, and second,
the server is handling virtual users, locally I have only real Unix
users.

Also, dovecot doesn't complain about configuration errors regard
--username=%u. What other way would be there to get the parameter
passed to sa-learn the way I want?

btw, I tried this, just to be sure, but the result was the same.


The verbose debug should give you some logging to work with.

Yes, and I pasted the output. I can of course repeat:

Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_unsure(Junk): 0 Apr
12 22:53:02 vm10 imap: antispam: 
mailbox_is_trash(INBhttp://wiki2.dovecot.org/Pigeonhole/Sieve/TroubleshootingOX): 
0 Apr 12

22:53:02 vm10 imap: antispam: mailbox_is_trash(Junk): 0 Apr 12
22:53:02 vm10 imap: antispam: mail copy: from trash: 0, to trash:
0 Apr 12 22:53:02 vm10 imap: antispam: 

Re: antispam plugin, pipe backend, how to make it work?

2016-04-13 Thread Johannes Rohr
tweaked the wrapper script to make it work. It seems like the sa-learn 
call silently fails:


"/usr/local/bin/sa-learn-pipe.sh" 10L, 350C geschrieben
root@vm10:/etc/dovecot/conf.d# cat /tmp/sa-learn-pipe.log
starting log
25200-start (--username=johan...@rohr.org --spam)
libgcc_s.so.1 must be installed for pthread_cancel to work
25200-end

Does the above error message have anything to do with it? Running the 
script & sa-learn manually works fine. do virtual users change something 
how dovecot calls programs, such as chrooting them?


Cheers,

Johannes


Am 13.04.2016 um 09:45 schrieb Johannes Rohr:

Am 13.04.2016 um 09:17 schrieb Tom Hendrikx:

On 13-04-16 08:27, Johannes Rohr wrote:

Hi List,

does the antispam plugin any way of actually seeing how it is
calling the pipe program and how it is failing? I can't reproduce the
failure when I call sa-learn manually. Can someone tell me, with
which UID the call happens, is it the UID the current dovecot process
is running under (which would be vmail, as it is a virtual user
setup) Cheers,


Hi Johannes,
http://wiki2.dovecot.org/Pigeonhole/Sieve/Troubleshooting
This is exactly what the wrapper script is supposed to log for you, or
which is trivially to add to its output. The wrapper script is not
actually useful for production, but it is for debugging. That is why I
asked for its logging, and any differences between manual run and a
dovecot run.


When I used the wrapper script recommended at 
http://wiki2.dovecot.org/Plugins/Antispam, it merely reported the PID 
and parameters (--username=s...@na.me --ham). The wrapper script noted 
in the dovecot wiki seems broken. Note the commented out line:


#echo $* > /tmp/sendmail-parms.txt cat<&0 >> /tmp/sendmail-msg-$$.txt

It seems like the second half of the line "cat<&0 >> 
/tmp/sendmail-msg-$$.txt" was originally a separate line, catting the 
message, which has been passed by the plugin via STDOUT to a file. 
Without that command, the call of sa-learn in the next line has no 
file to read from:


/usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt && rm -f 
/tmp/sendmail-msg-$$.txt &


So I moved the cat command to a separate uncommented line and to be 
sure I also commented out the


rm -f /tmp/sendmail-msg-$$.txt &

to verify that the file actually contains something, (why is there an 
"&" terminating the line, which would have the rm command executed in 
the background?)


But it seems the

/tmp/sendmail-msg-$$.txt &

was empty and the whole operation continued to fail. Could it be that 
the plugin fails to pass the actual message?


Cheers,

Johannes



Regards,
Tom



Johannes

Am 12.04.2016 um 23:09 schrieb Johannes Rohr:

Hi Tom,

Am 12.04.2016 um 22:26 schrieb Tom Hendrikx:

On 12-04-16 20:14, Johannes Rohr wrote:

Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise
with the antispam plugin in version  2.0+20120225-2 and
spamassassin at version 3.2.2

I have been trying and failed to get the pipe backend of the
antispam plugin to work. Spamassin by itself works, a manual
call of sa-learn works fine. Bayes data is stored in a mysql
DB.

I have the following configuration in
/etc/dovecot/conf.d/90-plugin.conf

plugin { #setting_name = value sieve=~/.dovecot.sieve
sieve_dir=~/sieve antispam_pipe_program_spam_arg = --spam
antispam_pipe_program_notspam_arg  = --ham
antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
antispam_pipe_program_args = --username=%u # % expansion done
by dovecot

You need to specify the argument list as a list seperated by
semicolons, per example on the wiki:

antispam_pipe_program_args = --username;%u

Not sure about that, because sa-learn expects the parameter
--username=u...@na.me, this is one parameter, not two, and it
works for me locally, where I also set up dovecot to test. The
main differences are that the versions I have here are newer, I'm
running Debian sid, the server is on Ubuntu Precise, and second,
the server is handling virtual users, locally I have only real Unix
users.

Also, dovecot doesn't complain about configuration errors regard
--username=%u. What other way would be there to get the parameter
passed to sa-learn the way I want?

btw, I tried this, just to be sure, but the result was the same.


The verbose debug should give you some logging to work with.

Yes, and I pasted the output. I can of course repeat:

Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_unsure(Junk): 0 Apr
12 22:53:02 vm10 imap: antispam: 
mailbox_is_trash(INBhttp://wiki2.dovecot.org/Pigeonhole/Sieve/TroubleshootingOX): 
0 Apr 12

22:53:02 vm10 imap: antispam: mailbox_is_trash(Junk): 0 Apr 12
22:53:02 vm10 imap: antispam: mail copy: from trash: 0, to trash:
0 Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_spam(INBOX): 0
Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_spam(Junk): 1 Apr
12 22:53:02 vm10 imap: antispam: mailbox_is_unsure(INBOX): 0 Apr 12
22:53:02 vm10 imap: antispam: mail cop

Re: antispam plugin, pipe backend, how to make it work?

2016-04-13 Thread Johannes Rohr

Am 13.04.2016 um 09:17 schrieb Tom Hendrikx:

On 13-04-16 08:27, Johannes Rohr wrote:

Hi List,

does the antispam plugin any way of actually seeing how it is
calling the pipe program and how it is failing? I can't reproduce the
failure when I call sa-learn manually. Can someone tell me, with
which UID the call happens, is it the UID the current dovecot process
is running under (which would be vmail, as it is a virtual user
setup) Cheers,


Hi Johannes,
http://wiki2.dovecot.org/Pigeonhole/Sieve/Troubleshooting
This is exactly what the wrapper script is supposed to log for you, or
which is trivially to add to its output. The wrapper script is not
actually useful for production, but it is for debugging. That is why I
asked for its logging, and any differences between manual run and a
dovecot run.


When I used the wrapper script recommended at 
http://wiki2.dovecot.org/Plugins/Antispam, it merely reported the PID 
and parameters (--username=s...@na.me --ham). The wrapper script noted 
in the dovecot wiki seems broken. Note the commented out line:


#echo $* > /tmp/sendmail-parms.txt cat<&0 >> /tmp/sendmail-msg-$$.txt

It seems like the second half of the line "cat<&0 >> 
/tmp/sendmail-msg-$$.txt" was originally a separate line, catting the 
message, which has been passed by the plugin via STDOUT to a file. 
Without that command, the call of sa-learn in the next line has no file 
to read from:


/usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt && rm -f 
/tmp/sendmail-msg-$$.txt &


So I moved the cat command to a separate uncommented line and to be sure 
I also commented out the


rm -f /tmp/sendmail-msg-$$.txt &

to verify that the file actually contains something, (why is there an 
"&" terminating the line, which would have the rm command executed in 
the background?)


But it seems the

/tmp/sendmail-msg-$$.txt &

was empty and the whole operation continued to fail. Could it be that 
the plugin fails to pass the actual message?


Cheers,

Johannes



Regards,
Tom



Johannes

Am 12.04.2016 um 23:09 schrieb Johannes Rohr:

Hi Tom,

Am 12.04.2016 um 22:26 schrieb Tom Hendrikx:

On 12-04-16 20:14, Johannes Rohr wrote:

Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise
with the antispam plugin in version  2.0+20120225-2 and
spamassassin at version 3.2.2

I have been trying and failed to get the pipe backend of the
antispam plugin to work. Spamassin by itself works, a manual
call of sa-learn works fine. Bayes data is stored in a mysql
DB.

I have the following configuration in
/etc/dovecot/conf.d/90-plugin.conf

plugin { #setting_name = value sieve=~/.dovecot.sieve
sieve_dir=~/sieve antispam_pipe_program_spam_arg = --spam
antispam_pipe_program_notspam_arg  = --ham
antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
antispam_pipe_program_args = --username=%u # % expansion done
by dovecot

You need to specify the argument list as a list seperated by
semicolons, per example on the wiki:

antispam_pipe_program_args = --username;%u

Not sure about that, because sa-learn expects the parameter
--username=u...@na.me, this is one parameter, not two, and it
works for me locally, where I also set up dovecot to test. The
main differences are that the versions I have here are newer, I'm
running Debian sid, the server is on Ubuntu Precise, and second,
the server is handling virtual users, locally I have only real Unix
users.

Also, dovecot doesn't complain about configuration errors regard
--username=%u. What other way would be there to get the parameter
passed to sa-learn the way I want?

btw, I tried this, just to be sure, but the result was the same.


The verbose debug should give you some logging to work with.

Yes, and I pasted the output. I can of course repeat:

Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_unsure(Junk): 0 Apr
12 22:53:02 vm10 imap: antispam: 
mailbox_is_trash(INBhttp://wiki2.dovecot.org/Pigeonhole/Sieve/TroubleshootingOX):
 0 Apr 12
22:53:02 vm10 imap: antispam: mailbox_is_trash(Junk): 0 Apr 12
22:53:02 vm10 imap: antispam: mail copy: from trash: 0, to trash:
0 Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_spam(INBOX): 0
Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_spam(Junk): 1 Apr
12 22:53:02 vm10 imap: antispam: mailbox_is_unsure(INBOX): 0 Apr 12
22:53:02 vm10 imap: antispam: mail copy: src spam: 0, dst spam: 1,
src unsure: 0 Apr 12 22:53:02 vm10 imap: antispam: running
mailtrain backend program /usr/bin/sa-learn Apr 12 22:53:02 vm10
imap: antispam: running mailtrain backend program
/usr/bin/sa-learn Apr 12 22:53:02 vm10 imap: antispam: running
mailtrain backend program parameter 1 --username=johan...@rohr.org
Apr 12 22:53:02 vm10 imap: antispam: running mailtrain backend
program parameter 2 --spam Apr 12 22:53:03 vm10 imap: antispam: run
program failed with exit code -1





Also, what does the wrapper script log when dovecot runs it?

I have actually ditched  the wrapper script because it works
witho

Re: antispam plugin, pipe backend, how to make it work?

2016-04-13 Thread Tom Hendrikx
On 13-04-16 08:27, Johannes Rohr wrote:
> Hi List,
> 
> does the antispam plugin any way of actually seeing how it is
> calling the pipe program and how it is failing? I can't reproduce the
> failure when I call sa-learn manually. Can someone tell me, with
> which UID the call happens, is it the UID the current dovecot process
> is running under (which would be vmail, as it is a virtual user
> setup) Cheers,
> 

Hi Johannes,

This is exactly what the wrapper script is supposed to log for you, or
which is trivially to add to its output. The wrapper script is not
actually useful for production, but it is for debugging. That is why I
asked for its logging, and any differences between manual run and a
dovecot run.

Regards,
Tom


> Johannes
> 
> Am 12.04.2016 um 23:09 schrieb Johannes Rohr:
>> Hi Tom,
>> 
>> Am 12.04.2016 um 22:26 schrieb Tom Hendrikx:
>>> On 12-04-16 20:14, Johannes Rohr wrote:
>>>> Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise 
>>>> with the antispam plugin in version  2.0+20120225-2 and
>>>> spamassassin at version 3.2.2
>>>> 
>>>> I have been trying and failed to get the pipe backend of the
>>>> antispam plugin to work. Spamassin by itself works, a manual
>>>> call of sa-learn works fine. Bayes data is stored in a mysql
>>>> DB.
>>>> 
>>>> I have the following configuration in 
>>>> /etc/dovecot/conf.d/90-plugin.conf
>>>> 
>>>> plugin { #setting_name = value sieve=~/.dovecot.sieve 
>>>> sieve_dir=~/sieve antispam_pipe_program_spam_arg = --spam 
>>>> antispam_pipe_program_notspam_arg  = --ham 
>>>> antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh 
>>>> antispam_pipe_program_args = --username=%u # % expansion done
>>>> by dovecot
>>> You need to specify the argument list as a list seperated by
>>> semicolons, per example on the wiki:
>>> 
>>> antispam_pipe_program_args = --username;%u
>> 
>> Not sure about that, because sa-learn expects the parameter 
>> --username=u...@na.me, this is one parameter, not two, and it
>> works for me locally, where I also set up dovecot to test. The
>> main differences are that the versions I have here are newer, I'm
>> running Debian sid, the server is on Ubuntu Precise, and second,
>> the server is handling virtual users, locally I have only real Unix
>> users.
>> 
>> Also, dovecot doesn't complain about configuration errors regard 
>> --username=%u. What other way would be there to get the parameter 
>> passed to sa-learn the way I want?
>> 
>> btw, I tried this, just to be sure, but the result was the same.
>> 
>>> 
>>> The verbose debug should give you some logging to work with.
>> Yes, and I pasted the output. I can of course repeat:
>> 
>> Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_unsure(Junk): 0 Apr
>> 12 22:53:02 vm10 imap: antispam: mailbox_is_trash(INBOX): 0 Apr 12
>> 22:53:02 vm10 imap: antispam: mailbox_is_trash(Junk): 0 Apr 12
>> 22:53:02 vm10 imap: antispam: mail copy: from trash: 0, to trash:
>> 0 Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_spam(INBOX): 0 
>> Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_spam(Junk): 1 Apr
>> 12 22:53:02 vm10 imap: antispam: mailbox_is_unsure(INBOX): 0 Apr 12
>> 22:53:02 vm10 imap: antispam: mail copy: src spam: 0, dst spam: 1,
>> src unsure: 0 Apr 12 22:53:02 vm10 imap: antispam: running
>> mailtrain backend program /usr/bin/sa-learn Apr 12 22:53:02 vm10
>> imap: antispam: running mailtrain backend program 
>> /usr/bin/sa-learn Apr 12 22:53:02 vm10 imap: antispam: running
>> mailtrain backend program parameter 1 --username=johan...@rohr.org 
>> Apr 12 22:53:02 vm10 imap: antispam: running mailtrain backend
>> program parameter 2 --spam Apr 12 22:53:03 vm10 imap: antispam: run
>> program failed with exit code -1
>> 
>> 
>> 
>> 
>>> Also, what does the wrapper script log when dovecot runs it?
>> 
>> I have actually ditched  the wrapper script because it works
>> without locally, I have configured the plugin to call sa-learn
>> directly.
>> 
>>> How does that differ from a manual run?
>> sa-learn works just fine with a manual run. It seems as if the
>> plugin is passing the parameters wrongly, but the debugging output
>> doesn't reveal the actual command, so it's just guesswork.
>> 
>> Cheers,
>> 
>> Johannes
>> 
>>> 
>>> 
>>>> antispam_trash = trash;Trash;Deleted Items;Deleted Messages 
>>>> antisp

Re: antispam plugin, pipe backend, how to make it work?

2016-04-13 Thread Johannes Rohr

Hi List,

does the antispam plugin any way of actually seeing how it is calling 
the pipe program and how it is failing? I can't reproduce the failure 
when I call sa-learn manually. Can someone tell me, with which UID the 
call happens, is it the UID the current dovecot process is running under 
(which would be vmail, as it is a virtual user setup)

Cheers,

Johannes

Am 12.04.2016 um 23:09 schrieb Johannes Rohr:

Hi Tom,

Am 12.04.2016 um 22:26 schrieb Tom Hendrikx:

On 12-04-16 20:14, Johannes Rohr wrote:
 Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise 
with

the antispam plugin in version  2.0+20120225-2 and spamassassin at
version 3.2.2

I have been trying and failed to get the pipe backend of the antispam
plugin to work. Spamassin by itself works, a manual call of sa-learn
works fine. Bayes data is stored in a mysql DB.

I have the following configuration in 
/etc/dovecot/conf.d/90-plugin.conf


plugin {
   #setting_name = value
   sieve=~/.dovecot.sieve
   sieve_dir=~/sieve
 antispam_pipe_program_spam_arg = --spam
 antispam_pipe_program_notspam_arg  = --ham
 antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
 antispam_pipe_program_args = --username=%u # % expansion done by
dovecot

You need to specify the argument list as a list seperated by semicolons,
per example on the wiki:

antispam_pipe_program_args = --username;%u


Not sure about that, because sa-learn expects the parameter 
--username=u...@na.me, this is one parameter, not two, and it works 
for me locally, where I also set up dovecot to test. The main 
differences are that the versions I have here are newer, I'm running 
Debian sid, the server is on Ubuntu Precise, and second, the server is 
handling virtual users, locally I have only real Unix users.


Also, dovecot doesn't complain about configuration errors regard 
--username=%u. What other way would be there to get the parameter 
passed to sa-learn the way I want?


btw, I tried this, just to be sure, but the result was the same.



The verbose debug should give you some logging to work with.

Yes, and I pasted the output. I can of course repeat:

Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_unsure(Junk): 0
Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_trash(INBOX): 0
Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_trash(Junk): 0
Apr 12 22:53:02 vm10 imap: antispam: mail copy: from trash: 0, to 
trash: 0

Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_spam(INBOX): 0
Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_spam(Junk): 1
Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_unsure(INBOX): 0
Apr 12 22:53:02 vm10 imap: antispam: mail copy: src spam: 0, dst spam: 
1, src unsure: 0
Apr 12 22:53:02 vm10 imap: antispam: running mailtrain backend program 
/usr/bin/sa-learn
Apr 12 22:53:02 vm10 imap: antispam: running mailtrain backend program 
/usr/bin/sa-learn
Apr 12 22:53:02 vm10 imap: antispam: running mailtrain backend program 
parameter 1 --username=johan...@rohr.org
Apr 12 22:53:02 vm10 imap: antispam: running mailtrain backend program 
parameter 2 --spam

Apr 12 22:53:03 vm10 imap: antispam: run program failed with exit code -1





  Also, what
does the wrapper script log when dovecot runs it?


I have actually ditched  the wrapper script because it works without 
locally, I have configured the plugin to call sa-learn directly.



How does that differ
from a manual run?
sa-learn works just fine with a manual run. It seems as if the plugin 
is passing the parameters wrongly, but the debugging output doesn't 
reveal the actual command, so it's just guesswork.


Cheers,

Johannes





 antispam_trash = trash;Trash;Deleted Items;Deleted Messages
 antispam_spam = SPAM;Junk
 antispam_backend = pipe
 antispam_verbose_debug = 1
 antispam_debug_target = syslog
 antispam_pipe_tmpdir = /tmp
}

I have tried the following wrapper script:
#!/bin/bash
# set -x
LOGFILE=/tmp/sa-learn-pipe.log
echo "$$-start ($*)" >> $LOGFILE
#echo $* > /tmp/sendmail-parms.txt
cat<&0 >> /tmp/sendmail-msg-$$.txt
/usr/bin/sa-learn $* -D /tmp/sendmail-msg-$$.txt >> $LOGFILE 2>&1 && \
rm -f /tmp/sendmail-msg-$$.txt
echo "$$-end" >> $LOGFILE
exit 0

It somehow isn't working. I can call the wrapper script manually e.g.
sudo -u vmail /usr/local/bin/sa-learn-pipe.sh --username=s...@mail.user
--ham \
< someham

But it doesn't work from dovecot. It seems the script is called. but no
new patterns show up in the bayes DB. Unfortunately, the plugin 
seems to

be documented poorly. How does it call the programme it pipes to? Is it
something like $programme --par1 --par2 < message ? Why can't /
shouldn't I call sa-learn directly? All the instructions I found on the
in internet contained a wrapper script, but none bothered to explain 
why

you would actually need it.

I would be very grateful, if someone could enlighten me on that...

Cheers,

Johannes




Re: antispam plugin, pipe backend, how to make it work?

2016-04-12 Thread Johannes Rohr

Hi Tom,

Am 12.04.2016 um 22:26 schrieb Tom Hendrikx:

On 12-04-16 20:14, Johannes Rohr wrote:

 Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise with
the antispam plugin in version  2.0+20120225-2 and spamassassin at
version 3.2.2

I have been trying and failed to get the pipe backend of the antispam
plugin to work. Spamassin by itself works, a manual call of sa-learn
works fine. Bayes data is stored in a mysql DB.

I have the following configuration in /etc/dovecot/conf.d/90-plugin.conf

plugin {
   #setting_name = value
   sieve=~/.dovecot.sieve
   sieve_dir=~/sieve
 antispam_pipe_program_spam_arg = --spam
 antispam_pipe_program_notspam_arg  = --ham
 antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
 antispam_pipe_program_args = --username=%u # % expansion done by
dovecot

You need to specify the argument list as a list seperated by semicolons,
per example on the wiki:

antispam_pipe_program_args = --username;%u


Not sure about that, because sa-learn expects the parameter 
--username=u...@na.me, this is one parameter, not two, and it works for 
me locally, where I also set up dovecot to test. The main differences 
are that the versions I have here are newer, I'm running Debian sid, the 
server is on Ubuntu Precise, and second, the server is handling virtual 
users, locally I have only real Unix users.


Also, dovecot doesn't complain about configuration errors regard 
--username=%u. What other way would be there to get the parameter passed 
to sa-learn the way I want?


btw, I tried this, just to be sure, but the result was the same.



The verbose debug should give you some logging to work with.

Yes, and I pasted the output. I can of course repeat:

Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_unsure(Junk): 0
Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_trash(INBOX): 0
Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_trash(Junk): 0
Apr 12 22:53:02 vm10 imap: antispam: mail copy: from trash: 0, to trash: 0
Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_spam(INBOX): 0
Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_spam(Junk): 1
Apr 12 22:53:02 vm10 imap: antispam: mailbox_is_unsure(INBOX): 0
Apr 12 22:53:02 vm10 imap: antispam: mail copy: src spam: 0, dst spam: 
1, src unsure: 0
Apr 12 22:53:02 vm10 imap: antispam: running mailtrain backend program 
/usr/bin/sa-learn
Apr 12 22:53:02 vm10 imap: antispam: running mailtrain backend program 
/usr/bin/sa-learn
Apr 12 22:53:02 vm10 imap: antispam: running mailtrain backend program 
parameter 1 --username=johan...@rohr.org
Apr 12 22:53:02 vm10 imap: antispam: running mailtrain backend program 
parameter 2 --spam

Apr 12 22:53:03 vm10 imap: antispam: run program failed with exit code -1





  Also, what
does the wrapper script log when dovecot runs it?


I have actually ditched  the wrapper script because it works without 
locally, I have configured the plugin to call sa-learn directly.



How does that differ
from a manual run?
sa-learn works just fine with a manual run. It seems as if the plugin is 
passing the parameters wrongly, but the debugging output doesn't reveal 
the actual command, so it's just guesswork.


Cheers,

Johannes





 antispam_trash = trash;Trash;Deleted Items;Deleted Messages
 antispam_spam = SPAM;Junk
 antispam_backend = pipe
 antispam_verbose_debug = 1
 antispam_debug_target = syslog
 antispam_pipe_tmpdir = /tmp
}

I have tried the following wrapper script:
#!/bin/bash
# set -x
LOGFILE=/tmp/sa-learn-pipe.log
echo "$$-start ($*)" >> $LOGFILE
#echo $* > /tmp/sendmail-parms.txt
cat<&0 >> /tmp/sendmail-msg-$$.txt
/usr/bin/sa-learn $* -D /tmp/sendmail-msg-$$.txt >> $LOGFILE 2>&1 && \
rm -f /tmp/sendmail-msg-$$.txt
echo "$$-end" >> $LOGFILE
exit 0

It somehow isn't working. I can call the wrapper script manually e.g.
sudo -u vmail /usr/local/bin/sa-learn-pipe.sh --username=s...@mail.user
--ham \
< someham

But it doesn't work from dovecot. It seems the script is called. but no
new patterns show up in the bayes DB. Unfortunately, the plugin seems to
be documented poorly. How does it call the programme it pipes to? Is it
something like $programme --par1 --par2 < message ? Why can't /
shouldn't I call sa-learn directly? All the instructions I found on the
in internet contained a wrapper script, but none bothered to explain why
you would actually need it.

I would be very grateful, if someone could enlighten me on that...

Cheers,

Johannes




Re: antispam plugin, pipe backend, how to make it work?

2016-04-12 Thread Tom Hendrikx

On 12-04-16 20:14, Johannes Rohr wrote:
> Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise with
> the antispam plugin in version  2.0+20120225-2 and spamassassin at
> version 3.2.2
> 
> I have been trying and failed to get the pipe backend of the antispam
> plugin to work. Spamassin by itself works, a manual call of sa-learn
> works fine. Bayes data is stored in a mysql DB.
> 
> I have the following configuration in /etc/dovecot/conf.d/90-plugin.conf
> 
> plugin {
>   #setting_name = value
>   sieve=~/.dovecot.sieve
>   sieve_dir=~/sieve
> antispam_pipe_program_spam_arg = --spam
> antispam_pipe_program_notspam_arg  = --ham
> antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
> antispam_pipe_program_args = --username=%u # % expansion done by
> dovecot

You need to specify the argument list as a list seperated by semicolons,
per example on the wiki:

antispam_pipe_program_args = --username;%u

The verbose debug should give you some logging to work with. Also, what
does the wrapper script log when dovecot runs it? How does that differ
from a manual run?


> antispam_trash = trash;Trash;Deleted Items;Deleted Messages
> antispam_spam = SPAM;Junk
> antispam_backend = pipe
> antispam_verbose_debug = 1
> antispam_debug_target = syslog
> antispam_pipe_tmpdir = /tmp
> }
> 
> I have tried the following wrapper script:
> #!/bin/bash
> # set -x
> LOGFILE=/tmp/sa-learn-pipe.log
> echo "$$-start ($*)" >> $LOGFILE
> #echo $* > /tmp/sendmail-parms.txt
> cat<&0 >> /tmp/sendmail-msg-$$.txt
> /usr/bin/sa-learn $* -D /tmp/sendmail-msg-$$.txt >> $LOGFILE 2>&1 && \
> rm -f /tmp/sendmail-msg-$$.txt
> echo "$$-end" >> $LOGFILE
> exit 0
> 
> It somehow isn't working. I can call the wrapper script manually e.g.
> sudo -u vmail /usr/local/bin/sa-learn-pipe.sh --username=s...@mail.user
> --ham \
> < someham
> 
> But it doesn't work from dovecot. It seems the script is called. but no
> new patterns show up in the bayes DB. Unfortunately, the plugin seems to
> be documented poorly. How does it call the programme it pipes to? Is it
> something like $programme --par1 --par2 < message ? Why can't /
> shouldn't I call sa-learn directly? All the instructions I found on the
> in internet contained a wrapper script, but none bothered to explain why
> you would actually need it.
> 
> I would be very grateful, if someone could enlighten me on that...
> 
> Cheers,
> 
> Johannes




signature.asc
Description: OpenPGP digital signature


Re: antispam plugin, pipe backend, how to make it work?

2016-04-12 Thread Johannes Rohr

Hi Jürgen,

what do you mean by "It's already integrated"? Of course I added the 
configuration, see my initial mail below. I still am struggling to 
understand what the reason  for the wrapper script is and how the plugin 
is supposed to call he helper programme, is the message passed to it via 
stdout?


This is what I find in the syslog: Apr 12 21:54:32 vm10 imap: antispam: 
plugin initialising (2.0-notgit)

Apr 12 21:54:32 vm10 imap: antispam: verbose debug enabled
Apr 12 21:54:32 vm10 imap: antispam: "SPAM" is exact match spam folder
Apr 12 21:54:32 vm10 imap: antispam: "Junk" is exact match spam folder
Apr 12 21:54:32 vm10 imap: antispam: no unsure folders
Apr 12 21:54:32 vm10 imap: antispam: "trash" is exact match trash folder
Apr 12 21:54:32 vm10 imap: antispam: "Trash" is exact match trash folder
Apr 12 21:54:32 vm10 imap: antispam: "Deleted Items" is exact match 
trash folder
Apr 12 21:54:32 vm10 imap: antispam: "Deleted Messages" is exact match 
trash folder

Apr 12 21:54:32 vm10 imap: antispam: pipe backend spam argument = --spam
Apr 12 21:54:32 vm10 imap: antispam: pipe backend not-spam argument = --ham
Apr 12 21:54:32 vm10 imap: antispam: pipe backend program = 
/usr/bin/sa-learn
Apr 12 21:54:32 vm10 imap: antispam: pipe backend program arg[0] = 
--username=[blanked out]@rohr.org

Apr 12 21:54:32 vm10 imap: antispam: pipe backend tmpdir /tmp

It doesn't hint at any particular error, however, when I tried to move a 
message to junk, nothing happens, the message just stays at its original 
place and I see that the contents of the bayes db is unchanged, so 
somehow nothing happens. When I disable the plugin, moving messages to 
Junk works again.


I wonder whether this is a bug in a particular version, it is quite 
ancient software, the server is running on Ubuntu precise.


 Cheers,

Johannes




Am 12.04.2016 um 20:18 schrieb J. Echter:

Hi,

here (Centos 7) its already integrated...

Just add something like this:

plugin {


   antispam_mail_sendmail = /usr/bin/sa-learn
   antispam_mail_sendmail_args = -u amavis
   antispam_mail_spam  = --spam
   antispam_mail_notspam  = --ham
}

to dovecot.conf

Cheers

Jürgen

Am 12.04.2016 um 20:14 schrieb Johannes Rohr:

 Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise with
the antispam plugin in version  2.0+20120225-2 and spamassassin at
version 3.2.2

I have been trying and failed to get the pipe backend of the antispam
plugin to work. Spamassin by itself works, a manual call of sa-learn
works fine. Bayes data is stored in a mysql DB.

I have the following configuration in /etc/dovecot/conf.d/90-plugin.conf

plugin {
   #setting_name = value
   sieve=~/.dovecot.sieve
   sieve_dir=~/sieve
 antispam_pipe_program_spam_arg = --spam
 antispam_pipe_program_notspam_arg  = --ham
 antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
 antispam_pipe_program_args = --username=%u # % expansion done by
dovecot
 antispam_trash = trash;Trash;Deleted Items;Deleted Messages
 antispam_spam = SPAM;Junk
 antispam_backend = pipe
 antispam_verbose_debug = 1
 antispam_debug_target = syslog
 antispam_pipe_tmpdir = /tmp
}

I have tried the following wrapper script:
#!/bin/bash
# set -x
LOGFILE=/tmp/sa-learn-pipe.log
echo "$$-start ($*)" >> $LOGFILE
#echo $* > /tmp/sendmail-parms.txt
cat<&0 >> /tmp/sendmail-msg-$$.txt
/usr/bin/sa-learn $* -D /tmp/sendmail-msg-$$.txt >> $LOGFILE 2>&1 && \
rm -f /tmp/sendmail-msg-$$.txt
echo "$$-end" >> $LOGFILE
exit 0

It somehow isn't working. I can call the wrapper script manually e.g.
sudo -u vmail /usr/local/bin/sa-learn-pipe.sh --username=s...@mail.user
--ham \
< someham

But it doesn't work from dovecot. It seems the script is called. but no
new patterns show up in the bayes DB. Unfortunately, the plugin seems to
be documented poorly. How does it call the programme it pipes to? Is it
something like $programme --par1 --par2 < message ? Why can't /
shouldn't I call sa-learn directly? All the instructions I found on the
in internet contained a wrapper script, but none bothered to explain why
you would actually need it.

I would be very grateful, if someone could enlighten me on that...

Cheers,

Johannes


Re: antispam plugin, pipe backend, how to make it work?

2016-04-12 Thread J. Echter
dovecot 2.2.10

Am 12.04.2016 um 20:18 schrieb J. Echter:
> Hi,
> 
> here (Centos 7) its already integrated...
> 
> Just add something like this:
> 
> plugin {
> 
> 
>   antispam_mail_sendmail = /usr/bin/sa-learn
>   antispam_mail_sendmail_args = -u amavis
>   antispam_mail_spam  = --spam
>   antispam_mail_notspam  = --ham
> }
> 
> to dovecot.conf
> 
> Cheers
> 
> Jürgen
> 
> Am 12.04.2016 um 20:14 schrieb Johannes Rohr:
>> Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise with
>> the antispam plugin in version  2.0+20120225-2 and spamassassin at
>> version 3.2.2
>>
>> I have been trying and failed to get the pipe backend of the antispam
>> plugin to work. Spamassin by itself works, a manual call of sa-learn
>> works fine. Bayes data is stored in a mysql DB.
>>
>> I have the following configuration in /etc/dovecot/conf.d/90-plugin.conf
>>
>> plugin {
>>   #setting_name = value
>>   sieve=~/.dovecot.sieve
>>   sieve_dir=~/sieve
>> antispam_pipe_program_spam_arg = --spam
>> antispam_pipe_program_notspam_arg  = --ham
>> antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
>> antispam_pipe_program_args = --username=%u # % expansion done by
>> dovecot
>> antispam_trash = trash;Trash;Deleted Items;Deleted Messages
>> antispam_spam = SPAM;Junk
>> antispam_backend = pipe
>> antispam_verbose_debug = 1
>> antispam_debug_target = syslog
>> antispam_pipe_tmpdir = /tmp
>> }
>>
>> I have tried the following wrapper script:
>> #!/bin/bash
>> # set -x
>> LOGFILE=/tmp/sa-learn-pipe.log
>> echo "$$-start ($*)" >> $LOGFILE
>> #echo $* > /tmp/sendmail-parms.txt
>> cat<&0 >> /tmp/sendmail-msg-$$.txt
>> /usr/bin/sa-learn $* -D /tmp/sendmail-msg-$$.txt >> $LOGFILE 2>&1 && \
>> rm -f /tmp/sendmail-msg-$$.txt
>> echo "$$-end" >> $LOGFILE
>> exit 0
>>
>> It somehow isn't working. I can call the wrapper script manually e.g.
>> sudo -u vmail /usr/local/bin/sa-learn-pipe.sh --username=s...@mail.user
>> --ham \
>> < someham
>>
>> But it doesn't work from dovecot. It seems the script is called. but no
>> new patterns show up in the bayes DB. Unfortunately, the plugin seems to
>> be documented poorly. How does it call the programme it pipes to? Is it
>> something like $programme --par1 --par2 < message ? Why can't /
>> shouldn't I call sa-learn directly? All the instructions I found on the
>> in internet contained a wrapper script, but none bothered to explain why
>> you would actually need it.
>>
>> I would be very grateful, if someone could enlighten me on that...
>>
>> Cheers,
>>
>> Johannes


antispam plugin, pipe backend, how to make it work?

2016-04-12 Thread Johannes Rohr
Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise with 
the antispam plugin in version  2.0+20120225-2 and spamassassin at 
version 3.2.2


I have been trying and failed to get the pipe backend of the antispam 
plugin to work. Spamassin by itself works, a manual call of sa-learn 
works fine. Bayes data is stored in a mysql DB.


I have the following configuration in /etc/dovecot/conf.d/90-plugin.conf

plugin {
  #setting_name = value
  sieve=~/.dovecot.sieve
  sieve_dir=~/sieve
antispam_pipe_program_spam_arg = --spam
antispam_pipe_program_notspam_arg  = --ham
antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
antispam_pipe_program_args = --username=%u # % expansion done by 
dovecot

antispam_trash = trash;Trash;Deleted Items;Deleted Messages
antispam_spam = SPAM;Junk
antispam_backend = pipe
antispam_verbose_debug = 1
antispam_debug_target = syslog
antispam_pipe_tmpdir = /tmp
}

I have tried the following wrapper script:
#!/bin/bash
# set -x
LOGFILE=/tmp/sa-learn-pipe.log
echo "$$-start ($*)" >> $LOGFILE
#echo $* > /tmp/sendmail-parms.txt
cat<&0 >> /tmp/sendmail-msg-$$.txt
/usr/bin/sa-learn $* -D /tmp/sendmail-msg-$$.txt >> $LOGFILE 2>&1 && \
rm -f /tmp/sendmail-msg-$$.txt
echo "$$-end" >> $LOGFILE
exit 0

It somehow isn't working. I can call the wrapper script manually e.g.
sudo -u vmail /usr/local/bin/sa-learn-pipe.sh --username=s...@mail.user 
--ham \

< someham

But it doesn't work from dovecot. It seems the script is called. but no 
new patterns show up in the bayes DB. Unfortunately, the plugin seems to 
be documented poorly. How does it call the programme it pipes to? Is it 
something like $programme --par1 --par2 < message ? Why can't / 
shouldn't I call sa-learn directly? All the instructions I found on the 
in internet contained a wrapper script, but none bothered to explain why 
you would actually need it.


I would be very grateful, if someone could enlighten me on that...

Cheers,

Johannes


Re: antispam plugin, pipe backend, how to make it work?

2016-04-12 Thread J. Echter
Hi,

here (Centos 7) its already integrated...

Just add something like this:

plugin {


  antispam_mail_sendmail = /usr/bin/sa-learn
  antispam_mail_sendmail_args = -u amavis
  antispam_mail_spam  = --spam
  antispam_mail_notspam  = --ham
}

to dovecot.conf

Cheers

Jürgen

Am 12.04.2016 um 20:14 schrieb Johannes Rohr:
> Hi, my setup is a dovecot 2.0.19 IMAP server on Ubuntu Precise with
> the antispam plugin in version  2.0+20120225-2 and spamassassin at
> version 3.2.2
> 
> I have been trying and failed to get the pipe backend of the antispam
> plugin to work. Spamassin by itself works, a manual call of sa-learn
> works fine. Bayes data is stored in a mysql DB.
> 
> I have the following configuration in /etc/dovecot/conf.d/90-plugin.conf
> 
> plugin {
>   #setting_name = value
>   sieve=~/.dovecot.sieve
>   sieve_dir=~/sieve
> antispam_pipe_program_spam_arg = --spam
> antispam_pipe_program_notspam_arg  = --ham
> antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
> antispam_pipe_program_args = --username=%u # % expansion done by
> dovecot
> antispam_trash = trash;Trash;Deleted Items;Deleted Messages
> antispam_spam = SPAM;Junk
> antispam_backend = pipe
> antispam_verbose_debug = 1
> antispam_debug_target = syslog
> antispam_pipe_tmpdir = /tmp
> }
> 
> I have tried the following wrapper script:
> #!/bin/bash
> # set -x
> LOGFILE=/tmp/sa-learn-pipe.log
> echo "$$-start ($*)" >> $LOGFILE
> #echo $* > /tmp/sendmail-parms.txt
> cat<&0 >> /tmp/sendmail-msg-$$.txt
> /usr/bin/sa-learn $* -D /tmp/sendmail-msg-$$.txt >> $LOGFILE 2>&1 && \
> rm -f /tmp/sendmail-msg-$$.txt
> echo "$$-end" >> $LOGFILE
> exit 0
> 
> It somehow isn't working. I can call the wrapper script manually e.g.
> sudo -u vmail /usr/local/bin/sa-learn-pipe.sh --username=s...@mail.user
> --ham \
> < someham
> 
> But it doesn't work from dovecot. It seems the script is called. but no
> new patterns show up in the bayes DB. Unfortunately, the plugin seems to
> be documented poorly. How does it call the programme it pipes to? Is it
> something like $programme --par1 --par2 < message ? Why can't /
> shouldn't I call sa-learn directly? All the instructions I found on the
> in internet contained a wrapper script, but none bothered to explain why
> you would actually need it.
> 
> I would be very grateful, if someone could enlighten me on that...
> 
> Cheers,
> 
> Johannes


  1   2   3   4   5   >