Subject: Re: pkg/26806
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Yoshitaka Tokugawa <toku@tokugawa.org>
List: pkgsrc-bugs
Date: 03/20/2005 12:25:01
The following reply was made to PR pkg/26806; it has been noted by GNATS.

From: Yoshitaka Tokugawa <toku@tokugawa.org>
To: wiz@netbsd.org
Cc: pkg-manager@netbsd.org, pkgsrc-bugs@netbsd.org,
	gnats-admin@netbsd.org
Subject: Re: pkg/26806
Date: Sun, 20 Mar 2005 12:12:10 +0900 (JST)

 wiz> Synopsis: spamass-milter dies with a NULL body spam mail
 wiz> 
 wiz> State-Changed-From-To: open->feedback
 wiz> State-Changed-By: wiz@netbsd.org
 wiz> State-Changed-When: Sat, 19 Mar 2005 14:35:36 +0000
 wiz> State-Changed-Why:
 wiz> I just updated the package to 0.3.0.
 wiz> 1. is fixed by it; there's a -f that should fix 2.
 wiz> I'm not sure if 3. is fixed. Could you please check?
 wiz> Thanks.
 
 Thank you for your mail.
 
 As you mentioned, two problems are fixed by 0.3.0.
 But I think we still need some hack.
 My changes are:
 
    Always use macro_b, so SA can do future/past validation.
    It is not a bug, but it makes SA happier.
 
    SA 2.x requires "($v/$Z)$?r with $r" part of Received: header.
    I don't think SA 3.x need this, but keep it for SA 2.x users.
 
    There is a bug in cmp_nocase_partial() function. Without my hack,
    cmp_nocase_partial("X-Spam-", "X-Spam") returns 0 which is
    incorrect behavior for this function.
 
 Hope this helps you.
 
 Yoshitaka Tokugawa
 
 --- spamass-milter.cpp.orig	Sun Mar 20 10:10:25 2005
 +++ spamass-milter.cpp	Sun Mar 20 10:32:22 2005
 @@ -898,13 +898,21 @@
  				(envelope-from $g)$.
  		   
  		*/
 -		const char *macro_b, *macro_s, *macro_j, *macro__;
 +		const char *macro_b, *macro_s, *macro_j, *macro__, *macro_r;
 +		char date[32];	/* sizeof("Mon, 23 Aug 2004 18:28:43 +0900") */
 +		time_t tval;
  
  		/* Failure to fetch {b} is not fatal.  Without this date SA can't do
  		   future/past validation on the Date: header, but sendmail doesn't
  		   default to allow milters to see it.
  		*/
  		macro_b = smfi_getsymval(ctx, "b");
 + 		if (!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
 @@ -916,6 +924,10 @@
  			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 */
  
  		/* FQDN of this site */
  		macro_j = smfi_getsymval(ctx, "j");
 @@ -930,10 +942,10 @@
  		assassin->output((string)"X-Envelope-From: "+assassin->from()+"\r\n");
  		assassin->output((string)"X-Envelope-To: "+envrcpt[0]+"\r\n");
  
 -		if (!macro_b)
 -			assassin->output((string)"Received: from "+macro_s+" ("+macro__+") by "+macro_j+";\r\n");
 -		else
 -			assassin->output((string)"Received: from "+macro_s+" ("+macro__+") by "+macro_j+"; "+macro_b+"\r\n");
 +		assassin->output((string)"Received: from "+macro_s
 +			+" ("+macro__+")\n\tby "+macro_j
 +			+" ("+PACKAGE_NAME+"/"+PACKAGE_VERSION	/* dummy */
 +			+") with "+macro_r+";\n\t"+macro_b+"\r\n");
  
  	} else
  		assassin->output((string)"X-Envelope-To: "+envrcpt[0]+"\r\n");
 @@ -1965,7 +1977,7 @@
    string::const_iterator p=s.begin();
    string::const_iterator p2=s2.begin();
  
 -  while ( p != s.end() && p2 != s2.end() ) {
 +  while ( p != s.end() ) {
      if (toupper(*p) != toupper(*p2))
      {
        debug(D_STR, "c_nc_p: <%s><%s> : miss", s.c_str(), s2.c_str());