I did some more testing and found out that is does not matter what
operator I use in the outer $if (Example, replace def:var by eq etc.).
But what changes this is the fail in $extract, here's a different example:
exim -d-all+expand -be '${if
def:received_ip_address{${extract{$received_ip_address}{10.0.0.1=hosta
127.0.0.1=local4 ::1=local6}{$value}{$primary_hostname}}}fail}'
Exim version 4.87 uid=0 gid=0 pid=18087 D=100
Berkeley DB: Berkeley DB 6.0.35: (February 26, 2015)
Support for: crypteq iconv() IPv6 PAM OpenSSL DKIM DNSSEC Event OCSP PRDR
Lookups (built-in): lsearch wildlsearch nwildlsearch iplsearch cdb dbm
dbmjz dbmnz dnsdb dsearch passwd sqlite
Authenticators: cram_md5 plaintext spa
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/mailstore autoreply pipe smtp
Fixed never_users: 0
Size of off_t: 8
Compiler: GCC [5.3.0]
Library version: OpenSSL: Compile: OpenSSL 1.0.2h 3 May 2016
Runtime: OpenSSL 1.0.2h 3 May 2016
: built on: reproducible build, date
unspecified
Library version: PCRE: Compile: 8.38
Runtime: 8.38 2015-11-23
Library version: SQLite: Compile: 3.12.2
Runtime: 3.13.0
WHITELIST_D_MACROS unset
TRUSTED_CONFIG_LIST unset
configuration file is /etc/exim/exim.conf
log selectors = 0000cffc 10332001
trusted user
admin user
condition: def:received_ip_address
result: false
expanding: $received_ip_address
result:
skipping: result is not used
expanding: 10.0.0.1=hosta 127.0.0.1=local4 ::1=local6
result: 10.0.0.1=hosta 127.0.0.1=local4 ::1=local6
skipping: result is not used
expanding: $value
result:
skipping: result is not used
expanding: $primary_hostname
result:
skipping: result is not used
expanding: ${extract{$received_ip_address}{10.0.0.1=hosta
127.0.0.1=local4 ::1=local6}{$value}{$primary_hostname}}
result:
skipping: result is not used
failed to expand: ${if
def:received_ip_address{${extract{$received_ip_address}{10.0.0.1=hosta
127.0.0.1=local4 ::1=local6}{$value}{$primary_hostname}}}fail}
error message: "if" failed and "fail" requested
failure was forced
Failed: "if" failed and "fail" requested
>>>>>>>>>>>>>>>> Exim pid=18087 terminating with rc=0 >>>>>>>>>>>>>>>>
As can be observed the parsing of the ${extract} substring now works
correctly. So when ${extract} is used with a keyed extraction, where
{<string3>} is repplaced with the word fail without curly braces,
parsing seems to go wrong at some point.
Regards
-Sven
Am 01.06.2016 um 15:39 schrieb Sven Eschenberg:
Am 01.06.2016 um 14:50 schrieb Jeremy Harris:
On 01/06/16 13:42, Sven Eschenberg wrote:
Thanks for your input
Exim version?
Exim version 4.87 #1 built 24-May-2016 01:15:17
Run with "-d-all+expand".
All of them, or just the one yielding the syntax error?
exim -d-all+expand -be '${if
def:received_ip_address{${extract{$received_ip_address}{10.0.0.1=hosta
127.0.0.1=local4 ::1=local6}{$value}fail}}fail}'
Exim version 4.87 uid=0 gid=0 pid=18037 D=100
Berkeley DB: Berkeley DB 6.0.35: (February 26, 2015)
Support for: crypteq iconv() IPv6 PAM OpenSSL DKIM DNSSEC Event OCSP PRDR
Lookups (built-in): lsearch wildlsearch nwildlsearch iplsearch cdb dbm
dbmjz dbmnz dnsdb dsearch passwd sqlite
Authenticators: cram_md5 plaintext spa
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/mailstore autoreply pipe smtp
Fixed never_users: 0
Size of off_t: 8
Compiler: GCC [5.3.0]
Library version: OpenSSL: Compile: OpenSSL 1.0.2h 3 May 2016
Runtime: OpenSSL 1.0.2h 3 May 2016
: built on: reproducible build, date
unspecified
Library version: PCRE: Compile: 8.38
Runtime: 8.38 2015-11-23
Library version: SQLite: Compile: 3.12.2
Runtime: 3.13.0
WHITELIST_D_MACROS unset
TRUSTED_CONFIG_LIST unset
configuration file is /etc/exim/exim.conf
log selectors = 0000cffc 10332001
trusted user
admin user
condition: def:received_ip_address
result: false
expanding: $received_ip_address
result:
skipping: result is not used
expanding: 10.0.0.1=hosta 127.0.0.1=local4 ::1=local6
result: 10.0.0.1=hosta 127.0.0.1=local4 ::1=local6
skipping: result is not used
expanding: $value
result:
skipping: result is not used
failed to expand: ${extract{$received_ip_address}{10.0.0.1=hosta
127.0.0.1=local4 ::1=local6}{$value}fail}}fail}
error message: missing or misplaced { or }
failed to expand: ${if
def:received_ip_address{${extract{$received_ip_address}{10.0.0.1=hosta
127.0.0.1=local4 ::1=local6}{$value}fail}}fail}
error message: missing or misplaced { or }
Failed: missing or misplaced { or }
Exim pid=18037 terminating with rc=0 >>>>>>>>>>>>>>>>
As far as I understand this the failure is already triggered during
${extract} which should be skipped since def:received_ip_address yields
false. But maybe I am reading this wrong.
Looking at this variant with $if{ instead of ${extract I can see that
the string of the expansion stops after the first fail and bracket, ie:
expanding: ${if eq{10.0.0.1}{$received_ip_address}{hosta}fail}
result:
skipping: result is not used
whereas the string parsing seems to go wrong for the ${extract case ...
since the string concludes with fail}}fail} where it should probably end
at fail}?
Regards
-Sven
--
## 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/