Petr,
> ...but addheader() adds the header BEFORE first occurence of the header
> with the same name. I have checked sendmail sources from version 8.9.0
> to 8.13. and this behavior has remained unchanged.
>
> There is a problem when amavisd-new adds some header and then deletes
> the same header. It occurres when amavisd-new adds new X-Amavis-* and
> X-Spam-* headers and then deletes old X-Amavis-* and X-Spam-* headers.
...
> I have sent this mail to amavis-user list too, because we need to
> change amavisd-new functionality to make the AM.PDP command addheader
> to take into account that smfi_addheader adds new header to the top.
> Another possibility is to use the smfi_insheader which was introduced
> in sendmail 8.13.
The following change will go to amavisd-new-2.4.3:
- added new attribute to AM.PDP protocol: "insheader=hdr_head hdr_body hdridx"
(where hdridx as used by amavisd will always be 0), making it possible
to prepend header fields in a sendmail milter setup (instead of appending
them, breaking compatibility with DomainKeys and DKIM); problem noted
by Adam Gibson and Petr Rehor;
- change the order of attributes returned in an AM.PDP protocol reply:
delete and edit header fields before adding new header fields;
problem of deleting just-inserted header fields in a sendmail milter
setup reported by Petr Rehor;
README.protocol:
addheader=hdr_head hdr_body
Specifies a mail header field to be appended to the mail header.
Note the use of exactly two value fields, separated by exactly one space.
As described above, spaces in each field must be hex-encoded.
'hdr_head' does not include the colon!
insheader=hdr_head hdr_body hdridx
Similar to addheader, but specifies a mail header field to be inserted to
the mail header at a given position, hdridx 0 implies top of the header.
Amavisd-new currently (2.4.3) always specifies hdridx to be 0, meaning the
added header field is to be prepended to the header. Inserting header field
at an arbitrary position is a later addition to sendmail milter protocol
(introduced with sendmail 8.13.0 2004-06-20)
Here is a preliminary patch. Petr, would you be so kind and test it,
after making appropriate adjustments to your milter program.
--- amavisd.orig Tue Jun 27 13:31:56 2006
+++ amavisd Tue Aug 8 17:26:46 2006
@@ -11218,4 +11218,5 @@
# delrcpt=recipient
# addheader=hdr_head hdr_body
+ # insheader=hdr_head hdr_body hdridx (hdridx will always be 0)
# chgheader=index hdr_head hdr_body
# delheader=index hdr_head
@@ -11259,12 +11260,5 @@
my($hdr_edits) = $msginfo->header_edits;
if ($hdr_edits) { # any added or modified header fields?
- local($1,$2);
- # Inserting. Not posible to specify placement of header fields in milter!
- for my $hf (map { ref $hdr_edits->{$_} ? @{$hdr_edits->{$_}} : () }
- qw(prepend addrcvd add append)) {
- if ($hf =~ /^([^:]+):[ \t]*(.*?)$/s)
- { push(@response, proto_encode('addheader',$1,$2)) }
- }
- my($field_name,$edit,$field_body);
+ local($1,$2); my($field_name,$edit,$field_body);
while ( ($field_name,$edit) = each %{$hdr_edits->{edit}} ) {
$field_body = $msginfo->mime_entity->head->get($field_name,0);
@@ -11285,4 +11279,18 @@
}
}
+ }
+ # prepend header fields
+ for my $hf (map { ref $hdr_edits->{$_} ? @{$hdr_edits->{$_}} : () }
+ (c('append_header_fields_to_bottom') ?
+ qw(prepend addrcvd) : qw(prepend add addrcvd)) ) {
+ if ($hf =~ /^([^:]+):[ \t]*(.*?)$/s)
+ { push(@response, proto_encode('insheader',$1,$2,'0')) }
+ }
+ # append header fields
+ for my $hf (map { ref $hdr_edits->{$_} ? @{$hdr_edits->{$_}} : () }
+ (c('append_header_fields_to_bottom') ?
+ qw(add append) : qw(append)) ) {
+ if ($hf =~ /^([^:]+):[ \t]*(.*?)$/s)
+ { push(@response, proto_encode('addheader',$1,$2)) }
}
}
Mark
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
AMaViS-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/