Bug 90 - spamd logging of message score
Summary: spamd logging of message score
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamc/spamd (show other bugs)
Version: 2.11
Hardware: PC FreeBSD
: P5 minor
Target Milestone: ---
Assignee: Craig Hughes
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-08 14:13 UTC by j knight
Modified: 2002-03-16 18:38 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description j knight 2002-03-08 14:13:16 UTC
spamd logs message scores and the score theshold as an integer. This makes it look like a message with a logged score of 5 (out of 5) should have been blocked when really the message only had a score of say 4.5.  This patch against v2.11 makes spamd log a score and threshold with a 1 decimal point precision:

--- spamd/spamd.raw.bak Sat Mar  2 10:35:46 2002
+++ spamd/spamd.raw Sat Mar  2 10:37:45 2002
@@ -309,8 +309,8 @@

        # Now use copy-on-writed (hopefully) SA object
        my $status = $spamtest->check($mail);
-       my $msg_score = int($status->get_hits);
-       my $msg_threshold = int($status->get_required_hits);
+       my $msg_score = sprintf("%.1f", $status->get_hits);
+       my $msg_threshold = sprintf("%.1f", $status->get_required_hits);
        my $was_it_spam;
        if ($status->is_spam)
        {
@@ -434,8 +434,8 @@
        }
        my $was_it_spam;
        if($status->is_spam) { $was_it_spam = 'identified spam'; } else { $was_it_spam = 'clean messag
e'; }
-            my $msg_score = int($status->get_hits);
-            my $msg_threshold = int($status->get_required_hits);
+            my $msg_score = sprintf("%.1f", $status->get_hits);
+            my $msg_threshold = sprintf("%.1f", $status->get_required_hits);
        $current_user ||= '(unknown)';
        logmsg "$was_it_spam ($msg_score/$msg_threshold) for $current_user:$> in ".
        sprintf("%3d", time - $start) ." seconds.\n";
--- spamd/spamc.c.bak   Fri Mar  8 14:35:41 2002
+++ spamd/spamc.c       Fri Mar  8 15:04:19 2002
@@ -208,7 +208,7 @@
   int header_read=0;
   char buf[8192];
   char is_spam[5];
-  int score,threshold;
+  float score,threshold;
   float version;
   int response=EX_OK;
   char* out_buf;
@@ -268,12 +268,12 @@
          if(CHECK_ONLY)
          {
            /* Ok, found a header line, it better be "Spam: x; y / x" */
-           if(3 != sscanf(buf,"Spam: %5s ; %d / %d",is_spam,&score,&threshold))
+           if(3 != sscanf(buf,"Spam: %5s ; %f / %f",is_spam,&score,&threshold))
            {
              response = EX_PROTOCOL; break;
            }
 
-           printf("%d/%d\n",score,threshold);
+           printf("%.1f/%.1f\n",score,threshold);
 
            if(!strcasecmp("true",is_spam)) /* If message is indeed spam */
            {