address rewriting with pcre?

2009-03-17 Thread Robert Brooks
Hi, I've looked at Postfix Address Rewriting doc, but am struggling to see the best way to do this. We have virtual mail recipients via mysql. Some of these use + addressing, however not everywhere will accept an email address with a + in. So, what I'd like to do if it's possible, is rewrite

Re: address rewriting with pcre?

2009-03-17 Thread LuKreme
On 17-Mar-2009, at 04:24, Robert Brooks wrote: So, what I'd like to do if it's possible, is rewrite f...@bar.example.com to bar+...@example.com. I rewrite foo_...@example.com to foo+...@example.com virtaul.pcre: /^(.*)_(.*)@example.com$/${1}+$...@example.com virtual_alias_maps = hash

Re: address rewriting with pcre?

2009-03-17 Thread Robert Brooks
LuKreme wrote: I rewrite foo_...@example.com to foo+...@example.com virtaul.pcre: /^(.*)_(.*)@example.com$/${1}+$...@example.com virtual_alias_maps = hash:$config_directory/virtual pcre:$config_directory/virtual.pcre, mysql:$config_directory/mysql_virtual_alias_maps.cf your lin

Re: address rewriting with pcre?

2009-03-17 Thread Charles Marcus
On 3/17/2009 6:47 AM, LuKreme wrote: > I rewrite foo_...@example.com to foo+...@example.com > > virtaul.pcre: > /^(.*)_(.*)@example.com$/${1}+$...@example.com > > virtual_alias_maps = > hash:$config_directory/virtual > pcre:$config_directory/virtual.pcre, > mysql:$config_directory

Re: address rewriting with pcre?

2009-03-17 Thread Erwan David
On Tue, Mar 17, 2009 at 12:01:13PM CET, Charles Marcus said: > On 3/17/2009 6:47 AM, LuKreme wrote: > > I rewrite foo_...@example.com to foo+...@example.com > > > > virtaul.pcre: > > /^(.*)_(.*)@example.com$/${1}+$...@example.com > > > > virtual_alias_maps = > > hash:$config_directory/v

Re: address rewriting with pcre?

2009-03-17 Thread LuKreme
On 17-Mar-2009, at 05:01, Charles Marcus wrote: (not sure if using the 'or' vertical bar will work as expected here) It's a PCRE. As long as the PCRE is valid it should work. -- RTFM replies are great, but please specify exactly which FM to R

Re: address rewriting with pcre?

2009-03-17 Thread LuKreme
On 17-Mar-2009, at 06:09, Erwan David wrote: I would fear it breaks recipient validation, accepting mail for eavery address with a _ as valid. That is a drawback. The other choice is to change the delimiter in postfix to _ and rewrite it to accept all '+' addresses to '_'. The trouble is

Re: address rewriting with pcre?

2009-03-17 Thread Charles Marcus
On 3/17/2009, LuKreme (krem...@kreme.com) wrote: > On 17-Mar-2009, at 06:09, Erwan David wrote: > > I would fear it breaks recipient validation, accepting mail for eavery > > address with a _ as valid. > That is a drawback. Oh... well, if it does indeed do what Erwan said, it isn't just a drawbac

Re: address rewriting with pcre?

2009-03-17 Thread LuKreme
On 17-Mar-2009, at 07:30, Charles Marcus wrote: So, is there no way to rewrite the recipient and *then* validate it? Sure, but not until after you've accepted the message. It's not like ziggy_test gets delivered to some random user. It's just that it generates a bounce instead of a reject.

Re: address rewriting with pcre?

2009-03-17 Thread Charles Marcus
On 3/17/2009, LuKreme (krem...@kreme.com) wrote: > On 17-Mar-2009, at 07:30, Charles Marcus wrote: >> So, is there no way to rewrite the recipient and *then* validate it? > Sure, but not until after you've accepted the message. Ummm... WRONG. Recipient VALIDATION, by DEFINITION, must occur BEFORE

Re: address rewriting with pcre?

2009-03-17 Thread LuKreme
On 17-Mar-2009, at 07:39, Charles Marcus wrote: On 3/17/2009, LuKreme (krem...@kreme.com) wrote: It's not like ziggy_test gets delivered to some random user. It's just that it generates a bounce instead of a reject. Like I said, this is unacceptable (makes you a backscatter source). Then yo

Re: address rewriting with pcre?

