Re: [exim] Postfix regex map to Exim ACL

Top Pagina
Delete this message
Reply to this message
Auteur: David Woodhouse
Datum:  
Aan: Stefano Sasso
CC: exim-users
Onderwerp: Re: [exim] Postfix regex map to Exim ACL
On Mon, 2010-06-07 at 11:33 +0200, Stefano Sasso wrote:
> Hi *,
>     is there a quick way to convert a postfix regex/pcre map for use with
> an exim acl?

>
> I have some regex files like this:
> (header_checks)
> /^X-Mailer: .*EVAMAIL/                REJECT Sorry, your mailer was identified as
> mass mailer program.
> ...
> /^X-Mailer: .*Avalanche/                REJECT Sorry, your mailer was identified
> as mass mailer program.
> ...
> /^Date: .* 19[0-9][0-9]/                REJECT Past Date
> /^From: <>/                        REJECT You need to specify a return address,
> otherwise we will not accept your email.

>
> (host_blacklist)
> /[Dd]ynamic/                        REJECT
> /[Dd][Hh][Cc][Pp]/                    REJECT
> /\.dsl\.brasiltelecom\.net\.br$/            REJECT
> ...

>
>
> The only idea I had is to use the embedded perl interpreter (condition
> = perl{xxxxx}{yyyy}) and a subroutine that loads the "map file" and
> checks the parameter with =~/<file_loaded_expression>/.


Do you really have to load the file more than once, or would it be
sufficient just to convert it to Exim ACL as a one-off and then maintain
it in that form?

Even if it really does have to be maintained in the original form, it
shouldn't be particularly hard to do an automated transform into Exim
ACL language...

s%^/^\(.*\): \(.*\)/[[:space:]]*REJECT \(.*\)\$%reject condition = ${if
match {{$h_\1} {\2}} {1}}\n message = \3%

s%^/\(.*\)/[[:space:]]*REJECT \(.*\)\$%reject condition = ${if match
{{$message_headers}{\1}} {1}}\n message = \2%

I typed that into my mailer without testing it at all, but you get the
idea.

Mildly confused by the 'From: <>' one -- do you really see messages with
an empty From: header? You _will_ see messages with an empty SMTP
reverse-path, of course, and it would be stupidly broken to reject
those.

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@???                              Intel Corporation