OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: Milter body callback (mostly) not being called

From: Alan J. Wylie (cbfgsvk-hfrefwylie.me.uk)
Date: Wed Dec 20 2006 - 05:06:16 CST


On Tue, 19 Dec 2006 12:38:52 -0500, Jim Horner <jhornerarinbe.com> said:

> I am using PMilter 0.95 on Debian. I posted this over at the PMilter
> site but got no answers. I am testing with protocol_dump.pl [1] and
> I am using Postfix v2.3.5. The problem I am having is the body
> callback is almost never being called. I am hoping someone can
> provide me with some debugging tips/techniques.

By co-incidence, I have just independently come across and fixed this
bug. It's in the Postfix Milter code. There are two milter callbacks -
"body" and "end of body". Body data is passed in both of them, but
PMilter doesn't pass the body data to the callback code for "end of
body".

The following patch fixes it.

It's a bit of a co-incidence that we both ran across this two year old
bug within a few days.

diff -Naur Sendmail-PMilter-0.95.orig/lib/Sendmail/PMilter/Context.pm Sendmail-PMilter-0.95/lib/Sendmail/PMilter/Context.pm
--- Sendmail-PMilter-0.95.orig/lib/Sendmail/PMilter/Context.pm 2004-08-04 18:07:51.000000000 +0100
+++ Sendmail-PMilter-0.95/lib/Sendmail/PMilter/Context.pm 2006-12-06 14:35:43.000000000 +0000
-245,7 +247,7
                                        $this->{symbols}{$code}{$name} = $value;
                                }
                        } elsif ($cmd eq SMFIC_BODYEOB) {
- $this->call_hooks('eom');
+ $this->call_hooks('eom', $buf, length($buf));
                        } elsif ($cmd eq SMFIC_HELO) {
                                my $helo = &$split_buf;
                                die "SMFIC_HELO: bad packet\n" unless ($helo == 1);

--
Alan J. Wylie http://www.wylie.me.uk/
"Perfection [in design] is achieved not when there is nothing left to add,
but rather when there is nothing left to take away."
  -- Antoine de Saint-Exupery