2009-03-17 Thread Erwan David
On Tue, Mar 17, 2009 at 02:39:08PM CET, Charles Marcus said: > On 3/17/2009, LuKreme (krem...@kreme.com) wrote: > > On 17-Mar-2009, at 07:30, Charles Marcus wrote: > >> So, is there no way to rewrite the recipient and *then* validate it? > > > Sure, but not until after you've accepted the messag

Re: address rewriting with pcre?

2009-03-17 Thread Charles Marcus
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

Re: address rewriting with pcre?

2009-03-17 Thread LuKreme
On 17-Mar-2009, at 08:01, 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. Inte

Re: address rewriting with pcre?

2009-03-17 Thread Victor Duchovni
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 >

Re: address rewriting with pcre?

2009-03-17 Thread Erwan David
On Tue, Mar 17, 2009 at 03:52:27PM CET, Victor Duchovni said: > 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 >

Re: address rewriting with pcre?

2009-03-19 Thread LuKreme
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 w

Re: address rewriting with pcre?

2009-03-19 Thread LuKreme
On 19-Mar-2009, at 04:14, Charles Marcus wrote: On 3/19/2009 5:55 AM, LuKreme wrote: 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.c

Re: address rewriting with pcre?

2009-03-19 Thread Wietse Venema
LuKreme: > 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 > >>>

Re: address rewriting with pcre?

2009-03-19 Thread Charles Marcus
On 3/19/2009 5:55 AM, LuKreme 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

Re: address rewriting with pcre?

2009-03-19 Thread LuKreme
On 19-Mar-2009, at 04:45, Wietse Venema wrote: $ ls -1 /usr/local/virtual/ | grep "@" | sed 's/^\([...@]*\)@\(.*\)$/ \/ ^\1_\(.*\)@\2$\/ \1+$...@\2/' testu...@example.com => /^testuser_(.*)@example.com$/ testuser+$...@example.com This is BROKEN. You are not escaping any of the regexp metacha

Re: address rewriting with pcre?

2009-03-19 Thread Wietse Venema
LuKreme: > On 19-Mar-2009, at 04:45, Wietse Venema wrote: > >> $ ls -1 /usr/local/virtual/ | grep "@" | sed 's/^\([...@]*\)@\(.*\)$/ > >> \/ > >> ^\1_\(.*\)@\2$\/ \1+$...@\2/' > >> > >> testu...@example.com => /^testuser_(.*)@example.com$/ > >> testuser+$...@example.com > > > > This is BROKEN. Y

Re: address rewriting with pcre?

2009-03-21 Thread mouss
Charles Marcus a écrit : > On 3/17/2009, LuKreme (krem...@kreme.com) wrote: >> On 17-Mar-2009, at 06:09, Erwan David wrote: >>> I would fear it breaks recipient validation, accepting mail for eavery >>> address with a _ as valid. > >> That is a drawback. > > Oh... well, if it does indeed do what

Re: address rewriting with pcre?

2009-03-21 Thread Victor Duchovni
On Sat, Mar 21, 2009 at 03:19:44PM +0100, mouss wrote: > Charles Marcus a ?crit : > > On 3/17/2009, LuKreme (krem...@kreme.com) wrote: > >> On 17-Mar-2009, at 06:09, Erwan David wrote: > >>> I would fear it breaks recipient validation, accepting mail for eavery > >>> address with a _ as valid. > >

Re: address rewriting with pcre?

2009-03-21 Thread mouss
Victor Duchovni a écrit : > On Sat, Mar 21, 2009 at 03:19:44PM +0100, mouss wrote: > >> Charles Marcus a ?crit : >>> On 3/17/2009, LuKreme (krem...@kreme.com) wrote: On 17-Mar-2009, at 06:09, Erwan David wrote: > I would fear it breaks recipient validation, accepting mail for eavery >

Re: address rewriting with pcre?

2009-03-21 Thread Victor Duchovni
On Sat, Mar 21, 2009 at 07:31:24PM +0100, mouss wrote: > >> alternatively, you can add an smtpd in the chain using proxy_filter: > >> > >> - smtpd on port 25 does the rewrite. it then uses proxy_filter to pass > >> mail to an smtpd on port 10020. > > > > Rewriting is done by cleanup(8). This can'

Re: address rewriting with pcre?

2009-03-21 Thread mouss
Victor Duchovni a écrit : > On Sat, Mar 21, 2009 at 07:31:24PM +0100, mouss wrote: > alternatively, you can add an smtpd in the chain using proxy_filter: - smtpd on port 25 does the rewrite. it then uses proxy_filter to pass mail to an smtpd on port 10020. >>> Rewriting is done