Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Milter - deleting headers with smfi_chgheader()

81 views
Skip to first unread message

JonB

unread,
Dec 21, 2009, 8:28:20 AM12/21/09
to
Hi,

I have a milter - which I need to delete some headers in incoming
emails... I see I can use smfi_chgheader() in the milter eom (End of
Message) callback to do this.

However, that only removes a single instance of a header, e.g. if the
incoming email has headers such as:

"
X-SomeHeader: Hello
X-SomeHeader: Goodbye
X-SomeHeader: YetAgain
X-SomeHeader: LastOne
"

Calling:

smfi_chgheader( ctx, "X-SomeHeader", 1, NULL )

Only removes the first header.

A workaround I've come up with is to 'count' the headers in as they
arrive in the milter header callback, so for the example above - we'd
have a count of 4, we'd then call smfi_chgheader() with a hdrirdx of
1, then again with a hdridx of 2, then 3 - then 4.

Repeatedly calling it with a hdridx of 1 doesn't remove additional
headers.

Can someone confirm the above is correct? - i.e. There is no 'delete
all headers with a headerf value of ..' type functionality, and that
instead calling smfi_chgheader() multiple times (once with each
occurence number of the header we want to delete) is acceptable?

Thanks,

-Jon

David F. Skoll

unread,
Dec 21, 2009, 2:18:49 PM12/21/09
to
JonB wrote:

> Can someone confirm the above is correct? - i.e. There is no 'delete
> all headers with a headerf value of ..' type functionality, and that
> instead calling smfi_chgheader() multiple times (once with each
> occurence number of the header we want to delete) is acceptable?

We do it that way in MIMEDefang. It was the only way I could find
to do it.

Regards,

David.

JonB

unread,
Dec 23, 2009, 5:35:58 AM12/23/09
to

Oh well - one by one removal it is then... As they can only be removed
at EOM - it's a bit of a pain as you have to 'count them in' then
remove them...

Having remove return either 'yes deleted it' or not would have been
good - you could just keep calling it until it either returns "none
deleted" or an error.

Thanks for the reply,

-Jon

John Nemeth

unread,
Dec 23, 2009, 7:24:47 AM12/23/09
to
JonB (jfr...@googlemail.com) wrote:

: On Dec 21, 7:18=A0pm, "David F. Skoll" <d...@roaringpenguin.com> wrote:
: > JonB wrote:
: > > Can someone confirm the above is correct? - i.e. There is no 'delete
: > > all headers with a headerf value of ..' type functionality, and that
: > > instead calling smfi_chgheader() multiple times (once with each
: > > occurence number of the header we want to delete) is acceptable?
: >
: > We do it that way in MIMEDefang. It was the only way I could find
: > to do it.

: Oh well - one by one removal it is then... As they can only be removed


: at EOM - it's a bit of a pain as you have to 'count them in' then
: remove them...

: Having remove return either 'yes deleted it' or not would have been
: good - you could just keep calling it until it either returns "none
: deleted" or an error.

Based on reading
sendmail-8.14.3/sendmail/milter.c:milter_changeheader() that is the
only way to do it. You would have to modify this function to loop when
idx = 0 (or something). Perhaps put in a change request or send a
patch.

grand...@gmail.com

unread,
Jan 9, 2014, 10:24:50 PM1/9/14
to
Hi,

I have same problem.

If I write a patch, where should I send it?

Claus Aßmann

unread,
Jan 10, 2014, 3:21:48 PM1/10/14
to
> If I write a patch, where should I send it?

The sendmail.org web site lists the e-mail addresses.

sendmail-YYYY at support.sendmail.org
(replace YYYY with the current year).
0 new messages