|
List Info
Thread: Mapping spam to two different mail account
|
|
| Mapping spam to two different mail
account |
  Austria |
2008-03-17 15:25:32 |
I tried in amavisd.conf to send spams
with unknown incoming mail addresses
to an internal mail account spamall.
That is working fine.
All other correct existing mails
adresses with spam should go to an
account spamadmin. But I do not
receive any mail in this mail box.
I inserted a "!" that all correct
mails should go to spamadmin:
[BEGIN]
$spam_quarantine_to = new_RE( # per-recip multiple
[qr'^spamall arnold.at$'i => 'spamall arnold.at'],
[qr'!^spamall arnold.at$'i => 'spamadmin arnold.at'] );
[END]
What is here wrong or how can I do this
with amavis.
Thanks Harald
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
AMaViS-user mailing list
AMaViS-user lists.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: Mapping spam to two different mail
account |

|
2008-03-17 20:04:06 |
On 3/18/08, Harald ARNOLD <listen arnold.at> wrote:
>
> I inserted a "!" that all correct
>
mails should go to spamadmin:
...
> [qr'!^spamall arnold.at$'i => 'spamadmin arnold.at'] );
I don't believe you can use "!" like this in a
hash list, only in an ACL
list.
However, because the hash list is processed in order, you
can simply include
a catch-all clause second, like this:
[BEGIN]
$spam_quarantine_to = new_RE( # per-recip multiple
[qr'^spamall arnold.at$'i => 'spamall arnold.at'],
[qr'^' => 'spamadmin arnold.at'] );
[END]
Cheers
Jeremy
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
AMaViS-user mailing list
AMaViS-user lists.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: Mapping spam to two different mail
account |
  Austria |
2008-03-18 06:44:01 |
Am Dienstag, den 18.03.2008, 12:04 +1100 schrieb Jeremy
Laidman:
> On 3/18/08, Harald ARNOLD <listen arnold.at> wrote:
> >
> > I inserted a "!" that all correct
> >
> mails should go to spamadmin:
>
> ...
>
> > [qr'!^spamall arnold.at$'i =>
'spamadmin arnold.at'] );
>
>
> I don't believe you can use "!" like this in
a hash list, only in an ACL
> list.
>
> However, because the hash list is processed in order,
you can simply include
> a catch-all clause second, like this:
>
> [BEGIN]
> $spam_quarantine_to = new_RE( # per-recip multiple
> [qr'^spamall arnold.at$'i => 'spamall arnold.at'],
> [qr'^' => 'spamadmin arnold.at'] );
> [END]
But then all incorrect mail adresses will go to spamall
and *all* mails are going to spamadmin.
Spamadmin should only receive mails that have not
"spamall arnold.at"
as receiving mail adress.
The reason is to devide those mails with correct adresses
to spamadmin and such mails with incorrect adresses to
spamall.
Thanks Harald
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
AMaViS-user mailing list
AMaViS-user lists.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: Mapping spam to two different mail
account |

|
2008-03-18 08:23:07 |
On 3/18/08, Harald ARNOLD <listen arnold.at> wrote:
>
> But then all incorrect mail adresses will go to
spamall
> and *all* mails are going to spamadmin.
>
I think the first match wins, and no more processing takes
place. From the
"HASH LOOKUPS" section in the file
README.lookups:
"The search sequence stops as soon as a match is found,
and the value
of the matched entry determines the result."
Therefore, the catch-all line will only match if the earlier
line doesn't
match.
Cheers
Jeremy
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
AMaViS-user mailing list
AMaViS-user lists.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: Mapping spam to two different mail
account |
  Austria |
2008-03-18 08:35:38 |
Am Mittwoch, den 19.03.2008, 00:23 +1100 schrieb Jeremy
Laidman:
> On 3/18/08, Harald ARNOLD <listen arnold.at> wrote:
> >
> > But then all incorrect mail adresses will go to
spamall
> > and *all* mails are going to spamadmin.
> >
>
> I think the first match wins, and no more processing
takes place. From the
> "HASH LOOKUPS" section in the file
README.lookups:
>
> "The search sequence stops as soon as a match is
found, and the value
> of the matched entry determines the result."
But *all* not correct mail are now in spamall - OK
And both correct and incorrect mail are in spamadmin :-(
Harald
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
AMaViS-user mailing list
AMaViS-user lists.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: Mapping spam to two different mail
account |
  Austria |
2008-03-18 18:53:43 |
Am Mittwoch, den 19.03.2008, 00:23 +1100 schrieb Jeremy
Laidman:
> On 3/18/08, Harald ARNOLD <listen arnold.at> wrote:
> >
> > But then all incorrect mail adresses will go to
spamall
> > and *all* mails are going to spamadmin.
> >
>
> I think the first match wins, and no more processing
takes place. From the
> "HASH LOOKUPS" section in the file
README.lookups:
>
> "The search sequence stops as soon as a match is
found, and the value
> of the matched entry determines the result."
Yes, that is the normal way. But:
In the description of the config file, it is explicitly
described
that this option is for multiple "quarantines". So
therefore will
be no stop after the first found. I am not good in perl -
very
poor. Otherwise I had changed and fixed the source code of
amavis.
Comment of original config file
# per-recip multiple quarantines
thanks Harald
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
AMaViS-user mailing list
AMaViS-user lists.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: Mapping spam to two different mail
account |

|
2008-03-18 20:27:08 |
On 3/19/08, Harald ARNOLD <listen arnold.at> wrote:
>
> But *all* not correct mail are now in spamall - OK
> And both correct and incorrect mail are in spamadmin
:-(
>
Sorry, I don't know why that is.
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
AMaViS-user mailing list
AMaViS-user lists.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: Mapping spam to two different mail
account |
  Austria |
2008-03-19 17:54:57 |
Am Mittwoch, den 19.03.2008, 12:27 +1100 schrieb Jeremy
Laidman:
> On 3/19/08, Harald ARNOLD <listen arnold.at> wrote:
> >
> > But *all* not correct mail are now in spamall -
OK
> > And both correct and incorrect mail are in
spamadmin :-(
> >
> Sorry, I don't know why that is.
I think that your quite better in perl.
The source changes have to be done in calling sub
"lookup(0, $rec, $quarantine_to_maps_ref)". It is
an HASH, therefore the next called sub is
"lookup_hash($addr,$t,$get_all)" this are only
25 lines of code.
My idea whould be:
1) Inserting a special character in the variable
"spam_quarantine_to" like the character
"!"
"!^spamall arnold.at$
2) Changinging code so that only this one
statement whould be filtered out. Because
there is no other logical change to source
3) Change the sub lookup_hash
Could you help me to change this sub ?
I am to bad in perl - I made a source
check only by a book - I now know many
more, but too less to make it work!
Source, Version amavisd-new-2.4.3 (20060930)
[BEGIN]
sub lookup_hash($$;$) {
my($addr, $hash_ref,$get_all) = _;
(ref($hash_ref) eq 'HASH')
or die "lookup_hash: arg2 must be a hash ref:
$hash_ref";
local($1,$2,$3,$4); my( matchingkey, result);
my($keys_ref,$rhs_ref) = make_query_keys($addr,1,1);
for my $key ( $keys_ref) { # do the search
if (exists $$hash_ref{$key}) { # got it
push( result,$$hash_ref{$key}); push( matchingkey,$key);
last if !$get_all;
}
}
# do the right-hand side replacements if any $n, $ or
$(n) is
specified
for my $r ( result) { # remember that $r is just an
alias to array
elements
if (!ref($r) && $r=~/$/) { # is a plain string
containing a '$'
my($any) = $r =~ s{ $ ( (d+) | { (d+) } | (
(d+) ) ) }
{ my($j)=$2+$3+$4; $j<1 ? '' :
$rhs_ref->[$j-1] }gxse;
# bring taintedness of input to the result
$r .= substr($addr,0,0) if $any;
}
}
if (!ll(5)) {
# only bother with logging when needed
} elsif (! result) {
do_log(5,"lookup_hash(%s), no matches",
$addr);
} elsif (!$get_all) { # first match wins
do_log(5,'lookup_hash(%s) matches key "%s",
result=%s',
$addr, $matchingkey[0],
!defined($result[0])?'undef':
$result[0]);
} else { # want all matches
do_log(5,"lookup_hash(%s) matches keys: %s",
$addr,
join(', ', map
{sprintf('"%s"=>%s',$matchingkey[$_],
$result[$_])}
(0..$#result)) );
}
if (!$get_all) { !wantarray ? $result[0] : ($result[0],
$matchingkey[0]) }
else { !wantarray ? result : ( result,
matchingkey) }
}
[END]
Thanks Harald
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
AMaViS-user mailing list
AMaViS-user lists.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: Mapping spam to two different mail
account |

|
2008-03-19 22:20:42 |
On 3/19/08, Harald ARNOLD <listen arnold.at> wrote:
>
> Am Mittwoch, den 19.03.2008, 00:23 +1100 schrieb Jeremy
Laidman:
> > I think the first match wins, and no more
processing takes place. From
> the
> > "HASH LOOKUPS" section in the file
README.lookups:
> >
> > "The search sequence stops as soon as a match
is found, and the value
> > of the matched entry determines the result."
>
> Yes, that is the normal way. But:
>
> In the description of the config file, it is explicitly
described
> that this option is for multiple
"quarantines". So therefore will
> be no stop after the first found. I am not good in perl
- very
> poor. Otherwise I had changed and fixed the source code
of amavis.
>
> Comment of original config file
> # per-recip multiple quarantines
I don't think amavis is broken, at least not mine. The
config file has this
example after that comment about per-recip multiple
quarantines:
# virus_quarantine_to_maps = ( # per-recip multiple
quarantines
# new_RE( [qr'^user example.com$'i => 'infected '],
# [qr'^(.*) example.com$'i => 'virus-$ example.com'],
# [qr'^(.*)( [^ ])?$'i => 'virus-$$'] ),
# $virus_quarantine_to, # the usual default
#);
In this example, the third regexp would match everything
that the second
regexp matches, and so the example would only work if the
second regexp
causes searching to stop.
> The source changes have to be done in calling sub
> "lookup(0, $rec, $quarantine_to_maps_ref)". It is
> an HASH, therefore the next called sub is
> "lookup_hash($addr,$t,$get_all> )" this
are only
> 25 lines of code.
In the lookup(0, ...) call, the zero (0) goes into $get_all,
so when
lookup_hash() is called, it is told to not get all matching
values, and stop
at the first one:
for my $key ( $keys_ref) { # do the search
if (exists $$hash_ref{$key}) { # got it
push( result,$$hash_ref{$key}); push( matchingkey,$key);
last if !$get_all;
}
}
The "last" command stops the search as soon as a
match is found. So I don't
believe amavisd needs fixing.
The lookup_hash() subroutine will log what it finds at log
level 5. Can you
please show the log entries from lookup_hash? In
particular, if it is
searching only for the first match, you should see:
lookup_hash(the address) matches key ...
and if it is searching for all matches (like you're
suggesting), you should
see:
lookup_hash(the address) matches keys: ...
> Could you help me to change this sub ?
> I am to bad in perl - I made a source
> check only by a book - I now know many
> more, but too less to make it work!
I'm not sure that any changes are needed to implement what
you want (a
negative match). If you craft a regexp appropriately, you
can probably
achieve what you want with a negative assertion. From
"perldoc perlre":
"(?!pattern)"
A zero-width negative look-ahead assertion.
For example
"/foo(?!bar)/" matches any
occurrence of "foo" that isn't
followed by "bar".
So for example, you might do this:
$spam_quarantine_to = new_RE( # per-recip multiple
[qr'^spamall arnold.at$'i => 'spamall arnold.at
<spamadmin arnold.at>'],
[qr'^(?!spamall arnold.at$)'i => 'spamadmin arnold.at']);
The ties to start (^) and end ($) of string are a bit
strange at first
sight, and they have something to do with being a
directional, zero-width
assertion, but the regexp should work as shown.
Having shown how to do this, I still can't understand why
things are not
working the way you want, with things as per my first
suggestion, with a
catch-all regexp in the second line.
Cheers
Jeremy
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
AMaViS-user mailing list
AMaViS-user lists.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: Mapping spam to two different mail
account |
  Austria |
2008-03-20 12:08:44 |
Am Donnerstag, den 20.03.2008, 14:20 +1100 schrieb Jeremy
Laidman:
> On 3/19/08, Harald ARNOLD <listen arnold.at> wrote:
> >
> > Am Mittwoch, den 19.03.2008, 00:23 +1100 schrieb
Jeremy Laidman:
> > > I think the first match wins, and no more
processing takes place. From
Sorry, I think I gave you wrong sub - look at the log. It
will
be processed in lookup_re:
log:
[BEGIN]
lookup: [spamall [127.0.0.1]]
lookup_re0: before loop
lookup_re1: [ARRAY(0x887031c)][spamall [127.0.0.1]]
lookup_re2a: [(?i-xsm:^spamall arnold\.at$)][spamall arnold.at]
lookup_re2: [(?i-xsm:^spamall arnold\.at$)][spamall arnold.at]
lookup_re1: [ARRAY(0x8ca4fec)][spamall [127.0.0.1]]
lookup_re2a: [(?i-xsm:^(?!spamall arnold\.at$))][spamadmin arnold.at]
lookup_re2: [(?i-xsm:^(?!spamall arnold\.at$))][spamadmin arnold.at]
lookup_re6
lookup_re8: after loop
[END]
src:
[BEGIN]
sub lookup_re($$;$) {
my($self, $addr,$get_all) = _;
local($1,$2,$3,$4); my( matchingkey, result);
do_log( 0, "lookup_re0: before loop" );
for my $e ( $self) { # try each regexp in the list
do_log( 0, "lookup_re1: [%s][%s]", $e, $addr
);
my($key,$r);
if (ref($e) eq 'ARRAY') { # a pair: (regexp,result)
($key,$r) = ($e->[0], $e < 2 ? 1 :
$e->[1]);
do_log( 0, "lookup_re2a: [%s][%s]",
$e->[0], $e->[1] );
do_log( 0, "lookup_re2: [%s][%s]", $key, $r
);
} else { # a single regexp (not a pair), implies result
1
($key,$r) = ($e, 1);
do_log( 0, "lookup_re3: [%s][%s]", $key, $r
);
}
""=~/x/; # braindead Perl: serves as
explicit deflt
# for an empty regexp
my( rhs); # match, capturing parenthesized subpatterns
in rhs
if (!ref($addr)) { rhs = $addr =~ /$key/
}
else {
do_log( 0, "lookup_re5" );
for ( $addr) { rhs = /$key/ }; last if rhs
} # inner loop
if ( rhs) { # regexp matches
do_log( 0, "lookup_re6" );
# do the righthand side replacements if any
# $n, $ or $(n) is specified
if (!ref($r) && $r=~/$/) { # triage
my($any) = $r =~ s{ $ ( (d+) | { (d+) } | (
(d+) ) ) }
{ my($j)=$2+$3+$4; $j<1 ? '' :
$rhs[$j-1] }gxse;
# bring taintedness of input to the result
$r .= substr($addr,0,0) if $any;
do_log( 0, "lookup_re7" );
}
push( result,$r); push( matchingkey,$key);
last if !$get_all;
}
}
do_log( 0, "lookup_re8: after loop" );
# logging-part: uninteressting
if (!$get_all) { !wantarray ? $result[0] : ($result[0],
$matchingkey[0]) }
else { !wantarray ? result : ( result,
matchingkey) }
}
[END]
Thanks Harald
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
AMaViS-user mailing list
AMaViS-user lists.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/
|
|
|
|