Mailing List Archive

Cannot negate router lookup condition
I am running Exim 4.89. I have the following router in exim.conf:

send_direct:
driver = dnslookup
condition = ! ${lookup{$local_part@$domain}\
lsearch{/etc/exim/exim.passwd}{$value}{}}
transport = remote_smtp


I just can't seem to negate the condition. I want it to evaluate to
false if the email address is found in the password file - so that this
router is skipped. The debug output is below - and it is always the same
- even when I use {1}{0} - the condition always returns the password
from the file - instead of the value I give lsearch to return. Any help
would be much appreciated.

checking "condition" "!
${lookup{$local_part@$domain}lsearch{/etc/exim/exim.passwd}{$value}{}}"...
search_open: lsearch "/etc/exim/exim.passwd"
search_find: file="/etc/exim/exim.passwd"
key="email@mydomain.co.uk" partial=-1 affix=NULL starflags=0
LRU list:
6/etc/exim/exim.passwd
End
internal_search_find: file="/etc/exim/exim.passwd"
type=lsearch key="email@mydomain.co.uk"
file lookup required for email@mydomain.co.uk
in /etc/exim/exim.passwd
lookup yielded: mypassword
calling send_direct router


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Cannot negate router lookup condition [ In reply to ]
On 12/08/2020 21:45, Sebastian Arcus via Exim-users wrote:
> I am running Exim 4.89. I have the following router in exim.conf:
>
> send_direct:
>     driver = dnslookup
>     condition = ! ${lookup{$local_part@$domain}\
>           lsearch{/etc/exim/exim.passwd}{$value}{}}
>     transport = remote_smtp

That exclamation-mark is not interpreted; it just becomes part
of the string, with the expansion result, being tested by the
"condition" option.

The latter is documented as:
"if the result is [...] one of the strings “0” or “no” or “false”
(checked without regard to the case of the letters), the router is skipped.

So: forget the "!", and just have your lookup returning {0} or {1}.
Put them in *that* order in the ${lookup...} so that your condition
has the truth sense you wanted.


(You were assuming the rules for an ACL condition apply to a router
condition. Sorry. but historical reasons...)
--
Cheers,
Jeremy

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Cannot negate router lookup condition [ In reply to ]
On 12/08/20 22:04, Jeremy Harris via Exim-users wrote:
> On 12/08/2020 21:45, Sebastian Arcus via Exim-users wrote:
>> I am running Exim 4.89. I have the following router in exim.conf:
>>
>> send_direct:
>>     driver = dnslookup
>>     condition = ! ${lookup{$local_part@$domain}\
>>           lsearch{/etc/exim/exim.passwd}{$value}{}}
>>     transport = remote_smtp
>
> That exclamation-mark is not interpreted; it just becomes part
> of the string, with the expansion result, being tested by the
> "condition" option.
>
> The latter is documented as:
> "if the result is [...] one of the strings “0” or “no” or “false”
> (checked without regard to the case of the letters), the router is skipped.
>
> So: forget the "!", and just have your lookup returning {0} or {1}.
> Put them in *that* order in the ${lookup...} so that your condition
> has the truth sense you wanted.
>
>
> (You were assuming the rules for an ACL condition apply to a router
> condition. Sorry. but historical reasons...)

Arrrgh - thank you so much for this! I've been banging my head for hours
- reading and re-reading the documentation. I never realised that the
exclamation mark doesn't work in router conditions. Reversing the order
of {1}{0} and removing the exclamation worked as expected. Again, much
appreciated the quick and helpful reply!


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/