Re: [exim] single quote question / problem

Etusivu
Poista viesti
Vastaa
Lähettäjä: W B Hacker
Päiväys:  
Vastaanottaja: exim users
Aihe: Re: [exim] single quote question / problem
Nathan Hruby wrote:
> 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:


Nathan,

Apologies I don't have more time at the moment, so this is *not definitive* (but
IS 'pragmatic' - many years of production use on many servers..).

A quick grep of my pgsql SQL calls finds single quotes used:

- ALWAYS around Exim 'built-in' variables

- ONLY around Exim 'built-in' variables AND string-literals

===

As in: '${quote_mysql:$local_part}'      <===>  '${quote_pgsql:$local_part}'


And:

${lookup pgsql{INSERT into brownlist (pg_when, pg_why, pg_ip, ....... \
VALUES ('$tod_log','RUD','$sender_host_address', .........

Where 'RUD' is a label set right there at that point, has no other appearance.


BUT *NO* use of single-quotes where the element is NOT an Exim variable or
string-literal:


Ex: Where you have:

AND user_status_type = 'active'

I have:

AND pg_active                (no quotes)


(boolean type here, so equality test need not be specified)

===

AFAICS, this sort of quoting is an *SQL* requirement, not an Exim-specific one.

HTH

Bill Hacker




>
> ====
> 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}}
>
> begin routers
> users_forward:
> driver = redirect
> domains = +users_domains
> check_ancestor
> condition = ${if or { { eq {USER_EMAIL_OPT}{a} } { eq
> {USER_EMAIL_OPT}{SENDING_IP_CLASS} } } }
>
> 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
> ===
>
> Thanks,
>
> -n