OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Rewrite with Pattern

From: Fat Bear Mail Services (postfixfatbear.com)
Date: Tue Dec 02 2008 - 17:19:45 CST


Noel Jones wrote:
> Fat Bear Mail Services wrote:
>> How would one setup Postfix that uses /etc/passwd for authentication
>> so that e-mails of the pattern:
>>
>> username-companyID-anyStringdomain1.com
>>
>> is delivered to:
>>
>> usernamecompanyDomain.com
>>
>> where there is a 1:1 mapping between companyID and companyDomain?
>> For example:
>>
>> pat-acme-beta123mycompany.com >>> patacmedesign.com
>>
>> Note above that "acme" maps to "acmedesign.com".
>
> One would use an awk or perl script to generate a virtual_alias_map
> from the input file.
The virtual_alias_map could not be hash:/etc/postfix/virtual because
that could not handle e-mail addresses where "anyString" is discarded,
right? I would think that we'd need to have regexp:/etc/postfix/virtual
that can handle transformations such as:

    pat-acme-123456mycompany.com delivered to patacmedesign.com
    pat-acme-tmp123mycompany.com delivered to patacmedesign.com
    pat-acme-reallyAnythingHeremycompany.com delivered to
patacmedesign.com

What I'm looking for is a production-quality example of what I should be
doing. I've read regexp_table(5) and I've tried doing:

    postmap -q "pat-acme-xxxxxxmycompany.com"
regexp:/etc/postfix/virtual.regexp

for a virtual.regexp file including a line such as:

    /^pat-acme(-[^]+)mycompany.com/ patacmedesign.com

and this does work for queries such as:

    #postmap -q "pat-acme-xyzzymycompany.com"
regexp:/etc/postfix/virtual-regexp
    patacmedesign.com
    #

But, is this production quality? Can anyone poke any holes for entries
such as the one above as the pattern that I should be using in the
virtual-regexp file? Is this the right solution for doing this kind of
thing?

Thanks!
Steve Amerige
Fat Bear