SA Bugzilla – Bug 90
spamd logging of message score
Last modified: 2002-03-16 18:38:55 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 */ {