About table search order: not to query 'user+extension@domain.ltd'

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

About table search order: not to query 'user+extension@domain.ltd'

Zhang Huangbin
Dear all,

According to Postfix document, virtual(8), '[hidden email]'
is looked up first, then '[hidden email]'. Is it possible to
skip/ignore the address extension and just query '[hidden email]'?
(by the way, i want to ignore the extension in SQL/LDAP lookup.)

Thanks for your time and help. :)

------------
TABLE SEARCH ORDER
...
The search order is as follows. The search stops upon  the  first  suc-
cessful lookup.

o When  the  recipient  has  an  optional  address  extension  the
   [hidden email] address is looked up first.

o The  [hidden email]  address,  without  address  extension,  is
   looked up next.
------------
Reply | Threaded
Open this post in threaded view
|

Re: About table search order: not to query 'user+extension@domain.ltd'

Viktor Dukhovni
On Wed, Mar 11, 2015 at 11:32:43PM +0800, Zhang Huangbin wrote:
> Dear all,
>
> According to Postfix document, virtual(8), '[hidden email]'
> is looked up first, then '[hidden email]'. Is it possible to
> skip/ignore the address extension and just query '[hidden email]'?
> (by the way, i want to ignore the extension in SQL/LDAP lookup.)

Not at present.  You can only suppress lookups for bare keys which
can happen when the domain is $myorigin or matches $mydestination
by interpolating the lookup key into the query via '%u@%d' instead
of '%s'.  That will filter out keys with no @domain part.

This logic happens in the *SQL and LDAP table drivers, while the
sequencing of lookup keys happens above that layer, and is not
currently configurable.  Configurable case-folding and lookup key
selection is not currently implemented.

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: About table search order: not to query 'user+extension@domain.ltd'

Zhang Huangbin
On Wed, Mar 11, 2015 at 11:46 PM, Viktor Dukhovni
<[hidden email]> wrote:
>
> Not at present.  You can only suppress lookups for bare keys which
> can happen when the domain is $myorigin or matches $mydestination
> by interpolating the lookup key into the query via '%u@%d' instead
> of '%s'.  That will filter out keys with no @domain part.

Thanks Victor. :)

I'm afraid that '%u' doesn't work, it still has '+extension' in query.
for example:

*) part of my testing ldap lookup file:

query_filter    = (mail=%u@%d)

*) Testing with 'postmap':

# postmap -v -q '[hidden email]' ldap:./my_ldap_file.cf
...
postmap: dict_ldap_lookup: ./my_ldap_file.cf: Searching with filter
(mail=[hidden email])
...

As you can see, '%u' doesn't drop extension '+abc' in my test.
Anything wrong in my testing?
Reply | Threaded
Open this post in threaded view
|

Re: About table search order: not to query 'user+extension@domain.ltd'

Viktor Dukhovni
On Wed, Mar 11, 2015 at 11:55:31PM +0800, Zhang Huangbin wrote:

> On Wed, Mar 11, 2015 at 11:46 PM, Viktor Dukhovni
> <[hidden email]> wrote:
> >
> > Not at present.  You can only suppress lookups for bare keys which
> > can happen when the domain is $myorigin or matches $mydestination
> > by interpolating the lookup key into the query via '%u@%d' instead
> > of '%s'.  That will filter out keys with no @domain part.
>
> Thanks Victor. :)
>
> I'm afraid that '%u' doesn't work, it still has '+extension' in query.
> for example:

I did not say it would solve your problem.  It addresses a different
need.

> As you can see, '%u' doesn't drop extension '+abc' in my test.
> Anything wrong in my testing?

No, that's what %u is supposed to do.

You may well be able to do something with advanced SQL string
manipulation to short-circuit queries that contain "+".

        SELECT result
        FROM table
        WHERE key = '%u@%d'
        AND key NOT LIKE '%%+%%'

An SQL server may well optimize that query away when the key contains
a "+" and not do any disk I/O.

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: About table search order: not to query 'user+extension@domain.ltd'

Zhang Huangbin
On Thu, Mar 12, 2015 at 12:03 AM, Viktor Dukhovni
<[hidden email]> wrote:

>
> You may well be able to do something with advanced SQL string
> manipulation to short-circuit queries that contain "+".
>
>         SELECT result
>         FROM table
>         WHERE key = '%u@%d'
>         AND key NOT LIKE '%%+%%'
>
> An SQL server may well optimize that query away when the key contains
> a "+" and not do any disk I/O.

In this case, SQL is flexible. but any solution for LDAP table? we cannot do
this in ldap query filter.

Again, thanks for your help. :)
Reply | Threaded
Open this post in threaded view
|

Re: About table search order: not to query 'user+extension@domain.ltd'

Viktor Dukhovni
On Thu, Mar 12, 2015 at 12:07:49AM +0800, Zhang Huangbin wrote:

> > An SQL server may well optimize that query away when the key contains
> > a "+" and not do any disk I/O.
>
> In this case, SQL is flexible. but any solution for LDAP table? we cannot do
> this in ldap query filter.

No.

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: About table search order: not to query 'user+extension@domain.ltd'

Zhang Huangbin
On Thu, Mar 12, 2015 at 12:10 AM, Viktor Dukhovni
<[hidden email]> wrote:

>> In this case, SQL is flexible. but any solution for LDAP table? we cannot do
>> this in ldap query filter.
>
> No.

OK, thanks.

BTW, any plan to support this (ignore '+extension' in table lookup)?