On 17-Mar-2009, at 08:52, Victor Duchovni wrote:
On Tue, Mar 17, 2009 at 10:01:53AM -0400, Charles Marcus wrote:
On 3/17/2009 9:43 AM, Erwan David wrote:
You may generate the pcre file with a line
/recipient_([...@_]+)@localdomain/    recipient+$...@localdomain

for each valid recipient. This would preserve the validation of
recipient at RCPT TO stage.

Interesting... and maybe a good candidate for my first usable scripting
attempt.

Perl is the natural choice for this:

   $ echo u...@example.com |
        domain=example.com perl -lpe '
            s{^(.*)\...@\q$env{domain}\e$}
                {/^\Q$1\E_(.*)\...@\q$env{domain}\e\$/ 
$1+\${...@$env{domain}}o;'
   /^user_(.*)@example\.com$/ user+$...@example.com

In practice instead of "echo ... |" Perl would read a list of addresses from a file. The "\Q...\E" construct is the critical ingredient for quoting PCRE
special characters in the address localpart and domain.

I came up with this one liner:

$ ls -1 /usr/local/virtual/ | grep "@" | sed 's/^\([...@]*\)@\(.*\)$/\/ ^\1_\(.*\)@\2$\/ \1+$...@\2/'

testu...@example.com => /^testuser_(.*)@example.com$/ testuser+$...@example.com

But the sed works for dumping all the virtual users into a .pcre map for postfix.

--
My mind is going. There is no question about it. I can feel it. I can
        feel it. I can feel it. I'm... afraid.

Reply via email to