[exim] Domain lists with colon in query-style lookups

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Alexander Koch
Dátum:  
Címzett: exim-users
Tárgy: [exim] Domain lists with colon in query-style lookups
Hello,

some times our mail server got an email adress like
<"mailto:ab"@???>. We look into a MySQL database for information
about the user. The lookup fails with this sort of addresses and exim
gives a "451 Temporary local problem - please try later" error in the
SMTP dialog.

One information about mail users is "should I scan for viruses?". So I
had an SQL Statement where the local_part ist used for the MySQL lookup.
I use this lookup in the domains statement of a manualroute router.

Here the configuration parts:

<snip src="exim4.conf">
[...]
LOCAL_QUERY = SELECT vu_local_part FROM pop_virtuser WHERE \
              vu_local_part='${quote_mysql:$local_part}' \
              AND vu_domain='${quote_mysql:$domain}'
[...]
FEATURE_VIREN = LOCAL_QUERY AND vu_viren_scan=1
[...]
feature_virenscanner_router:
  driver = manualroute
  condition = ${if or{ \
                     { eq {$interface_port}{10025} } \
                     { eq {$received_protocol}{spam-scanned} } \
                } {0}{1}}
  domains = mysql; FEATURE_VIREN
  transport = feature_virenscanner_transport
  route_list = "* localhost byname"
  self = send
[...]
</snip>



In the debug session I got:

<snip src="exim4 -d -bhc 1.2.3.4">
--------> feature_virenscanner_router router <--------
local_part=mailto:ab domain=domain.de
checking domains
search_open: mysql "NULL"
cached open
search_find: file="NULL"
key="SELECT vu_local_part FROM pop_virtuser WHERE vu_local_part='mailto" partial=-1 affix=NULL starflags=0
LRU list:
internal_search_find: file="NULL"
type=mysql key="SELECT vu_local_part FROM pop_virtuser WHERE vu_local_part='mailto"
database lookup required for SELECT vu_local_part FROM pop_virtuser WHERE vu_local_part='mailto
MYSQL query: SELECT vu_local_part FROM pop_virtuser WHERE vu_local_part='mailto
MYSQL using cached connection for localhost/pop_users/mailman
MYSQL: query failed: You have an error in your SQL syntax near ''mailto' at line 1

lookup deferred: MYSQL: query failed: You have an error in your SQL syntax near ''mailto' at line 1

domain.de in "mysql; SELECT vu_local_part FROM pop_virtuser WHERE vu_local_part='mailto:ab' AND vu_domain='domain.de' AND vu_viren_scan=1"? lookup deferred for mysql; SELECT vu_local_part FROM pop_virtuser WHERE vu_local_part='mailto
domains check lookup or other defer
----------- end verify ------------
</snip>

What happens? IMHO, the SQL statement got cropped at the colon and the
lookup failes.

The spec (10.8 Domain lists) says:

<snip>
If the pattern starts with the name of a query-style lookup type
followed by a semicolon (for example, nisplus; or ldap;), the remainder
of the pattern must be an appropriate query for the lookup type, as
described in chapter 9. For example:

  hold_domains = mysql;select domain from holdlist \
    where domain = '$domain';


In most cases, the data that is looked up is not used (so for an SQL
query, for example, it doesn't matter what field you select). Exim is
interested only in whether or not the query succeeds. However, when a
lookup is used for the domains option on a router, the data is preserved
in the $domain_data variable and can be referred to in other options.
</snip>

For me this means that all of the rest of the line forms the lookup and
will not be parsed. But it seems that the colon still is the separator.

My questions:

1) Did I understand the spec right and the colon should not be
interpreted.

2) Is there a way to escape the colon? I only know to change the
separator, but as it is a local_part any punctuation can be in
it.

IMHO, should the same problem appear if I use the statement in an
local_part list. As there is the same separator ...

Regards,
Alex

--
Alexander Koch, mailto: ak@???
ILK Internet GmbH, Akademiestrasse 25 - 27, D-76133 Karlsruhe
Tel: +49 (0) 721 9100 0, Fax: +49 (0) 721 9100 191
http://www.ilk.net