|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: LuKreme (kremels
kreme.com)
Date: Thu Mar 19 2009 - 04:55:36 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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+${1}
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 user
example.com |
> domain=example.com perl -lpe '
> s{^(.*)\
\Q$ENV{domain}\E$}
> {/^\Q$1\E_(.*)\
\Q$ENV{domain}\E\$/ $1+\${1}\
$ENV{domain}}o;'
> /^user_(.*)
example\.com$/ user+${1}
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+${1}
\2/'
testuser
example.com => /^testuser_(.*)
example.com$/ testuser+${1}
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.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]