Re: [exim] Mysql matching of $defaultdomain as well as $allv…

Inizio della pagina
Delete this message
Reply to this message
Autore: Mike Cardwell
Data:  
To: exim-users
Oggetto: Re: [exim] Mysql matching of $defaultdomain as well as $allvirtualdomains
On 05/10/2009 23:05, Ted Cooper wrote:

>> http://struction.de/projects/HOWTO_VirtualMail_Exim-MySQL-Spamassassin-ClamAV-Dovecot/index
>
> Looks good except that it uses sender callouts, but let's not start that
> **** fight argument again.
>
>> The basic gist is that user accounts are stored in a MySQL database for
>> Dovecot (that part works). I need Exim to check this database for valid
>> users, and when the domain part is "lightspeed.ca", it looks for the user
>> field in the database, with a blank domain name. Otherwise, Exim needs to
>> do another MySQL lookup to check to make sure both the local part and the
>> domain exist in the database. The pseudo code looks like this:
>>
>> if $domain = "lightspeed.ca" and lookup mysql {
>>       SELECT CONCAT(username,'@',domain) AS email
>>       FROM user
>>       WHERE username='${quote_mysql:$local_part}'
>>       AND domain=''
>>     }
>>     elif match $domain lookup mysql {
>>       SELECT CONCAT(username,'@',domain) AS email
>>       FROM user
>>       WHERE username='${quote_mysql:$local_part}'
>>       AND domain='${quote_mysql:$domain}'
>>     }
>> }

>>
>> The following Exim router works, but not with the users in the database
>> that have no domain part:
>>
>> mysql_user:
>>    driver                = accept
>>    # restriction to local domains only may be a double check, as the
>> condition takes care of it already ;-)
>>    domains               = +local_domains
>>    condition             = ${lookup mysql{ \
>>                     SELECT CONCAT(username,'@',domain) AS email \
>>                     FROM user \
>>                     WHERE username='${quote_mysql:$local_part}' \
>>                     AND domain='${quote_mysql:$domain}' \
>>                     AND SMTP_allowed='YES' \
>>                     }{true}{false}}
>>    local_part_suffix     = +*
>>    local_part_suffix_optional
>>    transport             = local_mysql_delivery
>>    no_more

>
> As it stands, a lightspeed.ca account gets the exact same lookup as an
> example.com user.
>
> So .... make 2 routers. Put this one before the other so that it pulls
> the lightspeed.ca ones out before the other +local_domains one.


I would have been tempted to leave it in a single router, and just
update the logic in the mysql query:

condition = ${lookup mysql{ \
SELECT IF(COUNT(*)=1,'true','false') \
FROM user \
WHERE username='${quote_mysql:$local_part}' \
AND IF(domain='','lightspeed.ca',domain)='${quote_mysql:$domain}' \
AND SMTP_allowed='YES' LIMIT 1 \
}}

I've made several small changes there that you might want to take a look at.

--
Mike Cardwell - IT Consultant and LAMP developer
Cardwell IT Ltd. (UK Reg'd Company #06920226) http://cardwellit.com/