Re: [exim] Help to logical OR two conditions

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Phil Pennock
Ημερομηνία:  
Προς: Victor Sudakov
Υ/ο: exim-users
Αντικείμενο: Re: [exim] Help to logical OR two conditions
On 2020-10-01 at 13:24 +0700, Victor Sudakov via Exim-users wrote:
> Could you please help me unite the following two ACL expressions into one:
>
> accept condition      = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}
> accept condition      = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}


Why?

It's _possible_ to combine conditions but too often it creates a bit of
a mess.

If you just leave it as two different accept verbs, then if the first
one doesn't pass, the second will be tested and ... you will have a
short-circuiting OR by using accept-then-accept.

For a Router, all condition rules must pass, so it becomes an AND.

> Should be fairly simple but... I've tried variants of '${if or {...' by
> the manual but all I got were errors like


The explanations here have been covered by others in the thread but I'm
combining it all into one, then comparing to the original.

So: a string needs to be made into a boolean status, because or/and take
booleans, not general strings. "Expansion conditions".

* bool{X} interprets X in the same way that ACL condition rules do
* bool_lax{X} interprets X in the same way that Router conditions do

So these should be equivalent:

  accept condition = ${if or{\
       {bool{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}}}\
       {bool{${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}}}\
       }}


accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}
accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}

I don't know about you, but I find the separate rules easier to read and
debug, with fewer braces to be matched and fewer bits of specialist lore
to be memorized.

Simplicity and lack of nesting wins out over fancy boolean conditions
constructed by a human instead of a machine.

(But I'm biased, I added the ability to have multiple condition rules to
a Router.)

-Phil