[exim] Stumped on router conditions

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Sander Smeenk
Date:  
À: exim-users
Sujet: [exim] Stumped on router conditions
Hi there,

I have been trying to have one router act when a condition is true, and
the other act when that same condition is not true. The conditions are
LDAP lookups. I'm omitting the specific lookup for privacy reasons. ;)

| > ${lookup ldap{...}{true}{false}}
| true


The lookup is defined as a macro in exim4.conf:
| HAS_FORWARDS = ${lookup ldap{...}{true}{false}}


I tried to have my router like this:
| routerWhenNoForwards:
|    debug_print = "routerWhenNoForwards HAS_FORWARDS"
|    condition = ! HAS_FORWARDS
|      [..]
|    no_more
| 
| routerWhenForwards:
|    debug_print  "routerWhenForwards HAS_FORWARDS"
|    condition = HAS_FORWARDS
|      [..]

|
| otherRouter:
|    ...


The lookup works and in '-be' testing yields 'true'.
In '-bt' testing, debug_print also shows that 'true':
| routerWhenNoForwards true


The address tested does indeed have forwards.
So, "! true" must mean "false", right?
That router should not run?
Yet, that routerWhenNoForwards router runs.

I made it work by duplicating the condition LDAP lookup macro and
negating it in the LDAP query. I am now using the 'HAS_NO_FORWARDS'
lookup on the 'WhenNoForwards' router and life is good again, but i
wonder what i am doing wrong?

Am i being bitten by the situation described in the 'Historical note' as
can be found at [1] in the docs? Is there a nicer way to do this than
having two lookups like i have now? That section isn't really clear on
not being able to negate a lookup like i tried...

Actually having two macros might be cleaner / more human readable, and i
think it doesn't really bother me, but still, this cost me a few minutes
before i gave in to having two lookups. ;)

Regards,
-Sander.

[1] https://www.exim.org/exim-html-current/doc/html/spec_html/ch-generic_options_for_routers.html
--
| 42.7 percent of all statistics are made up on the spot.
| 4096R/20CC6CD2 - 6D40 1A20 B9AA 87D4 84C7 FBD6 F3A9 9442 20CC 6CD2