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+$...@localdomainfor each valid recipient. This would preserve the validation of recipient at RCPT TO stage.Interesting... and maybe a good candidate for my first usable scriptingattempt.Perl is the natural choice for this: $ echo [email protected] | domain=example.com perl -lpe ' s{^(.*)\...@\q$env{domain}\e$} {/^\Q$1\E_(.*)\...@\q$env{domain}\e\$/ $1+\${...@$env{domain}}o;' /^user_(.*)@example\.com$/ [email protected]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 PCREspecial 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/'
[email protected] => /^testuser_(.*)@example.com$/ [email protected]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.
