Hi all,

I recently made a new server install starting from scratch: fresh OS install (RedHat 7.3), and after installing SpamAssassin 3.0.1, I have the following issues with spamd:

1.- Since I like to run spamd under daemontools, I would like it for spamd not to print out the timestamp each time it writes to the log (this just makes for duplicate timestamps with multilog). I suggest a command-line option (i.e. --syslog-nodate) to instruct spamd not to add the timestamp when writting to the logfile.

2.- In the subroutine check(); there are a few things:

2.1.- The variable $yorn (Yes or No) is set depending on the $status->is_spam(), but in the case where its not, a dot ('.') is assinged, shouldn't this be a 'N'?

2.2.- Towards the end, when the information is being logged about the message scan, there is a duplicate call to $status->get_score which could be removed and save a few cpu cycles...

2.3.- As a matter or preference, the variable $msg_score is assigned the message score with a one decimal precision, I like two decimals :-)

2.4.- Ditto for $scantime, since Time::HiRes is available with most perl implementations (and easily available via CPAN) there is a lot of precision lost with just one decimal for seconds :-)

3.- In the subroutine handle_user(); when enabling vpopmail, there are a couple of issues when vpopmail is enabled:

3.1.- Basically, `~vpopmail/bin/vuserinfo -d` is used to get the user's home directory, and no provision is made to check the result for an error message, this just generates all sorts of errors in the logs. If an error is detected, just return from handle_user with 0 and all the errors disappear...

3.2.- Also, the directory is not created because the $dir variable does not contain the correct directory to create, and neither the directory or the user_prefs file are created. This is a simple fix.

If anyone is interested, attached is a patch file for these changes...

--
Jorge Valdes
Intercom El Salvador
[EMAIL PROTECTED]
fax: ++(503) 265-7025

diff -ruN spamd-original spamd
--- spamd-original      Tue Nov  9 12:18:14 2004
+++ spamd       Tue Nov  9 16:07:52 2004
@@ -177,6 +177,7 @@
   'socketpath=s'             => \$opt{'socketpath'},
   'sql-config!'              => \$opt{'sql-config'},
   'ssl'                      => \$opt{'ssl'},
+  'syslog-nodate'            => \$opt{'syslog-nodate'},
   'syslog-socket=s'          => \$opt{'syslog-socket'},
   'syslog|s=s'               => \$opt{'syslog'},
   'user-config'              => \$opt{'user-config'},
@@ -1119,7 +1120,7 @@
   # Go ahead and check the message
   my $status = $spamtest->check($mail);
 
-  my $msg_score     = sprintf( "%.1f", $status->get_score );
+  my $msg_score     = sprintf( "%.2f", $status->get_score );
   my $msg_threshold = sprintf( "%.1f", $status->get_required_score );
 
   my $response_spam_status = "";
@@ -1198,7 +1199,7 @@
     }
   }
 
-  my $scantime = sprintf( "%.1f", time - $start_time );
+  my $scantime = sprintf( "%.2f", time - $start_time );
 
   logmsg( "$was_it_spam ($msg_score/$msg_threshold) for $current_user:$> in"
       . " $scantime seconds, $actual_length bytes." );
@@ -1217,11 +1218,10 @@
   }
   push(@extra, "autolearn=".$status->get_autolearn_status());
 
-  my $yorn = $status->is_spam() ? 'Y' : '.';
-  my $score = $status->get_score();
+  my $yorn = $status->is_spam() ? 'Y' : 'N';
   my $tests = join(",", sort(grep(length,$status->get_names_of_tests_hit())));
 
-  logmsg( sprintf("result: %s %2d - %s %s", $yorn, $score,
+  logmsg( sprintf("result: %s %2d - %s %s", $yorn, $msg_score,
                         $tests, join(",", @extra) ));
 
   $status->finish();    # added by jm to allow GC'ing
@@ -1409,8 +1409,10 @@
   if ( $opt{'vpopmail'} ) {
     $dir = `$dir/bin/vuserinfo -d $username`;
     chomp($dir);
+    return 0 if ($dir =~ m/^(no such user|Error: )/);
   }
-  my $cf_file = $dir . "/.spamassassin/user_prefs";
+  $dir .= "/.spamassassin";
+  my $cf_file = join('/',$dir,"user_prefs");
 
   #
   # If vpopmail config enabled then pass virtual homedir onto 
create_default_cf_needed
@@ -1666,13 +1668,24 @@
   my @date = reverse( ( gmtime(time) )[ 0 .. 5 ] );
   $date[0] += 1900;
   $date[1] += 1;
-  syswrite(
-    STDLOG,
-    sprintf(
-      "%04d-%02d-%02d %02d:%02d:%02d [%s] %s: %s\n",
-      @date, $$, 'i', $msg
-    )
-  );
+  if ($opt{'syslog-nodate'}) {
+    syswrite(
+      STDLOG,
+      sprintf(
+        "[%s] %s: %s\n", 
+        $$, 'i', $msg
+      )
+    );
+  }
+  else {
+    syswrite(
+      STDLOG,
+      sprintf(
+        "%04d-%02d-%02d %02d:%02d:%02d [%s] %s: %s\n",
+        @date, $$, 'i', $msg
+      )
+    );
+  }
 }
 
 sub logmsg_syslog {

Reply via email to