List Info

Thread: Modify the call for spamassassin in the SA-Plugin




Modify the call for spamassassin in the SA-Plugin
country flaguser name
Switzerland
2007-05-09 06:06:02
Hi list, hi everyone else

I'm playing with the idea to change the way spamassassin is
called by AMaViS and I'm looking for feedback about the
idea.
Hopefully it is not too stupid.

The reasoning goes like this: we do all our alias- and
list-expansion before calling the spamfilters to handle the
inabilities of some of our mailfilters (not all are as
flexible as
AMaViS) and particularly to have per-user-filtering even on
our lists. So when AMaViS gets the mail, there will be only
one recipient left.

Even though it's nice how AMaViS is applying some smart
logic when dealing with multiple recipients in our case it
will not be needed and we'd really like to use to use
spamassassin's bayes-db on a per user basis.

My assumption is that this is a rather simple change even
though I'm not a perl-guru. So what I was looking for is
the
place where spamassassin is called within AMaViS and then
change this call. Hopefully the RCPT TO-address is
available
at that point.

It all boils down to this:

sub initializeSpamAssassin {
	...
}

I'm not yet certain in what variable the envelope-recipient
(RCPT TO) is stored ($R?), but if so I could do

	username => $R,

within the above block according to the manpage of
Mail::SpamAssassin and be done with that, no?


Thanks a lot in advance for all input

mauro

PS: I know that this could all be achieved by having a
maildroprc calling spamc with the correct parameters but
we decided to keep the filtering on the MXes and not on the
mail-storage server for scalability-reasons.

------------------------------------------------------------
-------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and
take
control of your XML. No limits. Just data. Click to get it
now.
http://sourcefor
ge.net/powerbar/db2/
_______________________________________________
AMaViS-user mailing list
AMaViS-userlists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user

AMaViS-FAQ:http://www.amav
is.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/ho
wto/

Re: Modify the call for spamassassin in the SA-Plugin
country flaguser name
Slovenia
2007-05-09 08:13:38
Mauro,

> The reasoning goes like this: we do all our alias- and
> list-expansion before calling the spamfilters to handle
the
> inabilities of some of our mailfilters (not all are as
flexible as
> AMaViS) and particularly to have per-user-filtering
even on
> our lists. So when AMaViS gets the mail, there will be
only
> one recipient left.
>
> Even though it's nice how AMaViS is applying some
smart
> logic when dealing with multiple recipients in our case
it
> will not be needed and we'd really like to use to use
> spamassassin's bayes-db on a per user basis.
>
> My assumption is that this is a rather simple change
even
> though I'm not a perl-guru. So what I was looking for
is the
> place where spamassassin is called within AMaViS and
then
> change this call. Hopefully the RCPT TO-address is
available
> at that point.

It is doable, see spamd for code example.

A ref to the envelope recipients list (only one element
in your case) is available in $msginfo->recips.

