|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: $lookup variable and MySQL tables
From: Magnus Bäck (magnus
dsek.lth.se)
Date: Thu Dec 02 2004 - 15:33:43 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thursday, December 02, 2004 at 22:22 CET,
Mike M <mike
opennix.com> wrote:
[...]
> For instance, I have written a Perl script that enumerates all valid
> recipients, forwards, and aliases on the systems and creates a hash
> file to be used by Postfix via relay_recipient_maps. The script runs
> from a cron job so that Postfix can be made aware of changes
> automatically. The problem is the delay between the time the changes
> are made and the running of the cron job, which runs every two hours.
> This isn't a big deal, but I'd like to eliminate the delay if
> possible.
Running the cron job more often is not an alternative, I gather?
> My thought was to compile vpopmail with MySQL support and have Postfix
> use the resulting tables for the relay_recipient_maps check, thus
> changes would be seen as the happen.
>
> When I tested this out on a dev box, I found that vpopmail stores the
> local part and domain part of accounts in separate fields. As I
> understand it the value of $lookup when querying relay_recipient_maps is
> user
domain.tld. Therefore, this will not work with the structure set up
> by vpopmail.
Sure it will. Construct a query on this form:
SELECT ... FROM ... WHERE CONCAT(user, '
', domain) = '%s'
I don't the query optimizer can do a very good job, though. The
where_field parameter doesn't have to specify just the name of
a column; the string is just inserted into the query.. Behold
dict_mysql.c:
vstring_sprintf(query, "select %s from %s where %s = '%s' %s",
dict_mysql->name->select_field,
dict_mysql->name->table,
dict_mysql->name->where_field,
name_escaped,
dict_mysql->name->additional_conditions);
> Solutions I have considered for this new roadblock are:
> 1) Write a policy daemon to take the place of reject_unlisted_recipient,
> so that I could use more complex queries.
> 2) Patch the vpopmail code so that the tables contain a field with the
> full email address.
>
> Before I embark on either one, though, I wanted to be sure my
> interpretation of the value of $lookup, and how it is used, was correct.
> Because if I could use more complex queries for relay_recipient_maps
> lookups, I'd much rather do that. Reading the documentation didn't lead
> me to believe I would be able to do this, even with additional_conditions.
> I would need Postfix to split $lookup into something like $user and
> $domain.
This is *currently* not possible with dict_mysql. This feature is
present in dict_pgsql, and I think Victor Duckovni is going to merge
that functionaliy over to dict_mysql. If not, I'd be happy to do it.
[...]
--
Magnus Bäck
magnus
dsek.lth.se
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]