Re: [exim] struggling with conditions

Top Page
Delete this message
Reply to this message
Author: Magnus Holmgren
Date:  
To: exim-users
Subject: Re: [exim] struggling with conditions
On Monday 07 May 2007 08:09, Dominique wrote:
> I am working on a greylist implementation where greylist is defined per
> recipient. The greylist settings are stored in a MySQL database on a per
> domain basis. I realise this is a bit expensive, but it keeps the system
> fairly dynamic.
>
> This is what I currently have in my defer ACL (rcpt):
>
>         warn set acl_m_PROTECTION = ${lookup mysql{SELECT setting FROM
> settings WHERE domain_name='$domain'}}

>
>         condition = {{if eq{acl_m_PROTECTION}{1} { \
>         ALL_GREY = true} \
>         } {elseif eq{acl_m_PROTECTION}{2} { \
>         SKIP_GREY = true } \
>         } {elseif eq{acl_m_PROTECTION}{3} { \
>         PARTIAL_GREY = true } \
>         }


How did you make up this syntax? As far as Exim is concerned, this is just a
long string. I'm not sure whether one or more macros become defined, but in
any case you can't conditionally define macros based on string expansion
results. Macros are defined when the config file is read. They are not
general-purpose variables.

Have you read the specification, in particular chapters 11 and 40?

>         .ifdef SKIP_GREY
>           !local_parts = +skip_grey
>         .elifdef PARTIAL_GREY
>           local_parts = +partial_grey
>         .elifdef ALL_GREY
>           local_parts = *
>         .endif
>         acl = greylist_acl


This could work, but not the way you want.

> 08:58:51 20672 processing "defer"
> 08:58:51 20672 check !senders = : postmaster
> 08:58:51 20672 address match: subject=sender@??? pattern=
> 08:58:51 20672 d242.net in ""? no (end of list)
> 08:58:51 20672 address match: subject=sender@??? pattern=postmaster
> 08:58:51 20672 sender.net in "postmaster"? no (end of list)
> 08:58:51 20672 sender@??? in ": postmaster"? no (end of list)


The above log lines have no connection with the ACL at hand, but it seems that
you're trying to match an address against a local part list. You need
postmaster@* there.

You need something like this:

   warn set acl_m_PROTECTION = ${lookup mysql{SELECT setting FROM settings \
                                              WHERE domain_name='$domain'}}


   accept condition = ${if eq{acl_m_PROTECTION}{1}}
          acl = greylist_acl
   accept condition = ${if eq{acl_m_PROTECTION}{2}}
          !local_parts = +skip_grey
          acl = greylist_acl
   accept condition = ${if eq{acl_m_PROTECTION}{3}}
          local_parts = +partial_grey
          acl = greylist_acl


This assumes that greylist_acl returns defer if the mail is to be deferred,
deny if not, and never accept.

What are skip_grey and partial_grey? Do they depend on the domain too?

-- 
Magnus Holmgren        holmgren@???
                       (No Cc of list mail needed, thanks)


"Exim is better at being younger, whereas sendmail is better for
Scrabble (50 point bonus for clearing your rack)" -- Dave Evans