> It all boils down to this:
> sub initializeSpamAssassin {
> 	username => $R,
> within the above block according to the manpage of
> Mail::SpamAssassin and be done with that, no?

No, this isn't the right place. Sub initializeSpamAssassin
is
called before forking takes place, then several messages
are
processed by the same child process.

You should be calling
$spamassassin_obj->signal_user_changed
each time from within sub call_spamassassin.
See man Mail::SpamAssassin.

  Mark


------------------------------------------------------------
-------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and
take
control of your XML. No limits. Just data. Click to get it
now.
http://sourcefor
ge.net/powerbar/db2/
_______________________________________________
AMaViS-user mailing list
AMaViS-userlists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user

AMaViS-FAQ:http://www.amav
is.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/ho
wto/

Re: Modify the call for spamassassin in the SA-Plugin
country flaguser name
Switzerland
2007-05-20 16:24:35
Hi everyone, hi Mark

I'm sorry for the very very late reply, we ran into
unexpeted
problems elsewhere.
Finally got back to work on the AMaViS-Issue.

To sum up shortly: I wanted to have per-user SA-Settings by
telling SA what user we have for this mail.

[snip]

>> Even though it's nice how AMaViS is applying some
smart
>> logic when dealing with multiple recipients in our
case it
>> will not be needed and we'd really like to use to
use
>> spamassassin's bayes-db on a per user basis.
>>
>> My assumption is that this is a rather simple
change even
>> though I'm not a perl-guru. So what I was looking
for is the
>> place where spamassassin is called within AMaViS
and then
>> change this call. Hopefully the RCPT TO-address is
available
>> at that point.
>
> It is doable, see spamd for code example.

ok, i got that one, seems clear.

> A ref to the envelope recipients list (only one
element
> in your case) is available in $msginfo->recips.

thanks

> You should be calling
$spamassassin_obj->signal_user_changed
> each time from within sub call_spamassassin.

This is where my problem lies: I was unable to find said
sub call_spamassassin yet (BTW, we are running
amavisd-new-2.4.2
(20060627)). My best guess for what you could have meant
with
"call_spamassassin" is:

sub check {
	...
};

But, as I have to admit, things in there are too complicated
for me to
understand. Here is my try though: This is the point where I
assume  
SA is
called:

[snip]
	do_log(5,"calling SA parse, SA version %s",
$sa_version);
	if ($sa_version=~/^(d+(?:.d+)?)/ && $1 >= 3)
{
		$mail_obj = $spamassassin_obj->parse(lines);
	} else {  # 2.63 or earlier
[snip]

It seems to me, just inserting something like

	$spamassassin_obj->signal_user_changed(
		{
			username => $msginfo->recips,
			user_dir => undef
		}
	);

into that if-clause would not work, right?

Thanks again for all pointers and help!

Best whishes to everyone coming from Switzerland
mauro


------------------------------------------------------------
-------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and
take
control of your XML. No limits. Just data. Click to get it
now.
http://sourcefor
ge.net/powerbar/db2/
_______________________________________________
AMaViS-user mailing list
AMaViS-userlists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user

AMaViS-FAQ:http://www.amav
is.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/ho
wto/

Re: Modify the call for spamassassin in the SA-Plugin
country flaguser name
Slovenia
2007-05-21 13:41:37
Mauro,

> > You should be calling
$spamassassin_obj->signal_user_changed
> > each time from within sub call_spamassassin.
> This is where my problem lies: I was unable to find
said
> sub call_spamassassin yet (BTW, we are running
amavisd-new-2.4.2
> (20060627)).

I was referring to 2.5.0.  If you are contemplating code
changes,
you should not waste your time with a year-old version,
time will leave you behind.

That being said, that part of the code is similar,
just moved into a new subroutine to be able to run
SA as a detached process in case somebody wished to do so.

> My best guess for what you could have meant with 
> "call_spamassassin" is:
>
> sub check {
> 	...
> };
>
> But, as I have to admit, things in there are too
complicated for me to
> understand. Here is my try though: This is the point
where I assume
> SA is called:
> 	do_log(5,"calling SA parse, SA version %s",
$sa_version);
> 	if ($sa_version=~/^(d+(?:.d+)?)/ && $1
>= 3) {
> 		$mail_obj = $spamassassin_obj->parse(lines);
> 	} else {  # 2.63 or earlier
> It seems to me, just inserting something like
> 	$spamassassin_obj->signal_user_changed(
> 		{
> 			username => $msginfo->recips,
> 			user_dir => undef
> 		}
> 	);
> into that if-clause would not work, right?

Like I said, the $msginfo->recips is a _list_ or
recipients,
not a single recipient.

Something like the following might work for single-recipient
messages
(patch against 2.5.0), although I haven't tried it (apart
from
syntactical correctness):

--- amavisd.orig	Mon Apr 23 05:25:30 2007
+++ amavisd	Mon May 21 20:38:02 2007
 -17565,4
+17565,10 
   eval {
     $which_section = 'SA parse';
+    my($recips) = $msginfo->recips;
+    if ($recips == 1) {
+      do_log(3,"changing SA user to %s",
$recips->[0]);
+    # $spamassassin_obj->load_scoreonly_...
+      $spamassassin_obj->signal_user_changed({username
=> $recips->[0]});
+    }
     do_log(5,"calling SA parse, SA version %s,
%.6f",
              $sa_version, $sa_version_num);



Mark

------------------------------------------------------------
-------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and
take
control of your XML. No limits. Just data. Click to get it
now.
http://sourcefor
ge.net/powerbar/db2/
_______________________________________________
AMaViS-user mailing list
AMaViS-userlists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user

AMaViS-FAQ:http://www.amav
is.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/ho
wto/

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )