On 3/19/08, Harald ARNOLD <[EMAIL PROTECTED]> 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:

[EMAIL PROTECTED] = (   # per-recip multiple quarantines
#  new_RE( [qr'[EMAIL PROTECTED]'i => 'infected@'],
#          [qr'^(.*)@example\.com$'i => '[EMAIL PROTECTED]'],
#          [qr'^(.*)(@[EMAIL PROTECTED])?$'i      => 'virus-${1}${2}'] ),
#  $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([EMAIL PROTECTED]) matches key ...

and if it is searching for all matches (like you're suggesting), you should
see:

  lookup_hash([EMAIL PROTECTED]) 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'[EMAIL PROTECTED]'i => '[EMAIL PROTECTED] <[EMAIL PROTECTED]>'],
  [qr'^([EMAIL PROTECTED])'i => '[EMAIL PROTECTED]']);

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/
_______________________________________________
AMaViS-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

Reply via email to