Subject: pkg/26806: spamass-milter bugfix
To: None <gnats-bugs@gnats.netbsd.org>
From: None <toku@tokugawa.org>
List: pkgsrc-bugs
Date: 08/30/2004 13:48:36
>Number: 26806
>Category: pkg
>Synopsis: spamass-milter dies with a NULL body spam mail
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Aug 30 05:06:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Yoshitaka Tokugawa
>Release: NetBSD 1.6.2_STABLE
>Organization:
WIDE Project
>Environment:
System: NetBSD tish.tokugawa.org 1.6.2_STABLE NetBSD 1.6.2_STABLE (NETBSD) #34: Thu Jul 29 18:50:43 JST 2004 toku@tish.tokugawa.org:/var/src/src/sys/arch/i386/compile/NETBSD i386
Architecture: i386
Machine: i386
>Description:
1. The spamass-milter dies with a NULL body spam mail due to
incorrect BOB(Beginning Of Body) handling in 'assassinate()'.
2. The spamass-milter does not detach from the controlling terminal.
So, it starts but quits soon by SIGHUP unexpectedly if I started
it from the /etc/rc script. Adding 'setsid()' solves this problem.
3. The spamass-milter creates a faked "Received:" Header
to SA(SpamAssassin) makes happy. But due to incomplete work,
it does not recognized by SA as a Received Header.
>How-To-Repeat:
Described above.
>Fix:
I did my work based on spamass-milter-0.2.0 though the
pkgsrc version is based on 0.1.3a. Here is my fix and
complete tarball-kit for the pkgsrc/mail/spamass-milter.
--- spamass-milter.cpp.orig Fri Jun 27 00:10:44 2003
+++ spamass-milter.cpp Mon Aug 30 12:05:36 2004
@@ -273,6 +273,7 @@
exit(errno);
break;
case 0: /* Child */
+ (void) setsid();
break;
default: /* Parent */
exit(0);
@@ -351,6 +352,10 @@
string::size_type eoh = ( eoh1 < eoh2 ? eoh1 : eoh2 );
string::size_type bob = assassin->d().find_first_not_of("\r\n", eoh);
+ // In case of NULL body message
+ if (bob == string::npos)
+ bob = assassin->d().size();
+
update_or_insert(assassin, ctx, assassin->spam_flag(), &SpamAssassin::set_spam_flag, "X-Spam-Flag");
update_or_insert(assassin, ctx, assassin->spam_status(), &SpamAssassin::set_spam_status, "X-Spam-Status");
@@ -686,14 +691,19 @@
(envelope-from $g)$.
*/
- const char *macro_b, *macro_s;
+ const char *macro_b, *macro_s, *macro_r;
+ char date[32]; /* sizeof("Mon, 23 Aug 2004 18:28:43 +0900") */
+ time_t tval;
- /* If the user did not enable the {b} macro in sendmail.cf
- just make it blank. Without this date SA can't do
- future/past validation on the Date: header */
+ /* Without this date SA can't do future/past validation
+ on the Date: header */
macro_b = smfi_getsymval(ctx, "b");
if (!macro_b)
- macro_b = "";
+ {
+ (void) time(&tval);
+ (void) strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", localtime(&tval));
+ macro_b = date;
+ }
/* Sendmail currently cannot pass us the {s} macro, but
I do not know why. Leave this in for the day sendmail is
@@ -705,10 +715,18 @@
macro_s = sctx->helo;
if (!macro_s)
macro_s = "nohelo";
+ /* Get mailer info. */
+ macro_r = smfi_getsymval(ctx, "r");
+ if (!macro_r)
+ macro_r = "SMTP"; /* Assuming it as SMTP */
assassin->output((string)"X-Envelope-From: "+assassin->from()+"\r\n");
assassin->output((string)"X-Envelope-To: "+assassin->rcpt()+"\r\n");
- assassin->output((string)"Received: from "+macro_s+" ("+smfi_getsymval(ctx,"_")+") by "+smfi_getsymval(ctx,"j")+"; "+macro_b+"\r\n");
+ assassin->output((string)"Received: from "+macro_s
+ +" ("+smfi_getsymval(ctx,"_")+")\n\tby "
+ +smfi_getsymval(ctx,"j")
+ +" ("+PACKAGE_NAME+"/"+PACKAGE_VERSION
+ +") with "+macro_r+";\n\t"+macro_b+"\r\n");
} else
{
begin 644 spamass-milter.tar.gz
M'XL(`#JH,D$``^T\^UO;QK+Y%?T54R7IL0O6VW)PP`<'3/`M!JYMVM.O[>=/
MEM:V@BSIZ@$EO?G?[\Q*?F(@30C]SKF:I@CM8W9V7CNSVB4.K:D5QY6IZR4L
MDE]\"P!#J56K\`((E+5G_J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