Lähettäjä: Nathan Hruby Päiväys: Vastaanottaja: exim-users Aihe: [exim] single quote question / problem
Greetings!
I was doing a quick proof of concept today and ran into an issue that
I believe I've tracked down to exim treating the single quote
character specially in some cases. For instance, given the following
config:
====
USER_EMAIL_OPT = ${lookup mysql{SELECT email_opt FROM user WHERE
user_name = '${quote_mysql:$local_part}' AND user_status_type =
'active' LIMIT 1;} ${value}}
SENDING_IP_CLASS = ${lookup ${sender_host_address}
net24-iplsearch{CONFDIR/special_hosts} ${value}}
data = ${lookup mysql{ ... yadda ...}}
no_more
====
I get the following error when running with exim -bhc:
====
failed to expand condition "${if or { { eq {${lookup mysql{SELECT
email_opt FROM user WHERE user_name = '${quote_mysql:$local_part}' AND
user_status_type = 'active' LIMIT 1;} ${value}}}{a} } { eq {${lookup
mysql{SELECT email_opt FROM user WHERE user_name =
'${quote_mysql:$local_part}' AND user_status_type = 'active' LIMIT 1;}
${value}}}{${lookup ${sender_host_address}
net24-iplsearch{/etc/exim/special_hosts} ${value}}} } } }" for
users_forward router: missing or misplaced { or } inside "or{...}"
condition
====
However, if I quote the leading single quote in USER_EMAIL_OPT by
enclosing it with double quotes, using the hex ascii code for a single
quote, escaping with a backslash, or escaping the "$" in the
${quote_mysql: then the condition successfully expands; however the
expansion injects the unwanted escapes, backslashes, etc.. that I
inserted in order to get it to exapnd into the sql query.
The same thing happens if I use the text from the macro directly in
the if condition instead of the macro.
Also of note is that if I do similar quoting for the remaining single
quotes in USER_EMAIL_OPT they are treated differently, eg:
"'"${quote_mysql:$local_part}"'"
appears in the error string as
${quote_mysq:$local_part""'"
Is there a proper or better way to apply quotes or is this a bug with
the parsing of sub expansions in ${if or ...} expansion? It looks
like a bug to me, in that the construct:
'${
has some edge case whereby exim seems to think it's a string literal
This is on CentOS-5 x86_64 with exim 4.69-33 built from atrpms/dag.
===
Exim version 4.69 #1 built 10-Jan-2008 21:09:16
Copyright (c) University of Cambridge 2006
Berkeley DB: Sleepycat Software: Berkeley DB 4.3.29: (September 12, 2006)
Support for: crypteq iconv() IPv6 PAM Perl Expand_dlfunc TCPwrappers
OpenSSL Content_Scanning Old_Demime Experimental_SPF Experimental_SRS
Experimental_DomainKeys
Lookups: lsearch wildlsearch nwildlsearch iplsearch cdb dbm dbmnz
dnsdb dsearch ldap ldapdn ldapm mysql nis nis0 nisplus passwd pgsql
sqlite
Authenticators: cram_md5 cyrus_sasl dovecot plaintext spa
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/maildir/mailstore/mbx autoreply lmtp pipe smtp
Fixed never_users: 0
Size of off_t: 8
Configuration file is /etc/exim/exim.conf
===