Re: [exim] Doubled headers with exiscan

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Dennis Davis
Ημερομηνία:  
Προς: Piotr Roszatycki
Υ/ο: exim-users
Αντικείμενο: Re: [exim] Doubled headers with exiscan
On Wed, 20 Apr 2005, Piotr Roszatycki wrote:

> From: Piotr Roszatycki <Piotr_Roszatycki@???>
> To: exim-users@???
> Date: Wed, 20 Apr 2005 13:31:23 +0200
> Subject: Re: [exim] Doubled headers with exiscan
>
> On Tuesday 19 of April 2005 14:32, Piotr Roszatycki wrote:
> > I'm using exiscan with spamassassin which set X-Spam-Level:
> > header. I've found the problem if this header already exists in
> > incoming message. How can I delete header in ACL. I'm afraid it
> > is impossible, but I think the system filter is called after ACL
> > is working, so after adding the doubled header.
> >
> > Of course the message could come from my other server, so I use
> > following ACL:
> >
> > # Omit if already scanned accept condition = ${if eq
> > {${hmac{md5}{EXISCAN_SA_SECRET} {SA$body_linecount}}}\
> > {$h_X-Exiscan-SA-Signature:} {1}{0}}
>
> I'm trying to implement the removing the doubled headers in system
> filter but I'm missing modificator for $header_ to getting only
> last value. The headers are concacated :(


We talked about this on this list back in January 2004. Appended
below is the method I use to do what you require.


ACLs don't have the ability to remove headers. They can only add
headers.

The way to do this is to add headers with a *unique* name and do any
necessary header munging in a system filter that's run afterwards.
You can add and remove headers in a system filter.

For example, I have an ACL of:


  # Calculate and log the spam score for suitable messages.  Also
  # insert an X-Spam-score message in all suitable messages.
  warn  message = X-SPAMSCORE: $spam_score ($spam_bar)
        log_message = exiscan-acl spam score $spam_score
        condition = SPAMCHECK
        spam = nobody:true



where SPAMSCORE is a macro set to a pre-calculated unique string in
the main section:


SPAMSCORE = a5aaa22682c1c87bb3ec90eb845d703f42be234f


The system filter that's run afterwards does the header munging by:


# Munge the X-Spam-Score header.
headers remove X-Spam-Score
if "${if def:h_X-a5aaa22682c1c87bb3ec90eb845d703f42be234f: {there}}" is there
then
headers add "X-Spam-Score: $h_X-a5aaa22682c1c87bb3ec90eb845d703f42be234f:"
headers remove X-a5aaa22682c1c87bb3ec90eb845d703f42be234f
endif


I'm obviously not using "a5aaa22682c1c87bb3ec90eb845d703f42be234f"
as the "real" unique string. I use several such unique strings for
munging the spamassassin headers I include. These strings are
generated by:


dd if=/dev/urandom bs=1024 count=1 | sha1


on my OpenBSD boxes.  Other variants of Unix should have an
equivalent facility.
-- 
Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, UK
D.H.Davis@???               Phone: +44 1225 386101