You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by qu...@apache.org on 2004/10/02 23:54:54 UTC
svn commit: rev 51813 - in spamassassin/trunk: . lib/Mail lib/Mail/SpamAssassin lib/Mail/SpamAssassin/BayesStore lib/Mail/SpamAssassin/Conf lib/Mail/SpamAssassin/Locker lib/Mail/SpamAssassin/Message lib/Mail/SpamAssassin/Message/Metadata lib/Mail/SpamAssassin/Plugin masses spamd
Author: quinlan
Date: Sat Oct 2 14:54:53 2004
New Revision: 51813
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin.pm
spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
spamassassin/trunk/lib/Mail/SpamAssassin/AutoWhitelist.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm
spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm
spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm
spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/SQL.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Conf/LDAP.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Conf/SQL.pm
spamassassin/trunk/lib/Mail/SpamAssassin/DBBasedAddrList.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Locker.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Flock.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Locker/UnixNFSSafe.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Win32.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm
spamassassin/trunk/lib/Mail/SpamAssassin/NetSet.pm
spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgLearner.pm
spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
spamassassin/trunk/lib/Mail/SpamAssassin/PersistentAddrList.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Hashcash.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Razor2.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/SPF.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Reporter.pm
spamassassin/trunk/lib/Mail/SpamAssassin/SQLBasedAddrList.pm
spamassassin/trunk/lib/Mail/SpamAssassin/TextCat.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
spamassassin/trunk/masses/mass-check
spamassassin/trunk/spamassassin.raw
spamassassin/trunk/spamd/spamd.raw
Log:
bug 3703: clean up debugging
Modified: spamassassin/trunk/lib/Mail/SpamAssassin.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin.pm Sat Oct 2 14:54:53 2004
@@ -92,7 +92,7 @@
use vars qw{
@ISA $VERSION $SUB_VERSION @EXTRA_VERSION $IS_DEVEL_BUILD $HOME_URL
- $DEBUG
+ $DEBUG $INFO %facilities
@default_rules_path @default_prefs_path
@default_userprefs_path @default_userstate_dir
@site_rules_path
@@ -243,37 +243,24 @@
if (!defined $self) { $self = { }; }
bless ($self, $class);
- $DEBUG->{enabled} = 0;
- if (defined $self->{debug} && $self->{debug} > 0) { $DEBUG->{enabled} = 1; }
+ # define debugging facilities first
+ $INFO = 0;
+ $DEBUG = 0;
+ if (defined $self->{debug} && ref($self->{debug}) eq "ARRAY") {
+ $facilities{$_} = 1 for @{ $self->{debug} };
+ # turn on informational notices
+ $INFO = 1 if keys %facilities;
+ # turn on debugging if facilities other than "info" are enabled
+ $DEBUG = keys %facilities && !(keys %facilities == 1 && $facilities{info});
+ }
- # Make the first thing output by debug the version...
- dbg("SpamAssassin version ".Version());
+ # first debugging information possibly printed should be the version
+ info("generic: SpamAssassin version ".Version());
# if the libs are installed in an alternate location, and the caller
# didn't set PREFIX, we should have an estimated guess ready ...
$self->{PREFIX} ||= '@@PREFIX@@'; # substituted at 'make' time
- # This should be moved elsewhere, I know, but SA really needs debug sets
- # I'm putting the intialization here for now, move it if you want
-
- # For each part of the code, you can set debug levels. If the level is
- # progressive, use negative numbers (the more negative, the move debug info
- # is put out), and if you want to use bit fields, use positive numbers
- # All code path debug codes should be listed here with a value of 0 if you
- # want them disabled -- Marc
-
- $DEBUG->{datediff}=-1;
- $DEBUG->{razor}=-3;
- $DEBUG->{dcc}=0;
- $DEBUG->{pyzor}=0;
- $DEBUG->{rbl}=0;
- $DEBUG->{dnsavailable}=-2;
- $DEBUG->{bayes}=0;
- # Bitfield:
- # header regex: 1 | body-text: 2 | uri tests: 4 | raw-body-text: 8
- # full-text regexp: 16 | run_eval_tests: 32 | run_rbl_eval_tests: 64
- $DEBUG->{rulesrun}=64;
-
$self->{conf} ||= new Mail::SpamAssassin::Conf ($self);
$self->{plugins} = Mail::SpamAssassin::PluginHandler->new ($self);
@@ -321,7 +308,7 @@
$self->{locker} = new Mail::SpamAssassin::Locker::'.$class.' ($self);
'; ($@) and die $@;
- if (!defined $self->{locker}) { die "oops! no locker"; }
+ if (!defined $self->{locker}) { die "locker: oops! no locker"; }
}
###########################################################################
@@ -441,12 +428,13 @@
my $msg = Mail::SpamAssassin::PerMsgLearner->new($self, $mail_obj);
if ($forget) {
+ dbg("learn: forgetting message");
$msg->forget($id);
} elsif ($isspam) {
- dbg("Learning Spam");
+ dbg("learn: learning spam");
$msg->learn_spam($id);
} else {
- dbg("Learning Ham");
+ dbg("learn: learning ham");
$msg->learn_ham($id);
}
@@ -487,7 +475,7 @@
sub init_learner {
my $self = shift;
my $opts = shift;
- dbg ("Initialising learner");
+ dbg("learn: initializing learner");
# Make sure we're already initialized ...
$self->init(1);
@@ -578,7 +566,7 @@
my $opts = shift;
my $set = 0;
- dbg ("user has changed");
+ dbg("info: user has changed");
if (defined $opts && $opts->{username}) {
$self->{username} = $opts->{username};
@@ -845,7 +833,7 @@
my $mbox = $mail_obj->get_mbox_separator() || '';
- dbg("Removing Markup");
+ dbg("markup: removing markup");
# Go looking for a "report_safe" encapsulated message. Abort out ASAP
# if we have definitive proof it's not an encapsulated message.
@@ -924,7 +912,7 @@
# let the 3.0 decoding do it...
next if ($hdrs =~ /^X-Spam-Prev-$header:/im);
- dbg ("Removing markup in $header");
+ dbg("markup: removing markup in $header");
if ($header eq 'Subject') {
my $tag = $self->{conf}->{rewrite_header}->{'Subject'};
$tag = quotemeta($tag);
@@ -979,7 +967,7 @@
if (!open(IN,"<$filename")) {
# the file may not exist; this should not be verbose
- dbg ("read_scoreonly_config: cannot open \"$filename\": $!");
+ dbg("config: read_scoreonly_config: cannot open \"$filename\": $!");
return;
}
my $text = join ('',<IN>);
@@ -988,7 +976,7 @@
$self->{conf}->{main} = $self;
$self->{conf}->parse_scores_only ($text);
if ($self->{conf}->{allow_user_rules}) {
- dbg("finishing parsing!");
+ dbg("config: finishing parsing!");
$self->{conf}->finish_parsing();
}
delete $self->{conf}->{main}; # to allow future GC'ing
@@ -1037,7 +1025,7 @@
sub load_scoreonly_ldap {
my ($self, $username) = @_;
- dbg("load_scoreonly_ldap($username)");
+ dbg("config: load_scoreonly_ldap($username)");
my $src = Mail::SpamAssassin::Conf::LDAP->new ($self);
$self->{username} = $username;
$src->load($username);
@@ -1096,7 +1084,7 @@
"Message-Id: <"....@spamassassin_spamd_init>\n", "\n",
"I need to make this message body somewhat long so TextCat preloads\n"x20);
- dbg ("ignore: test message to precompile patterns and load modules");
+ dbg("ignore: test message to precompile patterns and load modules");
# Backup default values which deal with userstate.
# This is done so we can create any new files in, presumably, a temp dir.
@@ -1181,9 +1169,9 @@
if (eval ' require '.$module.'; $modver = $'.$module.'::VERSION; 1;')
{
$modver ||= '(undef)';
- dbg ("diag: module installed: $module, version $modver");
+ dbg("diag: module installed: $module, version $modver");
} else {
- dbg ("diag: module not installed: $module ('require' failed)");
+ dbg("diag: module not installed: $module ('require' failed)");
}
}
}
@@ -1200,7 +1188,7 @@
sub lint_rules {
my ($self) = @_;
- dbg ("ignore: using a test message to lint rules");
+ dbg("ignore: using a test message to lint rules");
my @testmsg = ("From: ignore\@compiling.spamassassin.taint.org\n",
"Subject: \n",
"Message-Id: <"....@lint_rules>\n", "\n",
@@ -1323,7 +1311,7 @@
if (defined $fname) {
if (!-f $fname && !$self->{dont_copy_prefs} && !$self->create_default_prefs($fname)) {
- warn "Failed to create default user preference file $fname\n";
+ warn "config: failed to create default user preference file $fname\n";
}
}
@@ -1332,7 +1320,7 @@
}
if ($self->{config_text} !~ /\S/) {
- warn "No configuration text or files found! Please check your setup.\n";
+ warn "config: no configuration text or files found! please check your setup\n";
}
# Go and parse the config!
@@ -1364,10 +1352,10 @@
require '.$type.';
$factory = '.$type.'->new();
';
- if ($@) { warn $@; undef $factory; }
+ if ($@) { warn "auto-whitelist: $@"; undef $factory; }
}
else {
- warn "illegal auto_whitelist_factory setting\n";
+ warn "auto-whitelist: illegal auto_whitelist_factory setting\n";
}
$self->set_persistent_address_list_factory($factory) if defined $factory;
}
@@ -1384,7 +1372,7 @@
return '' unless defined ($path);
- dbg ("using \"$path\" for $desc");
+ dbg("config: using \"$path\" for $desc");
my $txt = '';
if (-d $path) {
@@ -1398,7 +1386,7 @@
dbg("config: read file $file");
}
else {
- warn "cannot open \"$file\": $!\n";
+ warn "config: cannot open \"$file\": $!\n";
next;
}
}
@@ -1412,7 +1400,7 @@
dbg("config: read file $path");
}
else {
- warn "cannot open \"$path\": $!\n";
+ warn "config: cannot open \"$path\": $!\n";
}
}
@@ -1436,12 +1424,12 @@
$fname ||= $self->first_existing_path (@default_userstate_dir);
if (defined $fname && !$self->{dont_copy_prefs}) {
- dbg ("using \"$fname\" for user state dir");
+ dbg("config: using \"$fname\" for user state dir");
}
if (!-d $fname) {
# not being able to create the *dir* is not worth a warning at all times
- eval { mkpath ($fname, 0, 0700) } or dbg ("mkdir $fname failed: $@ $!\n");
+ eval { mkpath($fname, 0, 0700) } or dbg("config: mkdir $fname failed: $@ $!\n");
}
$fname;
}
@@ -1465,7 +1453,7 @@
}
if ($userdir && $userdir ne $self->{user_dir}) {
- warn "Oops! user_dirs don't match! '$userdir' vs '$self->{user_dir}'\n";
+ warn "config: oops! user_dirs don't match! '$userdir' vs '$self->{user_dir}'\n";
}
if (!-f $fname)
@@ -1490,18 +1478,18 @@
if (($< == 0) && ($> == 0) && defined($user)) { # chown it
my ($uid,$gid) = (getpwnam($user))[2,3];
unless (chown($uid, $gid, $fname)) {
- warn "Couldn't chown $fname to $uid:$gid for $user: $!\n";
+ warn "config: couldn't chown $fname to $uid:$gid for $user: $!\n";
}
}
- warn "Created user preferences file: $fname\n";
+ warn "config: created user preferences file: $fname\n";
return(1);
}
else {
- warn "Cannot write to $fname: $!\n";
+ warn "config: cannot write to $fname: $!\n";
}
}
else {
- warn "Cannot open $defprefs: $!\n";
+ warn "config: cannot open $defprefs: $!\n";
}
}
@@ -1565,7 +1553,7 @@
sub get_cf_files_in_dir {
my ($self, $dir) = @_;
- opendir(SA_CF_DIR, $dir) or warn "cannot opendir $dir: $!\n";
+ opendir(SA_CF_DIR, $dir) or warn "config: cannot opendir $dir: $!\n";
my @cfs = grep { /\.cf$/i && -f "$dir/$_" } readdir(SA_CF_DIR);
closedir SA_CF_DIR;
@@ -1639,31 +1627,41 @@
return @addrs;
}
-# Only the first argument is needed, and it can be a reference to a list if
-# you want
+# usage: dbg("facility: message")
+# This is used for all low priority debugging messages.
sub dbg {
- my $dbg=$Mail::SpamAssassin::DEBUG;
+ return unless $Mail::SpamAssassin::DEBUG;
+
+ my $facility = "generic";
+ my $message = shift;
+
+ if ($message =~ /^(\S+?):\s*(.*)/) {
+ $facility = $1;
+ $message = $2;
+ }
- return unless $dbg->{enabled};
+ if ($facilities{all} || $facilities{$facility}) {
+ warn "debug: $facility: $message\n";
+ }
+}
- my ($msg, $codepath, $level) = @_;
+# usage: info("facility: message")
+# This is used for informational messages indicating a normal, but
+# significant, condition. This should be very infrequently called.
+sub info {
+ return unless $Mail::SpamAssassin::INFO;
- $msg=join('',@{$msg}) if (ref $msg);
+ my $facility = "generic";
+ my $message = shift;
- if (defined $codepath) {
- if (not defined $dbg->{$codepath}) {
- warn("dbg called with codepath $codepath, but it's not defined, skipping (message was \"$msg\"\n");
- return 0;
- } elsif (not defined $level) {
- warn("dbg called with codepath $codepath, but no level threshold (message was \"$msg\"\n");
- }
+ if ($message =~ /^(\S+?):\s*(.*)/) {
+ $facility = $1;
+ $message = $2;
}
- # Negative levels are just level numbers, the more negative, the more debug
- return if (defined $level and $level<0 and not $dbg->{$codepath} <= $level);
- # Positive levels are bit fields
- return if (defined $level and $level>0 and not $dbg->{$codepath} & $level);
- warn "debug: $msg\n";
+ if ($facilities{all} || $facilities{info} || $facilities{$facility}) {
+ warn "info: $facility: $message\n";
+ }
}
# sa_die -- used to die with a useful exit code.
@@ -1682,11 +1680,11 @@
}
elsif (!eval { require Storable; }) {
$self->{storable_available} = 0;
- dbg("no Storable module found");
+ dbg("info: no Storable module found");
}
else {
$self->{storable_available} = 1;
- dbg("Storable module v".$Storable::VERSION." found");
+ dbg("info: Storable module v".$Storable::VERSION." found");
}
return $self->{storable_available};
@@ -1705,13 +1703,13 @@
# backup configuration to %conf_backup
my %conf_backup = ();
$spamtest->copy_config(undef, \%conf_backup) ||
- die "error returned from copy_config!\n";
+ die "config: error returned from copy_config!\n";
... do stuff, perhaps modify the config, etc ...
# reset the configuration back to the original
$spamtest->copy_config(\%conf_backup, undef) ||
- die "error returned from copy_config!\n";
+ die "config: error returned from copy_config!\n";
=cut
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm Sat Oct 2 14:54:53 2004
@@ -241,7 +241,7 @@
my ($self, @targets) = @_;
if (!defined $self->{wanted_sub}) {
- die "set_functions never called";
+ die "archive-iterator: set_functions never called";
}
# non-forking model (generally sa-learn), everything in a single process
@@ -278,7 +278,7 @@
exit;
}
else {
- die "cannot fork: $!";
+ die "archive-iterator: cannot fork: $!";
}
# we now have a temp file with the messages to process
@@ -374,7 +374,7 @@
# some error happened during the read!
if (!defined $line || !$line) {
$needs_restart = 1;
- warn "readline failed, attempting to recover\n";
+ warn "archive-iterator: readline failed, attempting to recover\n";
$select->remove($socket);
}
}
@@ -450,7 +450,7 @@
&{$method}($self, $class, $location);
}
else {
- warn "format $format unknown!";
+ warn "archive-iterator: format $format unknown!";
}
}
}
@@ -504,7 +504,7 @@
# create children
for (my $i = 0; $i < $count; $i++) {
($child->[$i],$parent) = $io->socketpair(AF_UNIX,SOCK_STREAM,PF_UNSPEC)
- or die "socketpair failed: $!";
+ or die "archive-iterator: socketpair failed: $!";
if ($pid->[$i] = fork) {
close $parent;
@@ -541,7 +541,7 @@
exit;
}
else {
- die "cannot fork: $!";
+ die "archive-iterator: cannot fork: $!";
}
}
}
@@ -578,7 +578,7 @@
$expr = "$file";
}
if (!open (INPUT, $expr)) {
- warn "Unable to open $file: $!\n";
+ warn "archive-iterator: unable to open $file: $!\n";
return 0;
}
return 1;
@@ -619,7 +619,7 @@
my @files;
- opendir(DIR, $folder) || die "Can't open '$folder' dir: $!";
+ opendir(DIR, $folder) || die "archive-iterator: can't open '$folder' dir: $!";
if (-f "$folder/cyrus.header") {
# cyrus metadata: http://unix.lsa.umich.edu/docs/imap/imap-lsa-srv_3.html
@files = grep { /^\S+$/ && !/^cyrus\.(?:index|header|cache|seen)/ }
@@ -679,7 +679,7 @@
if ($folder ne '-' && -d $folder) {
# passed a directory of mboxes
$folder =~ s/\/\s*$//; #Remove trailing slash, if there
- opendir(DIR, $folder) || die "Can't open '$folder' dir: $!";
+ opendir(DIR, $folder) || die "archive-iterator: can't open '$folder' dir: $!";
while($_ = readdir(DIR)) {
if(/^[^\.]\S*$/ && ! -d "$folder/$_") {
push(@files, "$folder/$_");
@@ -693,7 +693,7 @@
foreach my $file (@files) {
if ($file =~ /\.(?:gz|bz2)$/) {
- die "compressed mbox folders are not supported at this time\n";
+ die "archive-iterator: compressed mbox folders are not supported at this time\n";
}
mail_open($file) or return;
@@ -741,13 +741,13 @@
}
sub scan_mbx {
- my ($self, $class, $folder) = @_ ;
- my (@files, $fp) ;
+ my ($self, $class, $folder) = @_;
+ my (@files, $fp);
if ($folder ne '-' && -d $folder) {
# got passed a directory full of mbx folders.
$folder =~ s/\/\s*$//; # remove trailing slash, if there is one
- opendir(DIR, $folder) || die "Can't open '$folder' dir: $!" ;
+ opendir(DIR, $folder) || die "archive-iterator: can't open '$folder' dir: $!";
while($_ = readdir(DIR)) {
if(/^[^\.]\S*$/ && ! -d "$folder/$_") {
push(@files, "$folder/$_");
@@ -755,36 +755,36 @@
}
closedir(DIR);
} else {
- push(@files, $folder) ;
+ push(@files, $folder);
}
foreach my $file (@files) {
if ($folder =~ /\.(?:gz|bz2)$/) {
- die "compressed mbx folders are not supported at this time\n" ;
+ die "archive-iterator: compressed mbx folders are not supported at this time\n";
}
- mail_open($file) or return ;
+ mail_open($file) or return;
# check the mailbox is in mbx format
- $fp = <INPUT> ;
+ $fp = <INPUT>;
if ($fp !~ /\*mbx\*/) {
- die "Error, mailbox not in mbx format!\n" ;
+ die "archive-iterator: error: mailbox not in mbx format!\n";
}
# skip mbx headers to the first email...
- seek(INPUT, 2048, 0) ;
+ seek(INPUT, 2048, 0);
my $sep = MBX_SEPARATOR;
while (<INPUT>) {
if ($_ =~ /$sep/) {
- my $offset = tell INPUT ;
- my $size = $2 ;
+ my $offset = tell INPUT;
+ my $size = $2;
# gather up the headers...
- my $header = '' ;
+ my $header = '';
while (<INPUT>) {
- last if (/^$/) ;
- $header .= $_ ;
+ last if (/^$/);
+ $header .= $_;
}
my $t;
@@ -795,9 +795,9 @@
next if !$self->message_is_useful_by_date($t);
}
$self->{$class}->{index_pack($class, "b", $t, "$file.$offset")} = $t;
- seek(INPUT, $offset + $size, 0) ;
+ seek(INPUT, $offset + $size, 0);
} else {
- die "Error, failure to read message body!\n" ;
+ die "archive-iterator: error: failure to read message body!\n";
}
}
close INPUT;
@@ -864,26 +864,26 @@
}
sub run_mbx {
- my ($self, $class, $where, $date) = @_ ;
+ my ($self, $class, $where, $date) = @_;
- my ($file, $offset) = ($where =~ m/(.*)\.(\d+)$/) ;
- my @msg ;
+ my ($file, $offset) = ($where =~ m/(.*)\.(\d+)$/);
+ my @msg;
- mail_open($file) or return ;
- seek(INPUT, $offset, 0) ;
+ mail_open($file) or return;
+ seek(INPUT, $offset, 0);
while (<INPUT>) {
- last if ($_ =~ MBX_SEPARATOR) ;
+ last if ($_ =~ MBX_SEPARATOR);
# skip mails that are too big
if (! $self->{opt_all} && @msg > BIG_LINES) {
- close INPUT ;
- return ;
+ close INPUT;
+ return;
}
- push (@msg, $_) ;
+ push (@msg, $_);
}
- close INPUT ;
- &{$self->{wanted_sub}}($class, $where, $date, \@msg) ;
+ close INPUT;
+ &{$self->{wanted_sub}}($class, $where, $date, \@msg);
}
############################################################################
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/AutoWhitelist.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/AutoWhitelist.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/AutoWhitelist.pm Sat Oct 2 14:54:53 2004
@@ -106,7 +106,7 @@
my $noipent = $self->{checker}->get_addr_entry ($noipaddr);
if (defined $noipent->{count} && $noipent->{count} > 0) {
- dbg ("AWL: found entry w/o IP address for $addr: replacing with $origip");
+ dbg("auto-whitelist: found entry w/o IP address for $addr: replacing with $origip");
$self->{checker}->remove_entry($noipent);
# Now assign proper entry the count and totscore values of the no ip entry
# instead of assigning the whole value to avoid wiping out any information added
@@ -239,6 +239,6 @@
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm Sat Oct 2 14:54:53 2004
@@ -287,7 +287,7 @@
# after compiling; for example, spamd will never see that the
# number of messages has reached the bayes-scanning threshold.
if ($self->{store}->db_readable()) {
- warn "SpamAssassin: oops! still tied to bayes DBs, untie'ing\n";
+ warn "bayes: oops! still tied to bayes DBs, untying\n";
$self->{store}->untie_db();
}
}
@@ -576,7 +576,7 @@
} else {
$parsed{$hdr} = $val;
}
- dbg ("tokenize: header tokens for $hdr = \"$parsed{$hdr}\"");
+ dbg("bayes: header tokens for $hdr = \"$parsed{$hdr}\"");
}
return %parsed;
@@ -698,7 +698,7 @@
my $ignore = $PMS->check_from_in_list('bayes_ignore_from')
|| $PMS->check_to_in_list('bayes_ignore_to');
- dbg("Not using Bayes, bayes_ignore_from or _to rule") if $ignore;
+ dbg("bayes: not using bayes, bayes_ignore_from or _to rule") if $ignore;
return $ignore;
}
@@ -749,7 +749,7 @@
if ($@) { # if we died, untie the dbs.
my $failure = $@;
$self->{store}->untie_db();
- die $failure;
+ die "bayes: $failure";
}
return $ret;
@@ -769,12 +769,12 @@
if (defined ($seen)) {
if (($seen eq 's' && $isspam) || ($seen eq 'h' && !$isspam)) {
- dbg ("$msgid: already learnt correctly, not learning twice");
+ dbg("bayes: $msgid already learnt correctly, not learning twice");
return 0;
} elsif ($seen !~ /^[hs]$/) {
- warn ("db_seen corrupt: value='$seen' for $msgid. ignored");
+ warn("bayes: db_seen corrupt: value='$seen' for $msgid, ignored");
} else {
- dbg ("$msgid: already learnt as opposite, forgetting first");
+ dbg("bayes: $msgid already learnt as opposite, forgetting first");
# kluge so that forget() won't untie the db on us ...
my $orig = $self->{main}->{learn_caller_will_untie};
@@ -787,7 +787,7 @@
# forget() gave us a fatal error, so propagate that up
if ($fatal) {
- dbg("forget() returned a fatal error, so learn() will too");
+ dbg("bayes: forget() returned a fatal error, so learn() will too");
return;
}
}
@@ -834,7 +834,7 @@
msgatime => $msgatime,
});
- dbg("bayes: Learned '$msgid', atime: $msgatime");
+ dbg("bayes: learned '$msgid', atime: $msgatime");
1;
}
@@ -877,7 +877,7 @@
if ($@) { # if we died, untie the dbs.
my $failure = $@;
$self->{store}->untie_db();
- die $failure;
+ die "bayes: $failure";
}
return $ret;
@@ -902,7 +902,7 @@
} elsif ($seen eq 'h') {
$isspam = 0;
} else {
- dbg ("forget: msgid $msgid seen entry is neither ham nor spam, ignored");
+ dbg("bayes: forget: msgid $msgid seen entry is neither ham nor spam, ignored");
return 0;
}
@@ -911,13 +911,13 @@
last;
}
else {
- dbg ("forget: msgid $msgid not learnt, ignored");
+ dbg("bayes: forget: msgid $msgid not learnt, ignored");
}
}
# This message wasn't learnt before, so return
if (!defined $isspam) {
- dbg("forget: no msgid from this message has been learnt, skipping message");
+ dbg("bayes: forget: no msgid from this message has been learnt, skipping message");
return 0;
}
elsif ($isspam) {
@@ -990,7 +990,7 @@
if (!ref $msg) {
# I have no idea why this seems to happen. TODO
- warn "msg not a ref: '$msg'";
+ warn "bayes: msg not a ref: '$msg'";
return { };
}
@@ -1002,7 +1002,7 @@
if (!defined $msgdata) {
# why?!
- warn "failed to get body for ".scalar($self->get_msgid($self->{msg}))."\n";
+ warn "bayes: failed to get body for ".scalar($self->get_msgid($self->{msg}))."\n";
return { };
}
@@ -1025,10 +1025,10 @@
my ($self, $sync, $expire, $opts) = @_;
if (!$self->{conf}->{use_bayes}) { return 0; }
- dbg("Syncing Bayes and expiring old tokens...");
+ dbg("bayes: syncing bayes and expiring old tokens...");
$self->{store}->sync($opts) if ( $sync );
$self->{store}->expire_old_tokens($opts) if ( $expire );
- dbg("Syncing complete.");
+ dbg("bayes: syncing complete");
return 0;
}
@@ -1063,7 +1063,7 @@
my $prob;
if ($ratios == 0 && $ration == 0) {
- warn "oops? ratios == ration == 0";
+ warn "bayes: oops? ratios == ration == 0";
return;
} else {
$prob = ($ratios) / ($ration + $ratios);
@@ -1150,14 +1150,14 @@
my ($ns, $nn) = $self->{store}->nspam_nham_get();
if ($ns < $self->{conf}->{bayes_min_spam_num}) {
- dbg("bayes: Not available for scanning, only $ns spam(s) in Bayes DB < ".$self->{conf}->{bayes_min_spam_num});
+ dbg("bayes: not available for scanning, only $ns spam(s) in bayes DB < ".$self->{conf}->{bayes_min_spam_num});
if (!$self->{main}->{learn_caller_will_untie}) {
$self->{store}->untie_db();
}
return 0;
}
if ($nn < $self->{conf}->{bayes_min_ham_num}) {
- dbg("bayes: Not available for scanning, only $nn ham(s) in Bayes DB < ".$self->{conf}->{bayes_min_ham_num});
+ dbg("bayes: not available for scanning, only $nn ham(s) in bayes DB < ".$self->{conf}->{bayes_min_ham_num});
if (!$self->{main}->{learn_caller_will_untie}) {
$self->{store}->untie_db();
}
@@ -1189,7 +1189,7 @@
$self->{raw_counts} = " ns=$ns nn=$nn ";
}
- dbg ("bayes corpus size: nspam = $ns, nham = $nn");
+ dbg("bayes: corpus size: nspam = $ns, nham = $nn");
my $msgdata = $self->get_msgdata_from_permsgstatus ($permsgstatus);
@@ -1214,7 +1214,7 @@
# If none of the tokens were found in the DB, we're going to skip
# this message...
if (!keys %pw) {
- dbg ("cannot use bayes on this message; none of the tokens were found in the database");
+ dbg("bayes: cannot use bayes on this message; none of the tokens were found in the database");
goto skip;
}
@@ -1264,13 +1264,13 @@
# update the atime on this token, it proved useful
push(@touch_tokens, $_);
- dbg ("bayes token '$raw_token' => $pw");
+ dbg("bayes: token '$raw_token' => $pw");
}
if (!@sorted || (REQUIRE_SIGNIFICANT_TOKENS_TO_SCORE > 0 &&
$#sorted <= REQUIRE_SIGNIFICANT_TOKENS_TO_SCORE))
{
- dbg ("cannot use bayes on this message; not enough usable tokens found");
+ dbg("bayes: cannot use bayes on this message; not enough usable tokens found");
goto skip;
}
@@ -1283,7 +1283,7 @@
# Couldn't come up with a probability?
goto skip unless defined $score;
- dbg ("bayes: score = $score");
+ dbg("bayes: score = $score");
# no need to call tok_touch_all unless there were significant
# tokens and a score was returned
@@ -1305,7 +1305,7 @@
skip:
if (!defined $score) {
- dbg ("bayes: not scoring message, returning undef");
+ dbg("bayes: not scoring message, returning undef");
}
# Take any opportunistic actions we can take
@@ -1371,8 +1371,8 @@
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
-sub sa_die { Mail::SpamAssassin::sa_die (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
+sub sa_die { Mail::SpamAssassin::sa_die(@_); }
###########################################################################
@@ -1400,7 +1400,7 @@
sub chi2q {
my ($x2, $v) = @_;
- die "v must be even in chi2q(x2, v)" if $v & 1;
+ die "bayes: v must be even in chi2q(x2, v)" if $v & 1;
my $m = $x2 / 2.0;
my ($sum, $term);
$sum = $term = exp(0 - $m);
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm Sat Oct 2 14:54:53 2004
@@ -121,7 +121,7 @@
sub tie_db_readonly {
my ($self) = @_;
- die "tie_db_readonly: not implemented\n";
+ die "bayes: tie_db_readonly: not implemented\n";
}
=head2 tie_db_writable
@@ -138,7 +138,7 @@
sub tie_db_writable {
my ($self) = @_;
- die "tie_db_writable: not implemented\n";
+ die "bayes: tie_db_writable: not implemented\n";
}
=head2 untie_db
@@ -152,7 +152,7 @@
sub untie_db {
my $self = shift;
- die "untie_db: not implemented\n";
+ die "bayes: untie_db: not implemented\n";
}
=head2 calculate_expire_delta
@@ -169,7 +169,7 @@
sub calculate_expire_delta {
my ($self, $newest_atime, $start, $max_expire_mult) = @_;
- die "calculate_expire_delta: not implemented\n";
+ die "bayes: calculate_expire_delta: not implemented\n";
}
=head2 token_expiration
@@ -187,7 +187,7 @@
sub token_expiration {
my ($self, $opts, $newest_atime, $newdelta) = @_;
- die "token_expiration: not implemented\n";
+ die "bayes: token_expiration: not implemented\n";
}
=head2 expire_old_tokens
@@ -216,7 +216,7 @@
}
if ($err) { # if we died, untie the dbs.
- warn "bayes expire_old_tokens: $err\n";
+ warn "bayes: expire_old_tokens: $err\n";
return 0;
}
$ret;
@@ -266,7 +266,7 @@
dbg("bayes: token count: ".$vars[3].", final goal reduction size: $goal_reduction");
if ( $goal_reduction < 1000 ) { # too few tokens to expire, abort.
- dbg("bayes: reduction goal of $goal_reduction is under 1,000 tokens. skipping expire.");
+ dbg("bayes: reduction goal of $goal_reduction is under 1,000 tokens, skipping expire");
$self->set_last_expire(time());
$self->remove_running_expire_tok(); # this won't be cleaned up, so do it now.
return 1; # we want to indicate things ran as expected
@@ -287,7 +287,7 @@
# count and the current goal removal count.
my $ratio = ($vars[9] == 0 || $vars[9] > $goal_reduction) ? $vars[9]/$goal_reduction : $goal_reduction/$vars[9];
- dbg("bayes: First pass? Current: ".time().", Last: ".$vars[4].", atime: ".$vars[8].", count: ".$vars[9].", newdelta: $newdelta, ratio: $ratio, period: ".$self->{expiry_period});
+ dbg("bayes: first pass? current: ".time().", Last: ".$vars[4].", atime: ".$vars[8].", count: ".$vars[9].", newdelta: $newdelta, ratio: $ratio, period: ".$self->{expiry_period});
## ESTIMATION PHASE
#
@@ -306,7 +306,7 @@
#
if ( (time() - $vars[4] > 86400*30) || ($vars[8] < $self->{expiry_period}) || ($vars[9] < 1000)
|| ($newdelta < $self->{expiry_period}) || ($ratio > 1.5) ) {
- dbg("bayes: Can't use estimation method for expiry, something fishy, calculating optimal atime delta (first pass)");
+ dbg("bayes: can't use estimation method for expiry, unexpected result, calculating optimal atime delta (first pass)");
my $start = $self->{expiry_period}; # exponential search starting at ...? 1/2 day, 1, 2, 4, 8, 16, ...
my $max_expire_mult = 2**$self->{expiry_max_exponent}; # $max_expire_mult * $start = max expire time (256 days), power of 2.
@@ -318,11 +318,11 @@
return 0 unless (%delta);
# This will skip the for loop if debugging isn't enabled ...
- if ( $Mail::SpamAssassin::DEBUG->{'enabled'} ) {
+ if ($Mail::SpamAssassin::DEBUG) {
dbg("bayes: atime\ttoken reduction");
dbg("bayes: ========\t===============");
- for( my $i = 1; $i<=$max_expire_mult; $i<<=1 ) {
- dbg("bayes: ".$start*$i."\t".(exists $delta{$i} ? $delta{$i} : 0));
+ for(my $i = 1; $i<=$max_expire_mult; $i <<= 1) {
+ dbg("bayes: ".$start*$i."\t".(exists $delta{$i} ? $delta{$i} : 0));
}
}
@@ -349,35 +349,35 @@
# - reduction count < 1000, not enough tokens to be worth doing an expire.
#
if ( !exists $delta{$max_expire_mult} || $delta{$max_expire_mult} < 1000 ) {
- dbg("bayes: couldn't find a good delta atime, need more token difference, skipping expire.");
+ dbg("bayes: couldn't find a good delta atime, need more token difference, skipping expire");
$self->set_last_expire(time());
$self->remove_running_expire_tok(); # this won't be cleaned up, so do it now.
return 1; # we want to indicate things ran as expected
}
$newdelta = $start * $max_expire_mult;
- dbg("bayes: First pass decided on $newdelta for atime delta");
+ dbg("bayes: first pass decided on $newdelta for atime delta");
}
else { # use the estimation method
- dbg("bayes: Can do estimation method for expiry, skipping first pass.");
+ dbg("bayes: can do estimation method for expiry, skipping first pass");
}
my ($kept, $deleted, $num_hapaxes, $num_lowfreq) = $self->token_expiration($opts, $newdelta, @vars);
my $done = time();
- my $msg = "expired old Bayes database entries in ".($done - $started)." seconds";
+ my $msg = "expired old bayes database entries in ".($done - $started)." seconds";
my $msg2 = "$kept entries kept, $deleted deleted";
if ($opts->{verbose}) {
-
my $hapax_pc = ($num_hapaxes * 100) / $kept;
my $lowfreq_pc = ($num_lowfreq * 100) / $kept;
print "$msg\n$msg2\n";
printf "token frequency: 1-occurence tokens: %3.2f%%\n", $hapax_pc;
printf "token frequency: less than 8 occurrences: %3.2f%%\n", $lowfreq_pc;
- } else {
- dbg ("$msg: $msg2");
+ }
+ else {
+ dbg("bayes: $msg: $msg2");
}
return 1;
@@ -394,7 +394,7 @@
sub sync_due {
my ($self) = @_;
- die "sync_due: not implemented\n";
+ die "bayes: sync_due: not implemented\n";
}
=head2 expiry_due
@@ -434,7 +434,7 @@
return 0 if ($last_expire < 300);
}
- dbg("Bayes DB expiry: Tokens in DB: $ntoks, Expiry max size: ".$self->{expiry_max_db_size}.", Oldest atime: ".$vars[5].", Newest atime: ".$vars[10].", Last expire: ".$vars[4].", Current time: ".time(),'bayes','-1');
+ dbg("bayes: DB expiry: tokens in DB: $ntoks, Expiry max size: ".$self->{expiry_max_db_size}.", Oldest atime: ".$vars[5].", Newest atime: ".$vars[10].", Last expire: ".$vars[4].", Current time: ".time(),'bayes','-1');
my $conf = $self->{bayes}->{main}->{conf};
if ($ntoks <= 100000 || # keep at least 100k tokens
@@ -461,7 +461,7 @@
sub seen_get {
my ($self, $msgid) = @_;
- die "seen_get: not implemented\n";
+ die "bayes: seen_get: not implemented\n";
}
=head2 seen_put
@@ -476,7 +476,7 @@
sub seen_put {
my ($self, $msgid, $flag) = @_;
- die "seen_put: not implemented\n";
+ die "bayes: seen_put: not implemented\n";
}
=head2 seen_delete
@@ -490,7 +490,7 @@
sub seen_delete {
my ($self, $msgid) = @_;
- die "seen_delete: not implemented\n";
+ die "bayes: seen_delete: not implemented\n";
}
=head2 get_storage_variables
@@ -529,7 +529,7 @@
sub get_storage_variables {
my ($self) = @_;
- die "get_storage_variables: not implemented\n";
+ die "bayes: get_storage_variables: not implemented\n";
}
=head2 dump_db_toks
@@ -544,7 +544,7 @@
sub dump_db_toks {
my ($self, $template, $regex, @vars) = @_;
- die "dump_db_toks: not implemented\n";
+ die "bayes: dump_db_toks: not implemented\n";
}
=head2 set_last_expire
@@ -558,7 +558,7 @@
sub set_last_expire {
my ($self, $time) = @_;
- die "set_last_expire: not implemented\n";
+ die "bayes: set_last_expire: not implemented\n";
}
=head2 get_running_expire_tok
@@ -573,7 +573,7 @@
sub get_running_expire_tok {
my ($self) = @_;
- die "get_running_expire_tok: not implemented\n";
+ die "bayes: get_running_expire_tok: not implemented\n";
}
=head2 set_running_expire_tok
@@ -587,7 +587,7 @@
sub set_running_expire_tok {
my ($self) = @_;
- die "set_running_expire_tok: not implemented\n";
+ die "bayes: set_running_expire_tok: not implemented\n";
}
=head2 remove_running_expire_tok
@@ -601,7 +601,7 @@
sub remove_running_expire_tok {
my ($self) = @_;
- die "remove_running_expire_tok: not implemented\n";
+ die "bayes: remove_running_expire_tok: not implemented\n";
}
=head2 tok_get
@@ -616,7 +616,7 @@
sub tok_get {
my ($self, $token) = @_;
- die "tok_get: not implemented\n";
+ die "bayes: tok_get: not implemented\n";
}
=head2 tok_get_all
@@ -631,7 +631,7 @@
sub tok_get_all {
my ($self, $tokens) = @_;
- die "tok_get_all: not implemented\n";
+ die "bayes: tok_get_all: not implemented\n";
}
=head2 tok_count_change
@@ -649,7 +649,7 @@
sub tok_count_change {
my ($self, $spam_count, $ham_count, $token, $atime) = @_;
- die "tok_count_change: not implemented\n";
+ die "bayes: tok_count_change: not implemented\n";
}
=head2 nspam_nham_get
@@ -664,7 +664,7 @@
sub nspam_nham_get {
my ($self) = @_;
- die "nspam_nham_get: not implemented\n";
+ die "bayes: nspam_nham_get: not implemented\n";
}
=head2 nspam_nham_change
@@ -679,7 +679,7 @@
sub nspam_nham_change {
my ($self, $num_spam, $num_ham) = @_;
- die "nspam_nham_change: not implemented\n";
+ die "bayes: nspam_nham_change: not implemented\n";
}
=head2 tok_touch
@@ -694,7 +694,7 @@
sub tok_touch {
my ($self, $token, $atime) = @_;
- die "tok_touch: not implemanted\n";
+ die "bayes: tok_touch: not implemanted\n";
}
=head2 tok_touch_all
@@ -710,7 +710,7 @@
sub tok_touch_all {
my ($self, $tokens, $atime) = @_;
- die "tok_touch_all: not implemanted\n";
+ die "bayes: tok_touch_all: not implemanted\n";
}
=head2 cleanup
@@ -725,7 +725,7 @@
sub cleanup {
my ($self) = @_;
- die "cleanup: not implemented\n";
+ die "bayes: cleanup: not implemented\n";
}
=head2 get_magic_re
@@ -739,7 +739,7 @@
sub get_magic_re {
my ($self) = @_;
- die "get_magic_re: not implemented\n";
+ die "bayes: get_magic_re: not implemented\n";
}
=head2 sync
@@ -753,7 +753,7 @@
sub sync {
my ($self, $opts) = @_;
- die "sync: not implemented\n";
+ die "bayes: sync: not implemented\n";
}
=head2 perform_upgrade
@@ -771,7 +771,7 @@
sub perform_upgrade {
my ($self, $opts) = @_;
- die "perform_upgrade: not implemented\n";
+ die "bayes: perform_upgrade: not implemented\n";
}
=head2 clear_database
@@ -788,7 +788,7 @@
sub clear_database {
my ($self) = @_;
- die "clear_database: not implemented\n";
+ die "bayes: clear_database: not implemented\n";
}
=head2 backup_database
@@ -802,7 +802,7 @@
sub backup_database {
my ($self) = @_;
- die "backup_database: not implemented\n";
+ die "bayes: backup_database: not implemented\n";
}
=head2 restore_database
@@ -819,7 +819,7 @@
sub restore_database {
my ($self, $filename, $showdots) = @_;
- die "restore_database: not implemented\n";
+ die "bayes: restore_database: not implemented\n";
}
=head2 db_readable
@@ -834,7 +834,7 @@
sub db_readable {
my ($self) = @_;
- die "db_readable: not implemented\n";
+ die "bayes: db_readable: not implemented\n";
}
=head2 db_writable
@@ -849,11 +849,11 @@
sub db_writable {
my ($self) = @_;
- die "db_writable: not implemented\n";
+ die "bayes: db_writable: not implemented\n";
}
-sub dbg { Mail::SpamAssassin::dbg (@_); }
-sub sa_die { Mail::SpamAssassin::sa_die (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
+sub sa_die { Mail::SpamAssassin::sa_die(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm Sat Oct 2 14:54:53 2004
@@ -116,7 +116,7 @@
my ($self) = @_;
if (!HAS_DB_FILE) {
- dbg ("bayes: DB_File module not installed, cannot use Bayes");
+ dbg("bayes: DB_File module not installed, cannot use bayes");
return 0;
}
@@ -126,7 +126,7 @@
my $main = $self->{bayes}->{main};
if (!defined($main->{conf}->{bayes_path})) {
- dbg ("bayes_path not defined");
+ dbg("bayes: bayes_path not defined");
return 0;
}
@@ -138,7 +138,7 @@
for my $ext (@DB_EXTENSIONS) { if (-f $path.'_toks'.$ext) { $found=1; last; } }
if (!$found) {
- dbg ("bayes: no dbs present, cannot tie DB R/O: ${path}_toks");
+ dbg("bayes: no dbs present, cannot tie DB R/O: ${path}_toks");
return 0;
}
@@ -166,7 +166,7 @@
return 1;
failed_to_tie:
- warn "Cannot open bayes databases ${path}_* R/O: tie failed: $!\n";
+ warn "bayes: cannot open bayes databases ${path}_* R/O: tie failed: $!\n";
foreach my $dbname (@DBNAMES) {
my $db_var = 'db_'.$dbname;
next unless exists $self->{$db_var};
@@ -184,7 +184,7 @@
my ($self) = @_;
if (!HAS_DB_FILE) {
- dbg ("bayes: DB_File module not installed, cannot use Bayes");
+ dbg("bayes: DB_File module not installed, cannot use bayes");
return 0;
}
@@ -199,7 +199,7 @@
}
if (!defined($main->{conf}->{bayes_path})) {
- dbg ("bayes_path not defined");
+ dbg("bayes: bayes_path not defined");
return 0;
}
@@ -228,7 +228,7 @@
$self->{locked_file} = $path;
$self->{is_locked} = 1;
} else {
- warn "Cannot open bayes databases ${path}_* R/W: lock failed: $!\n";
+ warn "bayes: cannot open bayes databases ${path}_* R/W: lock failed: $!\n";
return 0;
}
@@ -279,7 +279,7 @@
$self->{bayes}->{main}->{locker}->safe_unlock ($self->{locked_file});
$self->{is_locked} = 0;
}
- warn "Cannot open bayes databases ${path}_* R/W: tie failed: $err\n";
+ warn "bayes: cannot open bayes databases ${path}_* R/W: tie failed: $err\n";
return 0;
}
@@ -323,12 +323,12 @@
# older version's journal files are likely not in the same format as the new ones, so remove it.
my $jpath = $self->_get_journal_filename();
if ( -f $jpath ) {
- dbg("bayes: old journal file found, removing.");
- warn "Couldn't remove $jpath: $!" if ( !unlink $jpath );
+ dbg("bayes: old journal file found, removing");
+ warn "bayes: couldn't remove $jpath: $!" if ( !unlink $jpath );
}
if ( $self->{db_version} < 2 ) {
- dbg ("bayes: upgrading database format from v".$self->{db_version}." to v2");
+ dbg("bayes: upgrading database format from v".$self->{db_version}." to v2");
$self->set_running_expire_tok();
my($DB_NSPAM_MAGIC_TOKEN, $DB_NHAM_MAGIC_TOKEN, $DB_NTOKENS_MAGIC_TOKEN);
@@ -409,9 +409,9 @@
# older versions used scancount, so kill the stupid little file ...
my $msgc = $path.'_msgcount';
if ( -f $msgc ) {
- dbg("bayes: old msgcount file found, removing.");
+ dbg("bayes: old msgcount file found, removing");
if ( !unlink $msgc ) {
- warn "Couldn't remove $msgc: $!";
+ warn "bayes: couldn't remove $msgc: $!";
}
}
@@ -421,7 +421,7 @@
my $oldf = $name.$ext;
next unless (-f $newf);
if (!rename ($newf, $oldf)) {
- warn "rename $newf to $oldf failed: $!\n";
+ warn "bayes: rename $newf to $oldf failed: $!\n";
return 0;
}
}
@@ -434,13 +434,13 @@
return 0 unless $res;
undef $res;
- dbg ("bayes: upgraded database format from v".$self->{db_version}." to v2 in ".(time - $started)." seconds");
+ dbg("bayes: upgraded database format from v".$self->{db_version}." to v2 in ".(time - $started)." seconds");
$self->{db_version} = 2; # need this for other functions which check
}
# Version 3 of the database converts all existing tokens to SHA1 hashes
if ( $self->{db_version} == 2 ) {
- dbg ("bayes: upgrading database format from v".$self->{db_version}." to v3");
+ dbg("bayes: upgrading database format from v".$self->{db_version}." to v3");
$self->set_running_expire_tok();
my $DB_NSPAM_MAGIC_TOKEN = "\015\001\007\011\003NSPAM";
@@ -507,7 +507,7 @@
my $oldf = $name.$ext;
next unless (-f $newf);
if (!rename ($newf, $oldf)) {
- warn "rename $newf to $oldf failed: $!\n";
+ warn "bayes: rename $newf to $oldf failed: $!\n";
return 0;
}
}
@@ -520,7 +520,7 @@
return 0 unless $res;
undef $res;
- dbg ("bayes: upgraded database format from v".$self->{db_version}." to v3 in ".(time - $started)." seconds");
+ dbg("bayes: upgraded database format from v".$self->{db_version}." to v3 in ".(time - $started)." seconds");
$self->{db_version} = 3; # need this for other functions which check
}
@@ -547,14 +547,14 @@
my $db_var = 'db_'.$dbname;
if (exists $self->{$db_var}) {
- dbg ("bayes: $$ untie-ing $db_var");
+ dbg("bayes: $$ untie-ing $db_var");
untie %{$self->{$db_var}};
delete $self->{$db_var};
}
}
if ($self->{is_locked}) {
- dbg ("bayes: files locked, now unlocking lock");
+ dbg("bayes: files locked, now unlocking lock");
$self->{bayes}->{main}->{locker}->safe_unlock ($self->{locked_file});
$self->{is_locked} = 0;
}
@@ -682,7 +682,7 @@
# Sanity check: if we expired too many tokens, abort!
if ($kept < 100000) {
- dbg("bayes: Token Expiration would expire too many tokens, aborting.");
+ dbg("bayes: token expiration would expire too many tokens, aborting");
# set the magic tokens appropriately
# make sure the next expire run does a first pass
$self->{db_toks}->{$LAST_EXPIRE_MAGIC_TOKEN} = time();
@@ -717,7 +717,7 @@
my $oldf = $path.'_toks'.$ext;
next unless (-f $newf);
if (!rename ($newf, $oldf)) {
- warn "rename $newf to $oldf failed: $!\n";
+ warn "bayes: rename $newf to $oldf failed: $!\n";
}
}
}
@@ -741,7 +741,7 @@
return 0 if ( $conf->{bayes_journal_max_size} == 0 );
my @vars = $self->get_storage_variables();
- dbg("Bayes DB journal sync: last sync: ".$vars[7],'bayes','-1');
+ dbg("bayes: DB journal sync: last sync: ".$vars[7],'bayes','-1');
## Ok, should we do a sync?
@@ -1031,7 +1031,7 @@
my $umask = umask(0777 - (oct ($conf->{bayes_file_mode}) & 0666));
if (!open (OUT, ">>".$path)) {
- warn "cannot write to $path, Bayes db update ignored: $!\n";
+ warn "bayes: cannot write to $path, bayes db update ignored: $!\n";
umask $umask; # reset umask
return;
}
@@ -1049,19 +1049,19 @@
# argh, write failure, give up
if (!defined $len || $len < 0) {
$len = 0 unless ( defined $len );
- warn "write failed to Bayes journal $path ($len of $nbytes)!\n";
+ warn "bayes: write failed to Bayes journal $path ($len of $nbytes)!\n";
last;
}
# This shouldn't happen, but could if the fs is full...
if ($len != $nbytes) {
- warn "partial write to Bayes journal $path ($len of $nbytes), recovering.\n";
+ warn "bayes: partial write to bayes journal $path ($len of $nbytes), recovering\n";
# we want to be atomic, so revert the journal file back to where
# we know it's "good". if we can't truncate the journal, or we've
# tried 5 times to do the write, abort!
if (!truncate(OUT, $original_point) || ($write_failure++ > 4)) {
- warn "cannot write to Bayes journal $path, aborting!\n";
+ warn "bayes: cannot write to bayes journal $path, aborting!\n";
last;
}
@@ -1071,7 +1071,7 @@
} while ($len != $nbytes);
if (!close OUT) {
- warn "cannot write to $path, Bayes db update ignored\n";
+ warn "bayes: cannot write to $path, bayes db update ignored\n";
}
$self->{string_to_journal} = '';
@@ -1198,7 +1198,7 @@
}
$count++;
} else {
- warn "Bayes journal: gibberish entry found: $_";
+ warn "bayes: gibberish entry found in journal: $_";
}
}
close JOURNAL;
@@ -1223,13 +1223,14 @@
$self->{db_toks}->{$LAST_JOURNAL_SYNC_MAGIC_TOKEN} = $started;
my $done = time();
- my $msg = ("synced Bayes databases from journal in ".($done - $started).
- " seconds: $count unique entries ($total_count total entries)");
+ my $msg = ("bayes: synced databases from journal in " .
+ ($done - $started) .
+ " seconds: $count unique entries ($total_count total entries)");
if ($opts->{verbose}) {
print $msg,"\n";
} else {
- dbg ($msg);
+ dbg($msg);
}
}
@@ -1336,12 +1337,12 @@
my $dir = dirname($path);
# make temporary copy since old dbm and new dbm may have same name
- opendir(DIR, $dir) || die "can't opendir $dir: $!";
+ opendir(DIR, $dir) || die "bayes: can't opendir $dir: $!";
my @files = grep { /^bayes_(?:seen|toks)(?:\.\w+)?$/ } readdir(DIR);
closedir(DIR);
if (@files < 2 || !grep(/bayes_seen/,@files) || !grep(/bayes_toks/,@files))
{
- die "unable to find bayes_toks and bayes_seen, stopping\n";
+ die "bayes: unable to find bayes_toks and bayes_seen, stopping\n";
}
# untaint @files (already safe after grep)
@files = map { /(.*)/, $1 } @files;
@@ -1349,7 +1350,7 @@
for (@files) {
my $src = "$dir/$_";
my $dst = "$dir/old_$_";
- copy($src, $dst) || die "can't copy $src to $dst: $!\n";
+ copy($src, $dst) || die "bayes: can't copy $src to $dst: $!\n";
}
# delete previous to make way for import
@@ -1376,7 +1377,7 @@
# if we died, untie the dbm files
if ($err) {
- warn "bayes perform_upgrade: $err\n";
+ warn "bayes: perform_upgrade: $err\n";
return 0;
}
$ret;
@@ -1405,7 +1406,7 @@
';
if ($@) {
print "$dbm: $dbm module not installed, nothing copied.\n";
- dbg("error was: $@");
+ dbg("bayes: error was: $@");
}
elsif ($count == 0) {
print "$dbm: no database of that kind found, nothing copied.\n";
@@ -1470,7 +1471,7 @@
my ($self, $filename, $showdots) = @_;
if (!open(DUMPFILE, '<', $filename)) {
- dbg("bayes: Unable to open backup file $filename: $!");
+ dbg("bayes: unable to open backup file $filename: $!");
return 0;
}
@@ -1495,14 +1496,14 @@
my $umask = umask 0;
unless (tie %new_toks, "DB_File", $tmptoksdbname, O_RDWR|O_CREAT|O_EXCL,
(oct ($main->{conf}->{bayes_file_mode}) & 0666)) {
- dbg("bayes: Failed to tie temp toks db: $!");
+ dbg("bayes: failed to tie temp toks db: $!");
$self->untie_db();
umask $umask;
return 0;
}
unless (tie %new_seen, "DB_File", $tmpseendbname, O_RDWR|O_CREAT|O_EXCL,
(oct ($main->{conf}->{bayes_file_mode}) & 0666)) {
- dbg("bayes: Failed to tie temp seen db: $!");
+ dbg("bayes: failed to tie temp seen db: $!");
untie %new_toks;
unlink $tmptoksdbname;
$self->untie_db();
@@ -1533,7 +1534,7 @@
$db_version = $1;
}
else {
- dbg("bayes: Database Version must be the first line in the backup file, correct and re-run.");
+ dbg("bayes: database version must be the first line in the backup file, correct and re-run");
untie %new_toks;
untie %new_seen;
unlink $tmptoksdbname;
@@ -1543,7 +1544,7 @@
}
unless ($db_version == 2 || $db_version == 3) {
- warn("bayes: Database Version $db_version is unsupported, must be version 2 or 3.");
+ warn("bayes: database version $db_version is unsupported, must be version 2 or 3");
untie %new_toks;
untie %new_seen;
unlink $tmptoksdbname;
@@ -1570,7 +1571,7 @@
$num_ham = $value;
}
else {
- dbg("bayes: restore_database: Skipping unknown line: $line");
+ dbg("bayes: restore_database: skipping unknown line: $line");
}
}
elsif ($line =~ /^t\s+/) { # token line
@@ -1585,28 +1586,28 @@
if ($spam_count < 0) {
$spam_count = 0;
- push(@warnings,'Spam Count < 0, resetting');
+ push(@warnings, 'spam count < 0, resetting');
$token_warn_p = 1;
}
if ($ham_count < 0) {
$ham_count = 0;
- push(@warnings,'Ham Count < 0, resetting');
+ push(@warnings, 'ham count < 0, resetting');
$token_warn_p = 1;
}
if ($spam_count == 0 && $ham_count == 0) {
- dbg("bayes: Token has zero spam and ham count, skipping.");
+ dbg("bayes: token has zero spam and ham count, skipping");
next;
}
if ($atime > time()) {
$atime = time();
- push(@warnings,'atime > current time, resetting');
+ push(@warnings, 'atime > current time, resetting');
$token_warn_p = 1;
}
if ($token_warn_p) {
- dbg("bayes: Token ($token) has the following warnings:\n".join("\n",@warnings));
+ dbg("bayes: token ($token) has the following warnings:\n".join("\n",@warnings));
}
# database versions < 3 did not encode their token values
@@ -1633,19 +1634,19 @@
my $msgid = $parsed_line[2];
unless ($flag eq 'h' || $flag eq 's') {
- dbg("bayes: Unknown seen flag ($flag) for line: $line, skipping");
+ dbg("bayes: unknown seen flag ($flag) for line: $line, skipping");
next;
}
unless ($msgid) {
- dbg("bayes: Blank msgid for line: $line, skipping");
+ dbg("bayes: blank msgid for line: $line, skipping");
next;
}
$new_seen{$msgid} = $flag;
}
else {
- dbg("bayes: Skipping unknown line: $line");
+ dbg("bayes: skipping unknown line: $line");
next;
}
}
@@ -1654,17 +1655,17 @@
print STDERR "\n" if ($showdots);
unless (defined($num_spam)) {
- dbg("bayes: Unable to find num spam, please check file.");
+ dbg("bayes: unable to find num spam, please check file");
$error_p = 1;
}
unless (defined($num_ham)) {
- dbg("bayes: Unable to find num ham, please check file.");
+ dbg("bayes: unable to find num ham, please check file");
$error_p = 1;
}
if ($error_p) {
- dbg("bayes: Error(s) while attempting to load $filename, correct and Re-Run");
+ dbg("bayes: error(s) while attempting to load $filename, correct and re-run");
untie %new_toks;
untie %new_seen;
@@ -1701,17 +1702,17 @@
# will leave the database in an inconsistent state. Since this is an
# edge case, and they're trying to replace the DB anyway we should be ok.
unless (rename($tmptoksdbname, $toksdbname)) {
- dbg("bayes: Error while renaming $tmptoksdbname to $toksdbname: $!");
+ dbg("bayes: error while renaming $tmptoksdbname to $toksdbname: $!");
return 0;
}
unless (rename($tmpseendbname, $seendbname)) {
- dbg("bayes: Error while renaming $tmpseendbname to $seendbname: $!");
- dbg("bayes: Database now in inconsistent state.");
+ dbg("bayes: error while renaming $tmpseendbname to $seendbname: $!");
+ dbg("bayes: database now in inconsistent state");
return 0;
}
- dbg("bayes: Parsed $line_count lines.");
- dbg("bayes: Created database with $token_count tokens based on $num_spam Spam Messages and $num_ham Ham Messages.");
+ dbg("bayes: parsed $line_count lines");
+ dbg("bayes: created database with $token_count tokens based on $num_spam spam messages and $num_ham ham messages");
return 1;
}
@@ -1771,7 +1772,7 @@
}
# other formats would go here...
else {
- warn "unknown packing format for Bayes db, please re-learn: $packed";
+ warn "bayes: unknown packing format for bayes db, please re-learn: $packed";
return (0, 0, 0);
}
}
@@ -1800,7 +1801,7 @@
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
-sub sa_die { Mail::SpamAssassin::sa_die (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
+sub sa_die { Mail::SpamAssassin::sa_die(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/SQL.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/SQL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/SQL.pm Sat Oct 2 14:54:53 2004
@@ -66,7 +66,7 @@
$self->{db_writable_p} = 0;
if (!$self->{bayes}->{conf}->{bayes_sql_dsn}) {
- dbg("bayes: invalid config, must set bayes_sql_dsn config variable.\n");
+ dbg("bayes: invalid config, must set bayes_sql_dsn config variable\n");
return undef;
}
@@ -77,7 +77,7 @@
$self->{_dbh} = undef;
unless (HAS_DBI) {
- dbg("bayes: Unable to connect to database: DBI module not available: $!");
+ dbg("bayes: unable to connect to database: DBI module not available: $!");
}
if ($self->{bayes}->{conf}->{bayes_sql_override_username}) {
@@ -92,7 +92,7 @@
$self->{_username} = "GLOBALBAYES";
}
}
- dbg("bayes: Using username: ".$self->{_username});
+ dbg("bayes: using username: ".$self->{_username});
return $self;
}
@@ -130,7 +130,7 @@
dbg("bayes: found bayes db version ".$self->{db_version});
if ( $db_ver != $self->DB_VERSION ) {
- warn("bayes: Database version $db_ver is different than we understand (".$self->DB_VERSION."), aborting!");
+ warn("bayes: database version $db_ver is different than we understand (".$self->DB_VERSION."), aborting!");
$self->untie_db();
return 0;
}
@@ -177,7 +177,7 @@
dbg("bayes: found bayes db version ".$self->{db_version});
if ( $db_ver != $self->DB_VERSION ) {
- warn("bayes: Database version $db_ver is different than we understand (".$self->DB_VERSION."), aborting!");
+ warn("bayes: database version $db_ver is different than we understand (".$self->DB_VERSION."), aborting!");
$self->untie_db();
return 0;
}
@@ -244,7 +244,7 @@
my $rc = $sth->execute($self->{_userid}, $newest_atime, $start * $i);
unless ($rc) {
- dbg("bayes: calculate_expire_delta: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: calculate_expire_delta: SQL error: ".$self->{_dbh}->errstr());
return undef;
}
@@ -288,7 +288,7 @@
my $rows = $self->{_dbh}->do($sql, undef, $vars[10], $self->{_userid}, $vars[10]);
unless (defined($rows)) {
- dbg("bayes: token_expiration: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
$deleted = 0;
goto token_expiration_final;
}
@@ -301,7 +301,7 @@
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
- dbg("bayes: token_expiration: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
$deleted = 0;
goto token_expiration_final;
}
@@ -309,7 +309,7 @@
my $rc = $sth->execute($self->{_userid}, $too_old);
unless ($rc) {
- dbg("bayes: token_expiration: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
$deleted = 0;
goto token_expiration_final;
}
@@ -320,7 +320,7 @@
# Sanity check: if we expired too many tokens, abort!
if ($vars[3] - $count < 100000) {
- dbg("bayes: Token Expiration would expire too many tokens, aborting.");
+ dbg("bayes: token expiration would expire too many tokens, aborting");
# set these appropriately so the next expire pass does the first pass
$deleted = 0;
$newdelta = 0;
@@ -334,7 +334,7 @@
$rows = $self->{_dbh}->do($sql, undef, $self->{_userid}, $too_old);
unless (defined($rows)) {
- dbg("bayes: token_expiration: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
$deleted = 0;
goto token_expiration_final;
}
@@ -354,8 +354,8 @@
unless (defined($rows)) {
# Very bad, we actually deleted the tokens, but were unable to update
# bayes_vars with the new data.
- dbg("bayes: token_expiration: SQL Error: ".$self->{_dbh}->errstr());
- dbg("bayes: Bayes database now in inconsistent state, suggest a backup/restore.");
+ dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
+ dbg("bayes: bayes database now in inconsistent state, suggest a backup/restore");
goto token_expiration_final;
}
@@ -372,7 +372,7 @@
unless (defined($rows)) {
# not much more we can do here, so just warn the user and bail out
- dbg("bayes: token_expiration: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
# yeah I know it's the next thing anyway, but here in case someone adds
# additional code below this block
goto token_expiration_final;
@@ -438,7 +438,7 @@
my $rc = $sth->execute($self->{_userid}, $msgid);
unless ($rc) {
- dbg("bayes: seen_get: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: seen_get: SQL error: ".$self->{_dbh}->errstr());
return undef;
}
@@ -475,7 +475,7 @@
$self->{_userid}, $msgid, $flag);
unless (defined($rows)) {
- dbg("bayes: seen_put: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: seen_put: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -508,7 +508,7 @@
$self->{_userid}, $msgid);
unless (defined($rows)) {
- dbg("bayes: seen_delete: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: seen_delete: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -564,14 +564,14 @@
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
- dbg("bayes: get_storage_variables: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: get_storage_variables: SQL error: ".$self->{_dbh}->errstr());
return (0,0,0,0,0,0,0,0,0,0,0);
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
- dbg("bayes: get_storage_variables: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: get_storage_variables: SQL error: ".$self->{_dbh}->errstr());
return (0,0,0,0,0,0,0,0,0,0,0);
}
@@ -625,14 +625,14 @@
my $sth = $self->{_dbh}->prepare($sql);
unless (defined($sth)) {
- dbg("bayes: dump_db_toks: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: dump_db_toks: SQL error: ".$self->{_dbh}->errstr());
return;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
- dbg("bayes: dump_db_toks: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: dump_db_toks: SQL error: ".$self->{_dbh}->errstr());
return;
}
@@ -675,7 +675,7 @@
$self->{_userid});
unless (defined($rows)) {
- dbg("bayes: set_last_expire: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: set_last_expire: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -705,14 +705,14 @@
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
- dbg("bayes: get_running_expire_tok: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: get_running_expire_tok: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
- dbg("bayes: get_running_expire_tok: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: get_running_expire_tok: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -745,7 +745,7 @@
undef,
$self->{_userid}, $time);
unless (defined($rows)) {
- dbg("bayes: set_running_expire_tok: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: set_running_expire_tok: SQL error: ".$self->{_dbh}->errstr());
return undef;
}
@@ -773,7 +773,7 @@
my $rows = $self->{_dbh}->do($sql, undef, $self->{_userid});
unless (defined($rows)) {
- dbg("bayes: remove_running_expire_tok: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: remove_running_expire_tok: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -803,14 +803,14 @@
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
- dbg("bayes: tok_get: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: tok_get: SQL error: ".$self->{_dbh}->errstr());
return (0,0,0);
}
my $rc = $sth->execute($self->{_userid}, $token);
unless ($rc) {
- dbg("bayes: tok_get: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: tok_get: SQL error: ".$self->{_dbh}->errstr());
return (0,0,0);
}
@@ -841,7 +841,7 @@
return [] unless (defined($self->{_dbh}));
my $token_list_size = scalar(@tokens);
- dbg("bayes: tok_get_all: Token Count: $token_list_size");
+ dbg("bayes: tok_get_all: token count: $token_list_size");
my @tok_results;
my @bunch_sizes = (100, 50, 25, 5); # XXX - need to benchmark to tweak
@@ -878,14 +878,14 @@
my $sth = $self->{_dbh}->prepare($dynamic_sql);
unless (defined($sth)) {
- dbg("bayes: tok_get_all: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: tok_get_all: SQL error: ".$self->{_dbh}->errstr());
return [];
}
my $rc = $sth->execute($self->{_userid}, @bindings);
unless ($rc) {
- dbg("bayes: tok_get_all: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: tok_get_all: SQL error: ".$self->{_dbh}->errstr());
return [];
}
@@ -908,14 +908,14 @@
my $sth = $self->{_dbh}->prepare($single_sql);
unless (defined($sth)) {
- dbg("bayes: tok_get_all: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: tok_get_all: SQL error: ".$self->{_dbh}->errstr());
return [];
}
my $rc = $sth->execute($self->{_userid}, $tokens[$search_index++]);
unless ($rc) {
- dbg("bayes: tok_get_all: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: tok_get_all: SQL error: ".$self->{_dbh}->errstr());
return [];
}
@@ -1016,7 +1016,7 @@
}
else {
# For some reason called with no delta, it's ok though so just return
- dbg("bayes: nspam_nham_change: Called with no delta on spam or ham.");
+ dbg("bayes: nspam_nham_change: Called with no delta on spam or ham");
return 1;
}
@@ -1025,7 +1025,7 @@
@bindings);
unless (defined($rows)) {
- dbg("bayes: nspam_nham_change: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: nspam_nham_change: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1061,7 +1061,7 @@
$token, $atime);
unless (defined($rows)) {
- dbg("bayes: tok_touch: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: tok_touch: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1079,7 +1079,7 @@
$rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
- dbg("bayes: tok_touch: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: tok_touch: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1125,7 +1125,7 @@
my $rows = $self->{_dbh}->do($sql, undef, @bindings);
unless (defined($rows)) {
- dbg("bayes: tok_touch_all: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: tok_touch_all: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1143,7 +1143,7 @@
$rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
- dbg("bayes: tok_touch_all: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: tok_touch_all: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1177,7 +1177,7 @@
my $toks_deleted = $self->{_dbh}->do($sql, undef, $self->{_userid});
unless (defined($toks_deleted)) {
- dbg("bayes: cleanup: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: cleanup: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1190,7 +1190,7 @@
my $rows = $self->{_dbh}->do($sql, undef, $self->{_userid});
unless (defined($rows)) {
- dbg("bayes: cleanup: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: cleanup: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1280,7 +1280,7 @@
undef,
$self->{_userid});
unless (defined($rows)) {
- dbg("SQL Error removing user (bayes_vars) data: ".$self->{_dbh}->errstr());
+ dbg("bayes: SQL error removing user (bayes_vars) data: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1288,7 +1288,7 @@
undef,
$self->{_userid});
unless (defined($rows)) {
- dbg("SQL Error removing seen data: ".$self->{_dbh}->errstr());
+ dbg("bayes: SQL error removing seen data: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1296,7 +1296,7 @@
undef,
$self->{_userid});
unless (defined($rows)) {
- dbg("SQL Error removing token data: ".$self->{_dbh}->errstr());
+ dbg("bayes: SQL error removing token data: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1340,14 +1340,14 @@
my $sth = $self->{_dbh}->prepare($token_sql);
unless (defined ($sth)) {
- dbg("bayes: backup_database: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: backup_database: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
- dbg("bayes: backup_database: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: backup_database: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1361,14 +1361,14 @@
$sth = $self->{_dbh}->prepare($seen_sql);
unless (defined ($sth)) {
- dbg("bayes: backup_database: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: backup_database: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
$rc = $sth->execute($self->{_userid});
unless ($rc) {
- dbg("bayes: backup_database: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: backup_database: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1399,7 +1399,7 @@
my ($self, $filename, $showdots) = @_;
if (!open(DUMPFILE, '<', $filename)) {
- dbg("bayes: Unable to open backup file $filename: $!");
+ dbg("bayes: unable to open backup file $filename: $!");
return 0;
}
@@ -1433,12 +1433,12 @@
$db_version = $1;
}
else {
- dbg("bayes: Database Version must be the first line in the backup file, correct and re-run.");
+ dbg("bayes: database version must be the first line in the backup file, correct and re-run");
return 0;
}
unless ($db_version == 2 || $db_version == 3) {
- warn("bayes: Database Version $db_version is unsupported, must be version 2 or 3.");
+ warn("bayes: database version $db_version is unsupported, must be version 2 or 3");
return 0;
}
@@ -1460,7 +1460,7 @@
$num_ham = $value;
}
else {
- dbg("bayes: restore_database: Skipping unknown line: $line");
+ dbg("bayes: restore_database: skipping unknown line: $line");
}
}
elsif ($line =~ /^t\s+/) { # token line
@@ -1475,28 +1475,28 @@
if ($spam_count < 0) {
$spam_count = 0;
- push(@warnings,'Spam Count < 0, resetting');
+ push(@warnings, 'spam count < 0, resetting');
$token_warn_p = 1;
}
if ($ham_count < 0) {
$ham_count = 0;
- push(@warnings,'Ham Count < 0, resetting');
+ push(@warnings, 'ham count < 0, resetting');
$token_warn_p = 1;
}
if ($spam_count == 0 && $ham_count == 0) {
- dbg("bayes: Token has zero spam and ham count, skipping.");
+ dbg("bayes: token has zero spam and ham count, skipping");
next;
}
if ($atime > time()) {
$atime = time();
- push(@warnings,'atime > current time, resetting');
+ push(@warnings, 'atime > current time, resetting');
$token_warn_p = 1;
}
if ($token_warn_p) {
- dbg("bayes: Token ($token) has the following warnings:\n".join("\n",@warnings));
+ dbg("bayes: token ($token) has the following warnings:\n".join("\n",@warnings));
}
if ($db_version < 3) {
@@ -1509,7 +1509,7 @@
}
unless ($self->_put_token($token, $spam_count, $ham_count, $atime)) {
- dbg("bayes: Error inserting token for line: $line");
+ dbg("bayes: error inserting token for line: $line");
$error_p = 1;
}
$token_count++;
@@ -1520,22 +1520,22 @@
my $msgid = $parsed_line[2];
unless ($flag eq 'h' || $flag eq 's') {
- dbg("bayes: Unknown seen flag ($flag) for line: $line, skipping");
+ dbg("bayes: unknown seen flag ($flag) for line: $line, skipping");
next;
}
unless ($msgid) {
- dbg("bayes: Blank msgid for line: $line, skipping");
+ dbg("bayes: blank msgid for line: $line, skipping");
next;
}
unless ($self->seen_put($msgid, $flag)) {
- dbg("bayes: Error inserting msgid in seen table for line: $line");
+ dbg("bayes: error inserting msgid in seen table for line: $line");
$error_p = 1;
}
}
else {
- dbg("bayes: Skipping unknown line: $line");
+ dbg("bayes: skipping unknown line: $line");
next;
}
}
@@ -1544,31 +1544,31 @@
print STDERR "\n" if ($showdots);
unless (defined($num_spam)) {
- dbg("bayes: Unable to find num spam, please check file.");
+ dbg("bayes: unable to find num spam, please check file");
$error_p = 1;
}
unless (defined($num_ham)) {
- dbg("bayes: Unable to find num ham, please check file.");
+ dbg("bayes: unable to find num ham, please check file");
$error_p = 1;
}
if ($error_p) {
- dbg("bayes: Error(s) while attempting to load $filename, clearing database, correct and Re-Run");
+ dbg("bayes: error(s) while attempting to load $filename, clearing database, correct and re-run");
$self->clear_database();
return 0;
}
if ($num_spam || $num_ham) {
unless ($self->nspam_nham_change($num_spam, $num_ham)) {
- dbg("bayes: Error updating num spam and num ham, clearing database.");
+ dbg("bayes: error updating num spam and num ham, clearing database");
$self->clear_database();
return 0;
}
}
- dbg("bayes: Parsed $line_count lines.");
- dbg("bayes: Created database with $token_count tokens based on $num_spam Spam Messages and $num_ham Ham Messages.");
+ dbg("bayes: parsed $line_count lines");
+ dbg("bayes: created database with $token_count tokens based on $num_spam spam messages and $num_ham ham messages");
$self->untie_db();
@@ -1629,11 +1629,11 @@
{'PrintError' => 0, 'AutoCommit' => 1});
if (!$dbh) {
- dbg("bayes: Unable to connect to database: ".DBI->errstr());
+ dbg("bayes: unable to connect to database: ".DBI->errstr());
return 0;
}
else {
- dbg("bayes: Database connection established");
+ dbg("bayes: database connection established");
}
$self->{_dbh} = $dbh;
@@ -1663,14 +1663,14 @@
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
- dbg("bayes: _get_db_version: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _get_db_version: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute();
unless ($rc) {
- dbg("bayes: _get_db_version: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _get_db_version: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1705,14 +1705,14 @@
my $sthselect = $self->{_dbh}->prepare_cached($sqlselect);
unless (defined($sthselect)) {
- dbg("bayes: _initialize_db: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _initialize_db: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sthselect->execute($self->{_username});
unless ($rc) {
- dbg("bayes: _initialize_db: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _initialize_db: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1735,7 +1735,7 @@
undef,
$self->{_username});
unless (defined($rows)) {
- dbg("bayes: _initialize_db: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _initialize_db: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1746,7 +1746,7 @@
$rc = $sthselect->execute($self->{_username});
unless ($rc) {
- dbg("bayes: _initialize_db: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _initialize_db: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1756,7 +1756,7 @@
if ($id) {
$self->{_userid} = $id;
- dbg("bayes: Using userid: ".$self->{_userid});
+ dbg("bayes: using userid: ".$self->{_userid});
return 1;
}
@@ -1805,7 +1805,7 @@
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
- dbg("bayes: _put_token: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1816,7 +1816,7 @@
$atime);
unless ($rc) {
- dbg("bayes: _put_token: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1828,7 +1828,7 @@
my $rows = $self->{_dbh}->do($sql, undef, $self->{_userid});
unless (defined($rows)) {
- dbg("bayes: _put_token: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1838,7 +1838,7 @@
$rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
- dbg("bayes: _put_token: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -1851,7 +1851,7 @@
$rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
- dbg("bayes: _put_token: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
}
@@ -1906,7 +1906,7 @@
my $rows = $self->{_dbh}->do($sql, undef, @args);
unless (defined($rows)) {
- dbg("bayes: _put_token: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
}
@@ -1936,7 +1936,7 @@
my $rows = $self->{_dbh}->do($sql, undef, @args);
unless (defined($rows)) {
- dbg("bayes: _put_token: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
}
@@ -1951,7 +1951,7 @@
my $rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
- dbg("bayes: _put_token: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
}
@@ -1984,14 +1984,14 @@
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
- dbg("bayes: _get_oldest_token_age: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _get_oldest_token_age: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
- dbg("bayes: _get_oldest_token_age: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _get_oldest_token_age: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -2026,14 +2026,14 @@
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
- dbg("bayes: _get_num_hapaxes: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _get_num_hapaxes: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
- dbg("bayes: _get_num_hapaxes: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _get_num_hapaxes: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -2070,14 +2070,14 @@
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
- dbg("bayes: _get_num_lowfreq: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _get_num_lowfreq: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
- dbg("bayes: _get_num_lowfreq: SQL Error: ".$self->{_dbh}->errstr());
+ dbg("bayes: _get_num_lowfreq: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
@@ -2088,7 +2088,7 @@
return $num_lowfreq;
}
-sub dbg { Mail::SpamAssassin::dbg (@_); }
-sub sa_die { Mail::SpamAssassin::sa_die (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
+sub sa_die { Mail::SpamAssassin::sa_die(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Sat Oct 2 14:54:53 2004
@@ -214,13 +214,13 @@
}
if ($relative && !exists $self->{scoreset}->[0]->{$rule}) {
- my $msg = "Relative score without previous setting in SpamAssassin ".
+ my $msg = "config: relative score without previous setting in ".
"configuration, skipping: $line";
if ($self->{lint_rules}) {
warn $msg."\n";
} else {
- dbg ($msg);
+ dbg($msg);
}
$self->{errors}++;
return;
@@ -242,12 +242,12 @@
}
}
else {
- my $msg = "Score configuration option without actual scores, skipping: $line";
+ my $msg = "config: score configuration option without actual scores, skipping: $line";
if ($self->{lint_rules}) {
warn $msg."\n";
} else {
- dbg ($msg);
+ dbg($msg);
}
$self->{errors}++;
return;
@@ -570,7 +570,7 @@
}
# if we get here, note the issue, then we'll fail through for an error.
- dbg("rewrite_header: ignoring $hdr, not From, Subject, or To");
+ dbg("config: rewrite_header: ignoring $hdr, not From, Subject, or To");
}
});
@@ -1969,7 +1969,7 @@
code => sub {
my ($self, $key, $value, $line) = @_;
$self->{allow_user_rules} = $value+0;
- dbg( ($self->{allow_user_rules} ? "Allowing":"Not allowing") . " user rules!");
+ dbg("config: " . ($self->{allow_user_rules} ? "allowing":"not allowing") . " user rules!");
}
});
@@ -3265,7 +3265,7 @@
my ($self, $set) = @_;
$self->{scores} = $self->{scoreset}->[$set];
$self->{scoreset_current} = $set;
- dbg("Score set $set chosen.");
+ dbg("config: score set $set chosen.");
}
sub get_score_set {
@@ -3358,7 +3358,7 @@
my @rules_to_keep = grep(/$regexp/, @all_rules);
if (@rules_to_keep == 0) {
- die "trim_rules(): All rules excluded, nothing to test.\n";
+ die "config: trim_rules: all rules excluded, nothing to test\n";
}
my @meta_tests = grep(/$regexp/, $self->get_rule_keys('meta_tests'));
@@ -3390,7 +3390,7 @@
# @tokens now only consists of sub-rules
foreach my $token (@tokens) {
- die "meta test $meta depends on itself\n" if $token eq $meta;
+ die "config: meta test $meta depends on itself\n" if $token eq $meta;
push(@rules, $token);
# If the sub-rule is a meta-test, recurse
@@ -3545,8 +3545,8 @@
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
-sub sa_die { Mail::SpamAssassin::sa_die (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
+sub sa_die { Mail::SpamAssassin::sa_die(@_); }
###########################################################################
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf/LDAP.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf/LDAP.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf/LDAP.pm Sat Oct 2 14:54:53 2004
@@ -52,7 +52,7 @@
###########################################################################
sub load_modules { # static
- dbg("LDAP: loading Net::LDAP and URI");
+ dbg("ldap: loading Net::LDAP and URI");
eval {
require Net::LDAP; # actual server connection
require URI; # parse server connection dsn
@@ -73,9 +73,9 @@
my ($self, $username) = @_;
my $url = $self->{main}->{conf}->{user_scores_dsn}; # an ldap URI
- dbg("LDAP: URL is $url");
+ dbg("ldap: URL is $url");
if(!defined($url) || $url eq '') {
- dbg ("LDAP: No URL defined; skipping LDAP");
+ dbg("ldap: No URL defined; skipping LDAP");
return;
}
@@ -88,7 +88,7 @@
};
if ($@) {
- warn "failed to load user scores from LDAP server, ignored\n";
+ warn "ldap: failed to load user scores from LDAP server, ignored\n";
}
}
@@ -103,7 +103,7 @@
my $host = $uri->host;
if (!defined($host) || $host eq '') {
- dbg("LDAP: No server specified, assuming localhost");
+ dbg("ldap: No server specified, assuming localhost");
$host = "localhost";
}
my $port = $uri->port;
@@ -114,7 +114,7 @@
my %extn = $uri->extensions; # unused
$filter =~ s/__USERNAME__/$username/g;
- dbg("LDAP: host=$host, port=$port, base='$base', attr=${attr[0]}, scope=$scope, filter='$filter'");
+ dbg("ldap: host=$host, port=$port, base='$base', attr=${attr[0]}, scope=$scope, filter='$filter'");
my $main = $self->{main};
my $ldapuser = $main->{conf}->{user_scores_ldap_username};
@@ -123,14 +123,14 @@
if(!$ldapuser) {
undef($ldapuser);
} else {
- dbg("LDAP: user='$ldapuser'");
+ dbg("ldap: user='$ldapuser'");
}
if(!$ldappass) {
undef($ldappass);
} else {
# don't log this to avoid leaking sensitive info
- # dbg("LDAP: pass='$ldappass'");
+ # dbg("ldap: pass='$ldappass'");
}
my $f_attribute = $attr[0];
@@ -152,7 +152,7 @@
foreach my $entry ($result->all_entries) {
my @v = $entry->get_value($f_attribute);
foreach my $v (@v) {
- dbg("LDAP: retrieving prefs for $username: $v");
+ dbg("ldap: retrieving prefs for $username: $v");
$conf .= $v."\n";
}
}
@@ -164,8 +164,8 @@
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
-sub sa_die { Mail::SpamAssassin::sa_die (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
+sub sa_die { Mail::SpamAssassin::sa_die(@_); }
###########################################################################
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm Sat Oct 2 14:54:53 2004
@@ -262,11 +262,11 @@
my $cond = pop @if_stack;
if ($cond->{type} eq 'if') {
- warn "unclosed 'if' in ".
+ warn "config: unclosed 'if' in ".
$self->{currentfile}.": if ".$cond->{conditional}."\n";
}
else {
- die "unknown 'if' type: ".$cond->{type}."\n";
+ die "config: unknown 'if' type: ".$cond->{type}."\n";
}
$conf->{errors}++;
@@ -326,7 +326,7 @@
#$value =~ s/^(\d+)\.(\d{1,3}).*$/sprintf "%d.%d", $1, $2/e;
if ($ver ne $value) {
- warn "configuration file \"$self->{currentfile}\" requires version ".
+ warn "config: configuration file \"$self->{currentfile}\" requires version ".
"$value of SpamAssassin, but this is code version ".
"$ver. Maybe you need to use ".
"the -C switch, or remove the old config files? ".
@@ -350,11 +350,11 @@
if ($cmd) {
if ($self->{scoresonly}) { # reading user config from spamd
if ($cmd->{is_priv} && !$conf->{allow_user_rules}) {
- dbg ("config: not parsing, 'allow_user_rules' is 0: $line");
+ dbg("config: not parsing, 'allow_user_rules' is 0: $line");
goto failed_line;
}
if ($cmd->{is_admin}) {
- dbg ("config: not parsing, administrator setting: $line");
+ dbg("config: not parsing, administrator setting: $line");
goto failed_line;
}
}
@@ -401,14 +401,13 @@
my $msg = $parse_error;
if (!$msg) {
# the default warning, if a more specific one isn't output
- $msg = "config: SpamAssassin failed to parse line, ".
- "skipping: $line";
+ $msg = "config: failed to parse line, skipping: $line";
}
if ($conf->{lint_rules}) {
warn $msg."\n";
} else {
- dbg ($msg);
+ dbg($msg);
}
$conf->{errors}++;
}
@@ -443,7 +442,8 @@
$eval .= "\"$1\" "; # note: untaints!
}
else {
- $bad++; warn "unparseable chars in 'if $value': '$token'\n";
+ $bad++;
+ warn "config: unparseable chars in 'if $value': '$token'\n";
}
}
@@ -485,18 +485,18 @@
# Check for description and score issues in lint fashion
while ( ($k,$v) = each %{$conf->{descriptions}} ) {
if (length($v) > 50) {
- warn "warning: description for $k is over 50 chars\n";
+ warn "config: warning: description for $k is over 50 chars\n";
$conf->{errors}++;
}
if (!exists $conf->{tests}->{$k}) {
- warn "warning: description exists for non-existent rule $k\n";
+ warn "config: warning: description exists for non-existent rule $k\n";
$conf->{errors}++;
}
}
while ( my($sk) = each %{$conf->{scores}} ) {
if (!exists $conf->{tests}->{$sk}) {
- warn "warning: score set for non-existent rule $sk\n";
+ warn "config: warning: score set for non-existent rule $sk\n";
$conf->{errors}++;
}
}
@@ -516,7 +516,7 @@
while ( ($k,$v) = each %{$conf->{tests}} ) {
if ($conf->{lint_rules}) {
if (length($k) > 22 && $k !~ /^__/ && $k !~ /^T_/) {
- warn "warning: rule '$k' is over 22 chars\n";
+ warn "config: warning: rule '$k' is over 22 chars\n";
$conf->{errors}++;
}
}
@@ -558,7 +558,7 @@
$cmd->{code} = \&set_template_append;
}
else {
- die "unknown conf type $type!";
+ die "config: unknown conf type $type!";
}
}
@@ -706,7 +706,7 @@
# Don't allow invalid names ...
if ($name !~ /^\w+$/) {
- warn "error: rule '$name' has invalid characters (not Alphanumeric + Underscore)\n";
+ warn "config: error: rule '$name' has invalid characters (not Alphanumeric + Underscore)\n";
$conf->{errors}++;
return;
}
@@ -752,7 +752,7 @@
return 1;
} else {
- warn "invalid regexp for rule $name: $re\n";
+ warn "config: invalid regexp for rule $name: $re\n";
$self->{conf}->{errors}++;
return 0;
}
@@ -820,15 +820,15 @@
if (!File::Spec->file_name_is_absolute ($path)) {
my ($vol, $dirs, $file) = File::Spec->splitpath ($self->{currentfile});
$path = File::Spec->catpath ($vol, $dirs, $path);
- dbg ("plugin: fixed relative path: $path");
+ dbg("plugin: fixed relative path: $path");
}
return $path;
}
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
-sub sa_die { Mail::SpamAssassin::sa_die (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
+sub sa_die { Mail::SpamAssassin::sa_die(@_); }
###########################################################################
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf/SQL.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf/SQL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf/SQL.pm Sat Oct 2 14:54:53 2004
@@ -88,7 +88,7 @@
my $dsn = $self->{main}->{conf}->{user_scores_dsn};
if(!defined($dsn) || $dsn eq '') {
- dbg ("No DSN defined; skipping sql");
+ dbg("config: no DSN defined; skipping sql");
return 1;
}
@@ -100,7 +100,7 @@
};
if ($@) {
- warn "failed to load user ($username) scores from SQL database: $@\n";
+ warn "config: failed to load user ($username) scores from SQL database: $@\n";
return 0;
}
return 1;
@@ -140,12 +140,12 @@
"$f_username = ".$dbh->quote($username).
" or $f_username = '\@GLOBAL' order by $f_username asc";
}
- dbg("Conf::SQL: executing SQL: $sql");
+ dbg("config: Conf::SQL: executing SQL: $sql");
my $sth = $dbh->prepare($sql);
if($sth) {
my $rv = $sth->execute();
if($rv) {
- dbg("retrieving prefs for $username from SQL server");
+ dbg("config: retrieving prefs for $username from SQL server");
my @row;
my $text = '';
while(@row = $sth->fetchrow_array()) {
@@ -157,16 +157,16 @@
delete $main->{conf}->{main};
}
$sth->finish();
- } else { die "SQL Error: $sql\n".$sth->errstr."\n"; }
- } else { die "SQL Error: " . $dbh->errstr . "\n"; }
+ } else { die "config: SQL error: $sql\n".$sth->errstr."\n"; }
+ } else { die "config: SQL error: " . $dbh->errstr . "\n"; }
$dbh->disconnect();
- } else { die "SQL Error: " . DBI->errstr . "\n"; }
+ } else { die "config: SQL error: " . DBI->errstr . "\n"; }
}
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
-sub sa_die { Mail::SpamAssassin::sa_die (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
+sub sa_die { Mail::SpamAssassin::sa_die(@_); }
###########################################################################
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/DBBasedAddrList.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/DBBasedAddrList.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/DBBasedAddrList.pm Sat Oct 2 14:54:53 2004
@@ -58,7 +58,7 @@
my @order = split (' ', $main->{conf}->{auto_whitelist_db_modules});
my $dbm_module = Mail::SpamAssassin::Util::first_available_module (@order);
if (!$dbm_module) {
- die "Cannot find a usable DB package from auto_whitelist_db_modules: ".
+ die "auto-whitelist: cannot find a usable DB package from auto_whitelist_db_modules: " .
$main->{conf}->{auto_whitelist_db_modules}."\n";
}
@@ -72,7 +72,7 @@
{
$self->{locked_file} = $path;
$self->{is_locked} = 1;
- dbg("Tie-ing to DB file R/W in $path");
+ dbg("auto-whitelist: tie-ing to DB file R/W in $path");
tie %{$self->{accum}},$dbm_module,$path,
O_RDWR|O_CREAT, #open rw w/lock
(oct ($main->{conf}->{auto_whitelist_file_mode}) & 0666)
@@ -80,7 +80,7 @@
} else {
$self->{is_locked} = 0;
- dbg("Tie-ing to DB file R/O in $path");
+ dbg("auto-whitelist: tie-ing to DB file R/O in $path");
tie %{$self->{accum}},$dbm_module,$path,
O_RDONLY, #open ro w/o lock
(oct ($main->{conf}->{auto_whitelist_file_mode}) & 0666)
@@ -98,17 +98,17 @@
$self->{main}->{locker}->safe_unlock ($self->{locked_file});
$self->{is_locked} = 0;
}
- die "Cannot open auto_whitelist_path $path: $!\n";
+ die "auto-whitelist: cannot open auto_whitelist_path $path: $!\n";
}
###########################################################################
sub finish {
my $self = shift;
- dbg("DB addr list: untie-ing and unlocking.");
+ dbg("auto-whitelist: DB addr list: untie-ing and unlocking");
untie %{$self->{accum}};
if ($self->{is_locked}) {
- dbg ("DB addr list: file locked, breaking lock.");
+ dbg("auto-whitelist: DB addr list: file locked, breaking lock");
$self->{main}->{locker}->safe_unlock ($self->{locked_file});
$self->{is_locked} = 0;
}
@@ -127,7 +127,7 @@
$entry->{count} = $self->{accum}->{$addr} || 0;
$entry->{totscore} = $self->{accum}->{$addr.'|totscore'} || 0;
- dbg ("auto-whitelist (db-based): $addr scores ".$entry->{count}.'/'.$entry->{totscore});
+ dbg("auto-whitelist: db-based $addr scores ".$entry->{count}.'/'.$entry->{totscore});
return $entry;
}
@@ -142,7 +142,7 @@
$entry->{count}++;
$entry->{totscore} += $score;
- dbg("add_score: New count: ".$entry->{count}.", new totscore: ".$entry->{totscore});
+ dbg("auto-whitelist: add_score: new count: ".$entry->{count}.", new totscore: ".$entry->{totscore});
$self->{accum}->{$entry->{addr}} = $entry->{count};
$self->{accum}->{$entry->{addr}.'|totscore'} = $entry->{totscore};
@@ -174,6 +174,6 @@
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm Sat Oct 2 14:54:53 2004
@@ -104,7 +104,7 @@
# only make a specific query once
if (!defined $self->{dnspending}->{$type}->{$host}->[BGSOCK]) {
- dbg("rbl: launching DNS $type query for $host in background", "rbl", -1);
+ dbg("dns: launching DNS $type query for $host in background");
$self->{rbl_launch} = time;
$self->{dnspending}->{$type}->{$host}->[BGSOCK] =
$self->{res}->bgsend($host, $type);
@@ -133,7 +133,7 @@
# only make a specific query once
if (!defined $self->{dnspending}->{$type}->{$host}->[BGSOCK]) {
- dbg("dns: launching DNS $type query for $host in background", "rbl", -1);
+ dbg("dns: launching DNS $type query for $host in background");
$self->{rbl_launch} = time;
$self->{dnspending}->{$type}->{$host}->[BGSOCK] =
$self->{res}->bgsend($host, $type);
@@ -236,7 +236,7 @@
elsif ($subtest =~ s/^sb://) {
# SB rules are not available to users
if ($self->{conf}->{user_defined_rules}->{$rule}) {
- dbg ("RBL: skipping rule '$rule': not supported when user-defined");
+ dbg("dns: skipping rule '$rule': not supported when user-defined");
next;
}
@@ -315,7 +315,7 @@
$timeout = $dynamic if ($dynamic < $timeout);
sleep 1;
}
- dbg("RBL: success for " . ($total - @left) . " of $total queries", "rbl", 0);
+ dbg("dns: success for " . ($total - @left) . " of $total queries");
# timeouts
for my $query (@left) {
my $string = '';
@@ -326,7 +326,7 @@
$string = join(",", grep defined, @{$query->[RULES]});
}
my $delay = time - $self->{rbl_launch};
- dbg("DNS: timeout for $string after $delay seconds", "rbl", 0);
+ dbg("dns: timeout for $string after $delay seconds");
undef $query->[BGSOCK];
}
# register hits
@@ -379,7 +379,7 @@
my ($self) = @_;
if ($self->{main}->{local_tests_only}) {
- dbg ("local tests only, ignoring DCCifd");
+ dbg("dcc: local tests only, ignoring dccifd");
return 0;
}
@@ -391,14 +391,14 @@
}
unless ($dccifd && -S $dccifd && -w _ && -r _ ) {
- dbg ("DCCifd is not available: no r/w dccifd socket found.");
+ dbg("dcc: dccifd is not available: no r/w dccifd socket found.");
return 0;
}
# Remember any found dccifd socket
$self->{conf}->{dcc_dccifd_path} = $dccifd;
- dbg ("DCCifd is available: ".$self->{conf}->{dcc_dccifd_path});
+ dbg("dcc: dccifd is available: ".$self->{conf}->{dcc_dccifd_path});
return 1;
}
@@ -406,7 +406,7 @@
my ($self) = @_;
if ($self->{main}->{local_tests_only}) {
- dbg ("local tests only, ignoring DCC");
+ dbg("dcc: local tests only, ignoring DCC");
return 0;
}
if (!$self->{conf}->{use_dcc}) { return 0; }
@@ -422,14 +422,14 @@
}
unless ($dccproc && -x $dccproc) {
- dbg ("DCC is not available: no executable dccproc found.");
+ dbg("dcc: DCC is not available: no executable dccproc found.");
return 0;
}
# Remember any found dccproc
$self->{conf}->{dcc_path} = $dccproc;
- dbg ("DCC is available: ".$self->{conf}->{dcc_path});
+ dbg("dcc: DCC is available: ".$self->{conf}->{dcc_path});
return 1;
}
@@ -447,23 +447,23 @@
$count{fuz2} = 0;
if ($self->{main}->{local_tests_only}) {
- dbg ("local tests only, ignoring DCCifd");
+ dbg("dcc: local tests only, ignoring dccifd");
return 0;
}
if ($$fulltext eq '') {
- dbg ("empty message, ignoring DCCifd");
+ dbg("dcc: empty message, ignoring dccifd");
return 0;
}
if ( ! $self->{conf}->{dcc_home} ) {
- dbg ("dcc_home not defined, should not get here");
+ dbg("dcc: dcc_home not defined, should not get here");
return 0;
}
$sockpath = $self->{conf}->{dcc_dccifd_path};
if ( ! -S $sockpath || ! -w _ || ! -r _ ) {
- dbg ("dccifd not a socket, should not get here");
+ dbg("dcc: dccifd not a socket, should not get here");
return 0;
}
@@ -475,26 +475,26 @@
alarm($timeout);
my $sock = IO::Socket::UNIX->new(Type => SOCK_STREAM,
- Peer => $sockpath) || dbg("failed to open socket") && die;
+ Peer => $sockpath) || dbg("dcc: failed to open socket") && die;
# send the options and other parameters to the daemon
- $sock->print("header\n") || dbg("failed write") && die; # options
- $sock->print("0.0.0.0\n") || dbg("failed write") && die; #client
- $sock->print("\n") || dbg("failed write") && die; #HELO value
- $sock->print("\n") || dbg("failed write") && die; #sender
- $sock->print("unknown\r\n") || dbg("failed write") && die; # recipients
- $sock->print("\n") || dbg("failed write") && die; # recipients
+ $sock->print("header\n") || dbg("dcc: failed write") && die; # options
+ $sock->print("0.0.0.0\n") || dbg("dcc: failed write") && die; #client
+ $sock->print("\n") || dbg("dcc: failed write") && die; #HELO value
+ $sock->print("\n") || dbg("dcc: failed write") && die; #sender
+ $sock->print("unknown\r\n") || dbg("dcc: failed write") && die; # recipients
+ $sock->print("\n") || dbg("dcc: failed write") && die; # recipients
$sock->print($$fulltext);
- $sock->shutdown(1) || dbg("failed socket shutdown: $!") && die;
+ $sock->shutdown(1) || dbg("dcc: failed socket shutdown: $!") && die;
- $sock->getline() || dbg("failed read status") && die;
- $sock->getline() || dbg("failed read multistatus") && die;
+ $sock->getline() || dbg("dcc: failed read status") && die;
+ $sock->getline() || dbg("dcc: failed read multistatus") && die;
my @null = $sock->getlines();
if ( $#null == -1 ) {
- dbg("failed read header");
+ dbg("dcc: failed read header");
die;
}
@@ -507,7 +507,7 @@
$response .= $v;
}
- dbg("DCCifd: got response: $response");
+ dbg("dcc: dccifd got response: $response");
};
alarm(0); # if we die'd above, need to reset here
@@ -516,16 +516,16 @@
if ($@) {
$response = undef;
if ($@ =~ /alarm/) {
- dbg ("DCCifd check timed out after $timeout secs.");
+ dbg("dcc: dccifd check timed out after $timeout secs.");
return 0;
} else {
- warn ("DCCifd -> check skipped: $! $@");
+ warn("dcc: dccifd -> check skipped: $! $@");
return 0;
}
}
if (!defined $response || $response !~ /^X-DCC/) {
- dbg ("DCCifd -> check failed - no X-DCC returned: $response");
+ dbg("dcc: dccifd check failed - no X-DCC returned: $response");
return 0;
}
@@ -548,7 +548,7 @@
}
if ($count{body} >= $self->{conf}->{dcc_body_max} || $count{fuz1} >= $self->{conf}->{dcc_fuz1_max} || $count{fuz2} >= $self->{conf}->{dcc_fuz2_max}) {
- dbg ("DCCifd: Listed! BODY: $count{body} of $self->{conf}->{dcc_body_max} FUZ1: $count{fuz1} of $self->{conf}->{dcc_fuz1_max} FUZ2: $count{fuz2} of $self->{conf}->{dcc_fuz2_max}");
+ dbg("dcc: listed! BODY: $count{body} of $self->{conf}->{dcc_body_max} FUZ1: $count{fuz1} of $self->{conf}->{dcc_fuz1_max} FUZ2: $count{fuz2} of $self->{conf}->{dcc_fuz2_max}");
return 1;
}
@@ -566,7 +566,7 @@
$count{fuz2} = 0;
if ($self->{main}->{local_tests_only}) {
- dbg ("local tests only, ignoring DCC");
+ dbg("dcc: local tests only, ignoring DCC");
return 0;
}
if (!$self->{conf}->{use_dcc}) { return 0; }
@@ -591,7 +591,7 @@
$opts = $1;
}
- dbg("DCC command: ".join(' ', $path, "-H", $opts, "< '$tmpf'", "2>&1"),'dcc',-1);
+ dbg("dcc: command: ".join(' ', $path, "-H", $opts, "< '$tmpf'", "2>&1"));
# my $pid = open(DCC, join(' ', $path, "-H", $opts, "< '$tmpf'", "2>&1", '|')) || die "$!\n";
my $pid = Mail::SpamAssassin::Util::helper_app_pipe_open(*DCC,
@@ -602,7 +602,7 @@
close DCC;
if ( $#null == -1 ) {
- dbg("failed read header");
+ dbg("dcc: failed read header");
die;
}
@@ -616,10 +616,10 @@
}
unless (defined($response)) {
- die ("no response\n"); # yes, this is possible
+ die("dcc: no response\n"); # yes, this is possible
}
- dbg("DCC: got response: $response");
+ dbg("dcc: got response: $response");
alarm(0);
$self->cleanup_kids($pid);
@@ -630,19 +630,19 @@
if ($@) {
if ($@ =~ /^__alarm__$/) {
- dbg ("DCC -> check timed out after $timeout secs.");
+ dbg("dcc: check timed out after $timeout secs.");
} elsif ($@ =~ /^__brokenpipe__$/) {
- dbg ("DCC -> check failed: Broken pipe.");
+ dbg("dcc: check failed: broken pipe");
} elsif ($@ eq "no response\n") {
- dbg ("DCC -> check failed: no response");
+ dbg("dcc: check failed: no response");
} else {
- warn ("DCC -> check failed: $@\n");
+ warn("dcc: check failed: $@\n");
}
return 0;
}
if (!defined($response) || $response !~ /^X-DCC/) {
- dbg ("DCC -> check failed: no X-DCC returned (did you create a map file?): $response");
+ dbg("dcc: check failed: no X-DCC returned (did you create a map file?): $response");
return 0;
}
@@ -665,7 +665,7 @@
}
if ($count{body} >= $self->{conf}->{dcc_body_max} || $count{fuz1} >= $self->{conf}->{dcc_fuz1_max} || $count{fuz2} >= $self->{conf}->{dcc_fuz2_max}) {
- dbg ("DCC: Listed! BODY: $count{body} of $self->{conf}->{dcc_body_max} FUZ1: $count{fuz1} of $self->{conf}->{dcc_fuz1_max} FUZ2: $count{fuz2} of $self->{conf}->{dcc_fuz2_max}");
+ dbg("dcc: listed! BODY: $count{body} of $self->{conf}->{dcc_body_max} FUZ1: $count{fuz1} of $self->{conf}->{dcc_fuz1_max} FUZ2: $count{fuz2} of $self->{conf}->{dcc_fuz2_max}");
return 1;
}
@@ -676,7 +676,7 @@
my ($self) = @_;
if ($self->{main}->{local_tests_only}) {
- dbg ("local tests only, ignoring Pyzor");
+ dbg("pyzor: local tests only, ignoring Pyzor");
return 0;
}
if (!$self->{conf}->{use_pyzor}) { return 0; }
@@ -687,11 +687,11 @@
if ($pyzor) { $self->{conf}->{pyzor_path} = $pyzor; }
}
unless ($pyzor && -x $pyzor) {
- dbg ("Pyzor is not available: pyzor not found");
+ dbg("pyzor: not available: pyzor not found");
return 0;
}
- dbg ("Pyzor is available: ".$self->{conf}->{pyzor_path});
+ dbg("pyzor: available: ".$self->{conf}->{pyzor_path});
return 1;
}
@@ -706,7 +706,7 @@
$pyzor_whitelisted = 0;
if ($self->{main}->{local_tests_only}) {
- dbg ("local tests only, ignoring Pyzor");
+ dbg("pyzor: local tests only, ignoring Pyzor");
return 0;
}
if (!$self->{conf}->{use_pyzor}) { return 0; }
@@ -729,7 +729,7 @@
my $opts = $self->{conf}->{pyzor_options};
$opts =~ s/[^-A-Za-z0-9 \/_]/_/gs; # sanitise
- dbg("Pyzor command: ".join(' ', $path, $opts, "check", "< '$tmpf'", "2>&1"),'pyzor',-1);
+ dbg("pyzor: command: ".join(' ', $path, $opts, "check", "< '$tmpf'", "2>&1"));
#my $pid = open(PYZOR, join(' ', $path, $opts, "check", "< '$tmpf'", "2>&1", '|')) || die "$!\n";
my $pid = Mail::SpamAssassin::Util::helper_app_pipe_open(*PYZOR,
@@ -740,13 +740,13 @@
close PYZOR;
unless (@response) {
- die ("no response\n"); # yes, this is possible
+ die("pyzor: no response\n"); # yes, this is possible
}
map { chomp } @response;
- dbg("Pyzor: got response: " . join("\\n", @response));
+ dbg("pyzor: got response: " . join("\\n", @response));
if ($response[0] =~ /^Traceback/) {
- die ("internal error\n");
+ die("pyzor: internal error\n");
}
alarm(0);
@@ -759,13 +759,13 @@
if ($@) {
chomp $@;
if ($@ eq "__alarm__") {
- dbg ("Pyzor -> check timed out after $timeout secs.");
+ dbg("pyzor: check timed out after $timeout secs.");
} elsif ($@ eq "__brokenpipe__") {
- dbg ("Pyzor -> check failed: Broken pipe.");
+ dbg("pyzor: check failed: broken pipe");
} elsif ($@ eq "no response") {
- dbg ("Pyzor -> check failed: no response");
+ dbg("pyzor: check failed: no response");
} else {
- warn ("Pyzor -> check failed: $@\n");
+ warn("pyzor: check failed: $@\n");
}
return 0;
}
@@ -779,7 +779,7 @@
} else {
# warn on failures to parse (jm)
- dbg ("Pyzor: couldn't grok response \"$response[0]\"");
+ dbg("pyzor: failure to parse response \"$response[0]\"");
}
# moved this around a bit; no point in testing RE twice (jm)
@@ -790,7 +790,7 @@
}
if ($pyzor_count >= $self->{conf}->{pyzor_max}) {
- dbg ("Pyzor: Listed! $pyzor_count of $self->{conf}->{pyzor_max} and whitelist is $pyzor_whitelisted");
+ dbg("pyzor: listed! $pyzor_count of $self->{conf}->{pyzor_max} and whitelist is $pyzor_whitelisted");
return 1;
}
@@ -821,12 +821,12 @@
$self->{res}->persistent_udp(1);
}
1;
- }; # or warn "eval failed: $@ $!\n";
+ }; # or warn "dns: eval failed: $@ $!\n";
- dbg ("is Net::DNS::Resolver available? " .
+ dbg("dns: is Net::DNS::Resolver available? " .
($self->{no_resolver} ? "no" : "yes"));
if (!$self->{no_resolver} && defined $Net::DNS::VERSION) {
- dbg("Net::DNS version: ".$Net::DNS::VERSION);
+ dbg("dns: Net::DNS version: ".$Net::DNS::VERSION);
}
return (!$self->{no_resolver});
@@ -839,7 +839,7 @@
return if ($self->server_failed_to_respond_for_domain ($dom));
my $nsrecords;
- dbg ("looking up NS for '$dom'");
+ dbg("dns: looking up NS for '$dom'");
if (exists $self->{dnscache}->{NS}->{$dom}) {
$nsrecords = $self->{dnscache}->{NS}->{$dom};
@@ -856,7 +856,7 @@
$nsrecords = $self->{dnscache}->{NS}->{$dom} = [ @nses ];
};
if ($@) {
- dbg ("NS lookup failed horribly, perhaps bad resolv.conf setting?");
+ dbg("dns: NS lookup failed horribly, perhaps bad resolv.conf setting?");
return undef;
}
}
@@ -871,7 +871,7 @@
return if ($self->server_failed_to_respond_for_domain ($dom));
my $mxrecords;
- dbg ("looking up MX for '$dom'");
+ dbg("dns: looking up MX for '$dom'");
if (exists $self->{dnscache}->{MX}->{$dom}) {
$mxrecords = $self->{dnscache}->{MX}->{$dom};
@@ -886,7 +886,7 @@
$mxrecords = $self->{dnscache}->{MX}->{$dom} = [ @ips ];
};
if ($@) {
- dbg ("MX lookup failed horribly, perhaps bad resolv.conf setting?");
+ dbg("dns: MX lookup failed horribly, perhaps bad resolv.conf setting?");
return undef;
}
}
@@ -902,7 +902,7 @@
if (!defined $recs) { return undef; }
if (scalar @{$recs}) { $ret = 1; }
- dbg ("MX for '$dom' exists? $ret");
+ dbg("dns: MX for '$dom' exists? $ret");
return $ret;
}
@@ -911,20 +911,20 @@
return undef unless $self->load_resolver();
if ($self->{main}->{local_tests_only}) {
- dbg ("local tests only, not looking up PTR");
+ dbg("dns: local tests only, not looking up PTR");
return undef;
}
my $IP_IN_RESERVED_RANGE = IP_IN_RESERVED_RANGE;
if ($dom =~ /${IP_IN_RESERVED_RANGE}/) {
- dbg ("IP is reserved, not looking up PTR: $dom");
+ dbg("dns: IP is reserved, not looking up PTR: $dom");
return undef;
}
return if ($self->server_failed_to_respond_for_domain ($dom));
- dbg ("looking up PTR record for '$dom'");
+ dbg("dns: looking up PTR record for '$dom'");
my $name = '';
if (exists $self->{dnscache}->{PTR}->{$dom}) {
@@ -945,11 +945,11 @@
};
if ($@) {
- dbg ("PTR lookup failed horribly, perhaps bad resolv.conf setting?");
+ dbg("dns: PTR lookup failed horribly, perhaps bad resolv.conf setting?");
return undef;
}
}
- dbg ("PTR for '$dom': '$name'");
+ dbg("dns: PTR for '$dom': '$name'");
# note: undef is never returned, unless DNS is unavailable.
return $name;
@@ -960,13 +960,13 @@
return undef unless $self->load_resolver();
if ($self->{main}->{local_tests_only}) {
- dbg ("local tests only, not looking up A records");
+ dbg("dns: local tests only, not looking up A records");
return undef;
}
return if ($self->server_failed_to_respond_for_domain ($name));
- dbg ("looking up A records for '$name'");
+ dbg("dns: looking up A records for '$name'");
my @addrs = ();
if (exists $self->{dnscache}->{A}->{$name}) {
@@ -987,12 +987,12 @@
};
if ($@) {
- dbg ("A lookup failed horribly, perhaps bad resolv.conf setting?");
+ dbg("dns: A lookup failed horribly, perhaps bad resolv.conf setting?");
return undef;
}
}
- dbg ("A records for '$name': ".join (' ', @addrs));
+ dbg("dns: A records for '$name': ".join (' ', @addrs));
return @addrs;
}
@@ -1005,7 +1005,7 @@
$IS_DNS_AVAILABLE = 0;
if ($dnsopt eq "no") {
- dbg ("dns_available set to no in config file, skipping test", "dnsavailable", -1);
+ dbg("dns: dns_available set to no in config file, skipping test");
return $IS_DNS_AVAILABLE;
}
@@ -1015,7 +1015,7 @@
if ($dnsopt eq "yes") {
$IS_DNS_AVAILABLE = 1;
- dbg ("dns_available set to yes in config file, skipping test", "dnsavailable", -1);
+ dbg("dns: dns_available set to yes in config file, skipping test");
return $IS_DNS_AVAILABLE;
}
@@ -1023,15 +1023,13 @@
if (defined $Net::DNS::VERSION) {
if (Mail::SpamAssassin::Util::am_running_on_windows()) {
if ($Net::DNS::VERSION < 0.46) {
- dbg("Net::DNS version is $Net::DNS::VERSION, but need 0.46 for Win32",
- "dnsavailable", -1);
+ dbg("dns: Net::DNS version is $Net::DNS::VERSION, but need 0.46 for Win32");
return $IS_DNS_AVAILABLE;
}
}
else {
if ($Net::DNS::VERSION < 0.34) {
- dbg("Net::DNS version is $Net::DNS::VERSION, but need 0.34",
- "dnsavailable", -1);
+ dbg("dns: Net::DNS version is $Net::DNS::VERSION, but need 0.34");
return $IS_DNS_AVAILABLE;
}
}
@@ -1041,9 +1039,9 @@
if ($dnsopt =~ /test:\s+(.+)$/) {
my $servers=$1;
- dbg("servers: $servers");
+ dbg("dns: servers: $servers");
@domains = split (/\s+/, $servers);
- dbg("Looking up NS records for user specified servers: ".join(", ", @domains), "dnsavailable", -1);
+ dbg("dns: looking up NS records for user specified servers: ".join(", ", @domains));
} else {
@domains = @EXISTING_DOMAINS;
}
@@ -1053,27 +1051,27 @@
# simply fallen out ;)
for(my $retry = 3; $retry > 0 and $#domains>-1; $retry--) {
my $domain = splice(@domains, rand(@domains), 1);
- dbg ("trying ($retry) $domain...", "dnsavailable", -2);
+ dbg("dns: trying ($retry) $domain...");
my $result = $self->lookup_ns($domain);
if(defined $result && scalar @$result > 0) {
if ( $result ) {
- dbg ("NS lookup of $domain succeeded => Dns available (set dns_available to hardcode)", "dnsavailable", -1);
+ dbg("dns: NS lookup of $domain succeeded => Dns available (set dns_available to hardcode)");
$IS_DNS_AVAILABLE = 1;
last;
}
}
else {
- dbg ("NS lookup of $domain failed horribly => Perhaps your resolv.conf isn't pointing at a valid server?", "dnsavailable", -1);
+ dbg("dns: NS lookup of $domain failed horribly, your resolv.conf may not be pointing at a valid server");
$IS_DNS_AVAILABLE = 0; # should already be 0, but let's be sure.
last;
}
}
- dbg ("All NS queries failed => DNS unavailable (set dns_available to override)", "dnsavailable", -1) if ($IS_DNS_AVAILABLE == 0);
+ dbg("dns: all NS queries failed => DNS unavailable (set dns_available to override)") if ($IS_DNS_AVAILABLE == 0);
done:
# jm: leaving this in!
- dbg ("is DNS available? $IS_DNS_AVAILABLE");
+ dbg("dns: is DNS available? $IS_DNS_AVAILABLE");
return $IS_DNS_AVAILABLE;
}
@@ -1082,7 +1080,7 @@
sub server_failed_to_respond_for_domain {
my ($self, $dom) = @_;
if ($self->{dns_server_too_slow}->{$dom}) {
- dbg ("DNS: server for '$dom' failed to reply previously, not asking again");
+ dbg("dns: server for '$dom' failed to reply previously, not asking again");
return 1;
}
return 0;
@@ -1090,7 +1088,7 @@
sub set_server_failed_to_respond_for_domain {
my ($self, $dom) = @_;
- dbg ("DNS: server for '$dom' failed to reply, marking as bad");
+ dbg("dns: server for '$dom' failed to reply, marking as bad");
$self->{dns_server_too_slow}->{$dom} = 1;
}
@@ -1099,7 +1097,7 @@
sub enter_helper_run_mode {
my ($self) = @_;
- dbg ("entering helper-app run mode");
+ dbg("info: entering helper-app run mode");
$self->{old_slash} = $/; # Razor pollutes this
%{$self->{old_env}} = ();
if ( defined %ENV ) {
@@ -1128,7 +1126,7 @@
sub leave_helper_run_mode {
my ($self) = @_;
- dbg ("leaving helper-app run mode");
+ dbg("info: leaving helper-app run mode");
$/ = $self->{old_slash};
%ENV = %{$self->{old_env}};
}
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm Sat Oct 2 14:54:53 2004
@@ -249,7 +249,7 @@
my $hlo = $helo[$i];
my $by = $by[$i];
- dbg ("forged-HELO: from=".(defined $frm ? $frm : "(undef)").
+ dbg("eval: forged-HELO: from=".(defined $frm ? $frm : "(undef)").
" helo=".(defined $hlo ? $hlo : "(undef)").
" by=".(defined $by ? $by : "(undef)"));
@@ -263,7 +263,7 @@
&& $frm =~ /^\w+(?:[\w.-]+\.)+\w+$/
&& $frm ne $hlo && !helo_forgery_whitelisted($frm, $hlo))
{
- dbg ("forged-HELO: mismatch on HELO: '$hlo' != '$frm'");
+ dbg("eval: forged-HELO: mismatch on HELO: '$hlo' != '$frm'");
$self->{mismatch_helo}++;
}
@@ -282,7 +282,7 @@
$hclassb ne $fclassb &&
!($hlo =~ /$IP_IN_RESERVED_RANGE/o))
{
- dbg ("forged-HELO: massive mismatch on IP-addr HELO: '$hlo' != '$fip'");
+ dbg("eval: forged-HELO: massive mismatch on IP-addr HELO: '$hlo' != '$fip'");
$self->{mismatch_ip_helo}++;
}
}
@@ -293,7 +293,7 @@
&& $prev =~ /^\w+(?:[\w.-]+\.)+\w+$/
&& $by ne $prev && !helo_forgery_whitelisted($by, $prev))
{
- dbg ("forged-HELO: mismatch on from: '$prev' != '$by'");
+ dbg("eval: forged-HELO: mismatch on from: '$prev' != '$by'");
$self->{mismatch_from}++;
}
}
@@ -675,7 +675,7 @@
# ok, let's catch the case where there's *no* reverse DNS there either
if ($no_rdns) {
- dbg ("Received: no rDNS for dotcom HELO: from=$from_host HELO=$helo_host");
+ dbg("eval: Received: no rDNS for dotcom HELO: from=$from_host HELO=$helo_host");
$self->{no_rdns_dotcom_helo} = 1;
}
}
@@ -773,7 +773,7 @@
sub check_from_in_list {
my ($self,$list) = @_;
my $list_ref = $self->{conf}{$list};
- warn "Could not find list $list" unless defined $list_ref;
+ warn "eval: could not find list $list" unless defined $list_ref;
foreach my $addr (all_from_addrs $self) {
return 1 if _check_whitelist $self $list_ref, $addr;
@@ -787,7 +787,7 @@
sub check_to_in_list {
my ($self,$list) = @_;
my $list_ref = $self->{conf}{$list};
- warn "Could not find list $list" unless defined $list_ref;
+ warn "eval: could not find list $list" unless defined $list_ref;
foreach my $addr (all_to_addrs $self) {
return 1 if _check_whitelist $self $list_ref, $addr;
@@ -902,7 +902,7 @@
my $meanscore = $whitelist->check_address($_, $origip);
my $delta = 0;
- dbg("AWL active, pre-score: $self->{score}, autolearn score: $awlpoints, ".
+ dbg("auto-whitelist: AWL active, pre-score: $self->{score}, autolearn score: $awlpoints, ".
"mean: ". ($meanscore || 'undef') .", IP: ". ($origip || 'undef'));
if (defined ($meanscore)) {
@@ -933,12 +933,12 @@
};
if (!$evalok) {
- dbg ("open of AWL file failed: $@");
+ dbg("auto-whitelist: open of auto-whitelist file failed: $@");
# try an unlock, in case we got that far
eval { $whitelist->finish(); };
}
- dbg("Post AWL score: ".$self->{score});
+ dbg("auto-whitelist: post auto-whitelist score: ".$self->{score});
# test hit is above
return 0;
@@ -1044,7 +1044,7 @@
my %addrs = map { $_ => 1 } @addrs;
@addrs = keys %addrs;
- dbg("all '*From' addrs: " . join(" ", @addrs));
+ dbg("eval: all '*From' addrs: " . join(" ", @addrs));
$self->{all_from_addrs} = \@addrs;
return @addrs;
}
@@ -1098,7 +1098,7 @@
# noted some in <http://www.ii.com/internet/robots/procmail/qs/#envelope>
}
- dbg("all '*To' addrs: " . join(" ", @addrs));
+ dbg("eval: all '*To' addrs: " . join(" ", @addrs));
$self->{all_to_addrs} = \@addrs;
return @addrs;
@@ -1231,7 +1231,7 @@
return 0 unless $self->is_dns_available();
$self->load_resolver();
- dbg ("checking RBL $rbl_server, set $set", "rbl", -1);
+ dbg("dns: checking RBL $rbl_server, set $set");
# ok, make a list of all the IPs in the untrusted set
my @fullips = map { $_->{ip} } @{$self->{relays_untrusted}};
@@ -1264,9 +1264,9 @@
# relays, so we can return right now.
return 0 unless (scalar @ips + scalar @originating > 0);
- dbg("rbl: IPs found: full-external: ".join(", ", @fullips).
+ dbg("dns: IPs found: full-external: ".join(", ", @fullips).
" untrusted: ".join(", ", @ips).
- " originating: ".join(", ", @originating), "rbl", -3);
+ " originating: ".join(", ", @originating));
if (scalar @ips + scalar @originating > 0) {
# If name is foo-notfirsthop, check all addresses except for
@@ -1310,7 +1310,7 @@
}
}
}
- dbg("rbl: only inspecting the following IPs: ".join(", ", @ips), "rbl", -3);
+ dbg("dns: only inspecting the following IPs: ".join(", ", @ips));
eval {
foreach my $ip (@ips) {
@@ -1347,7 +1347,7 @@
# backward compatibility
sub check_rbl_results_for {
- #warn "check_rbl_results_for() is deprecated, use check_rbl_sub()\n";
+ #warn "dns: check_rbl_results_for() is deprecated, use check_rbl_sub()\n";
check_rbl_sub(@_);
}
@@ -1433,7 +1433,7 @@
return 0;
}
- dbg ("checking A and MX for host $host", "rbl", -1);
+ dbg("dns: checking A and MX for host $host");
$self->do_dns_lookup($rule, 'A', $host);
$self->do_dns_lookup($rule, 'MX', $host);
@@ -1556,12 +1556,12 @@
my $filename = $self->{main}->first_existing_path (@default_triplets_path);
if (!defined $filename) {
- dbg("failed to locate the triplets.txt file");
+ dbg("eval: failed to locate the triplets.txt file");
return 1;
}
if (!open (TRIPLETS, "<$filename")) {
- dbg ("failed to open '$filename', cannot check dictionary");
+ dbg("eval: failed to open '$filename', cannot check dictionary");
return 1;
}
@@ -1580,7 +1580,7 @@
for ($i = 0; $i < ($word_len - 2); $i++) {
my $triplet = substr($word, $i, 3);
if (!$triplets{$triplet}) {
- dbg ("Unique ID: Letter triplet '$triplet' from word '$word' not valid");
+ dbg("eval: unique ID: letter triplet '$triplet' from word '$word' not valid");
return 0;
}
} # for ($i = 0; $i < ($word_len - 2); $i++)
@@ -1784,22 +1784,22 @@
my $revdns = $self->lookup_ptr ($relayerip);
if (!defined $revdns) { $revdns = '(unknown)'; }
- dbg ("round-the-world: mail relayed through $relay by ".
+ dbg("eval: round-the-world: mail relayed through $relay by ".
"$relayerip (HELO $relayer, rev DNS says $revdns)");
if ($revdns =~ /\.${ROUND_THE_WORLD_RELAYERS}$/oi) {
- dbg ("round-the-world: yep, I think so (from rev dns)");
+ dbg("eval: round-the-world: yep, I think so (from rev dns)");
$self->{round_the_world_revdns} = 1;
return;
}
if ($relayer =~ /\.${ROUND_THE_WORLD_RELAYERS}$/oi) {
- dbg ("round-the-world: yep, I think so (from HELO)");
+ dbg("eval: round-the-world: yep, I think so (from HELO)");
$self->{round_the_world_helo} = 1;
return;
}
- dbg ("round-the-world: probably not");
+ dbg("eval: round-the-world: probably not");
return;
}
@@ -1914,11 +1914,10 @@
foreach $rcvd (@local) {
if ($rcvd =~ m/(\s.?\d+ \S\S\S \d+ \d+:\d+:\d+ \S+)/) {
my $date = $1;
- dbg ("trying Received fetchmail header date for real time: $date",
- "datediff", -2);
+ dbg("eval: trying Received fetchmail header date for real time: $date");
my $time = Mail::SpamAssassin::Util::parse_rfc822_date($date);
if (defined($time) && (time() >= $time)) {
- dbg ("time_t from date=$time, rcvd=$date", "datediff", -2);
+ dbg("eval: time_t from date=$time, rcvd=$date");
push @fetchmail_times, $time;
}
}
@@ -1935,10 +1934,10 @@
foreach $rcvd (@received) {
if ($rcvd =~ m/(\s.?\d+ \S\S\S \d+ \d+:\d+:\d+ \S+)/) {
my $date = $1;
- dbg ("trying Received header date for real time: $date", "datediff", -2);
+ dbg("eval: trying Received header date for real time: $date");
my $time = Mail::SpamAssassin::Util::parse_rfc822_date($date);
if (defined($time)) {
- dbg ("time_t from date=$time, rcvd=$date", "datediff", -2);
+ dbg("eval: time_t from date=$time, rcvd=$date");
push @header_times, $time;
}
}
@@ -1947,7 +1946,7 @@
if (scalar(@header_times)) {
$self->{received_header_times} = [ @header_times ];
} else {
- dbg ("no dates found in Received headers", "datediff", -1);
+ dbg("eval: no dates found in Received headers");
}
}
@@ -1987,10 +1986,10 @@
if (scalar(@dates_poss)) { # use median
$self->{date_received} = (sort {$b <=> $a}
(@dates_poss))[int($#dates_poss/2)];
- dbg("Date chosen from message: " .
- scalar(localtime($self->{date_received})), "datediff", -2);
+ dbg("eval: date chosen from message: " .
+ scalar(localtime($self->{date_received})));
} else {
- dbg("no dates found in message", "datediff", -1);
+ dbg("eval: no dates found in message");
}
}
@@ -2800,7 +2799,7 @@
my %bad = map { $_ => 1 } qw/ REJECT ERROR DISCARD /;
$path = $self->{main}->sed_path ($path);
- dbg("Tie-ing to DB file R/O in $path");
+ dbg("accessdb: tie-ing to DB file R/O in $path");
if (tie %access,"DB_File",$path, O_RDONLY) {
my @lookfor = ();
@@ -2850,7 +2849,7 @@
my %cache = ();
foreach (@lookfor) {
next if ($cache{$_}++);
- dbg("accessdb: Looking for $_");
+ dbg("accessdb: looking for $_");
# Some systems put a null at the end of the key, most don't...
my $result = $access{$_} || $access{"$_\000"} || next;
@@ -2867,13 +2866,13 @@
}
}
- dbg("Untie-ing DB file $path");
+ dbg("accessdb: untie-ing DB file $path");
untie %access;
return $retval;
}
else {
- dbg("Cannot open accessdb $path R/O: $!");
+ dbg("accessdb: cannot open accessdb $path R/O: $!");
}
0;
}
@@ -2929,7 +2928,7 @@
if ($self->is_dns_available()) {
my $vrdns = $self->lookup_ptr ($relay->{ip});
if (defined $vrdns && $vrdns ne $claimed) {
- dbg ("rdns/helo mismatch: helo=$relay->{helo} ".
+ dbg("eval: rdns/helo mismatch: helo=$relay->{helo} ".
"claimed-rdns=$claimed true-rdns=$vrdns");
return 1;
# TODO: instead, we should set a flag and check it later for
@@ -2949,7 +2948,7 @@
}
# otherwise there *is* a mismatch
- dbg ("rdns/helo mismatch: helo=$relay->{helo} rdns=$claimed");
+ dbg("eval: rdns/helo mismatch: helo=$relay->{helo} rdns=$claimed");
return 1;
}
}
@@ -3168,7 +3167,7 @@
#
if ($type eq 'text/html') {
foreach my $w (grep(/\w/,split(/\s+/,$rnd))) {
- #dbg("HTML: $w");
+ #dbg("eval: HTML: $w");
$html{$w}++;
}
@@ -3180,7 +3179,7 @@
}
else {
foreach my $w (grep(/\w/,split(/\s+/,$rnd))) {
- #dbg("TEXT: $w");
+ #dbg("eval: TEXT: $w");
$text{$w}++;
}
}
@@ -3196,7 +3195,7 @@
delete $html{$k} if (exists $html{$k} && $html{$k}-$text{$k} < 1);
}
- #map { dbg("LEFT: $_") } keys %html;
+ #map { dbg("eval: LEFT: $_") } keys %html;
# In theory, the tokens should be the same in both text and html
# parts, so there would be 0 tokens left in the html token list, for
@@ -3205,7 +3204,7 @@
my $diff = scalar(keys %html)/$orig*100;
$self->{madiff} = $diff if ($diff > $self->{madiff});
- dbg(sprintf "madiff: left: %d, orig: %d, max-difference: %0.2f%%", scalar(keys %html), $orig, $self->{madiff});
+ dbg("eval: " . sprintf "madiff: left: %d, orig: %d, max-difference: %0.2f%%", scalar(keys %html), $orig, $self->{madiff});
}
return;
@@ -3235,7 +3234,7 @@
$_ = Mail::SpamAssassin::Util::uri_to_domain(lc($_)) || $_;
}
next if ($redir eq $dest);
- dbg("redirect: found $redir to $dest, flagging");
+ dbg("eval: redirect: found $redir to $dest, flagging");
return 1;
}
}
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Locker.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Locker.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Locker.pm Sat Oct 2 14:54:53 2004
@@ -43,21 +43,21 @@
sub safe_lock {
my ($self, $path, $max_retries) = @_;
# max_retries is optional, should default to about 30
- die "safe_lock not implemented by Locker subclass";
+ die "locker: safe_lock not implemented by Locker subclass";
}
###########################################################################
sub safe_unlock {
my ($self, $path) = @_;
- die "safe_unlock not implemented by Locker subclass";
+ die "locker: safe_unlock not implemented by Locker subclass";
}
###########################################################################
sub refresh_lock {
my ($self, $path) = @_;
- die "refresh_lock not implemented by Locker subclass";
+ die "locker: refresh_lock not implemented by Locker subclass";
}
###########################################################################
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Flock.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Flock.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Flock.pm Sat Oct 2 14:54:53 2004
@@ -56,18 +56,18 @@
if (!$fh->open ("$lock_file", O_RDWR|O_CREAT)) {
umask $umask; # just in case
- die "lock: $$ cannot create lockfile $lock_file: $!\n";
+ die "locker: safe_lock: $$ cannot create lockfile $lock_file: $!\n";
}
umask $umask; # we've created the file, so reset umask
- dbg("lock: $$ created $lock_file");
+ dbg("locker: safe_lock: $$ created $lock_file");
my $unalarmed = 0;
# use a SIGALRM-based timer -- more efficient than second-by-second
# sleeps
eval {
local $SIG{ALRM} = sub { die "alarm\n" };
- dbg("lock: $$ trying to get lock on $path with $max_retries timeout");
+ dbg("locker: safe_lock: $$ trying to get lock on $path with $max_retries timeout");
# max_retries is basically seconds! so use it for the timeout
alarm($max_retries);
@@ -76,7 +76,7 @@
if (flock ($fh, LOCK_EX)) {
alarm(0) and $unalarmed = 1; # avoid calling alarm(0) twice
- dbg("lock: $$ link to $lock_file: link ok");
+ dbg("locker: safe_lock: $$ link to $lock_file: link ok");
$is_locked = 1;
# just to be nice: let people know when it was locked
@@ -93,9 +93,9 @@
$unalarmed or alarm(0); # if we die'd above, need to reset here
if ($@) {
if ($@ =~ /alarm/) {
- dbg ("lock: $$ timed out after $max_retries secs.");
+ dbg("locker: safe_lock: $$ timed out after $max_retries seconds");
} else {
- die $@;
+ die "locker: safe_lock: $$ " . $@;
}
}
@@ -108,7 +108,7 @@
my ($self, $path) = @_;
if (!exists $self->{lock_fhs} || !defined $self->{lock_fhs}->{$path}) {
- dbg ("unlock: $$ no lock handle for $path - already unlocked?");
+ dbg("locker: safe_unlock: $$ no lock handle for $path - already unlocked?");
return;
}
@@ -118,7 +118,7 @@
flock ($fh, LOCK_UN);
$fh->close();
- dbg("unlock: $$ unlocked $path.mutex");
+ dbg("locker: safe_unlock: $$ unlocked $path.mutex");
# do NOT unlink! this would open a race, whereby:
#
@@ -144,7 +144,7 @@
return unless $path;
if (!exists $self->{lock_fhs} || !defined $self->{lock_fhs}->{$path}) {
- warn "refresh_lock: $$ no lock handle for $path\n";
+ warn "locker: refresh_lock: $$ no lock handle for $path\n";
return;
}
@@ -152,11 +152,11 @@
$fh->print ("$$\n");
$fh->flush ();
- dbg("refresh: $$ refresh $path.mutex");
+ dbg("locker: refresh_lock: $$ refresh $path.mutex");
}
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Locker/UnixNFSSafe.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Locker/UnixNFSSafe.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Locker/UnixNFSSafe.pm Sat Oct 2 14:54:53 2004
@@ -70,25 +70,25 @@
my $umask = umask 077;
if (!open(LTMP, ">$lock_tmp")) {
umask $umask; # just in case
- die "lock: $$ cannot create tmp lockfile $lock_tmp for $lock_file: $!\n";
+ die "locker: safe_lock: $$ cannot create tmp lockfile $lock_tmp for $lock_file: $!\n";
}
umask $umask;
autoflush LTMP 1;
- dbg("lock: $$ created $lock_tmp");
+ dbg("locker: safe_lock: $$ created $lock_tmp");
for (my $retries = 0; $retries < $max_retries; $retries++) {
if ($retries > 0) { $self->jittery_one_second_sleep(); }
print LTMP "$hname.$$\n";
- dbg("lock: $$ trying to get lock on $path with $retries retries");
+ dbg("locker: safe_lock: $$ trying to get lock on $path with $retries retries");
if (link($lock_tmp, $lock_file)) {
- dbg("lock: $$ link to $lock_file: link ok");
+ dbg("locker: safe_lock: $$ link to $lock_file: link ok");
$is_locked = 1;
last;
}
# link _may_ return false even if the link _is_ created
@stat = lstat($lock_tmp);
if ($stat[3] > 1) {
- dbg("lock: $$ link to $lock_file: stat ok");
+ dbg("locker: safe_lock: $$ link to $lock_file: stat ok");
$is_locked = 1;
last;
}
@@ -98,14 +98,14 @@
my $lock_age = ($#stat < 11 ? undef : $stat[10]);
if (!defined($lock_age) || ($now - $lock_age) > LOCK_MAX_AGE) {
# we got a stale lock, break it
- dbg("lock: $$ breaking stale $lock_file: age=" .
+ dbg("locker: safe_lock: $$ breaking stale $lock_file: age=" .
(defined $lock_age ? $lock_age : "undef") . " now=$now");
- unlink ($lock_file) || warn "lock: $$ unlink of lock file $lock_file failed: $!\n";
+ unlink ($lock_file) || warn "locker: safe_lock: $$ unlink of lock file $lock_file failed: $!\n";
}
}
close(LTMP);
- unlink ($lock_tmp) || warn "lock: $$ unlink of temp lock $lock_tmp failed: $!\n";
+ unlink ($lock_tmp) || warn "locker: safe_lock: $$ unlink of temp lock $lock_tmp failed: $!\n";
# record this for safe unlocking
if ($is_locked) {
@@ -127,7 +127,7 @@
my $lock_file = "$path.lock";
my $lock_tmp = $self->{lock_tmp};
if (!$lock_tmp) {
- dbg("unlock: $$ $path.lock never locked");
+ dbg("locker: safe_unlock: $$ $path.lock never locked");
return;
}
@@ -141,14 +141,14 @@
print LTMP "\n";
if (!(@stat_ourtmp = stat(LTMP)) || (scalar(@stat_ourtmp) < 11)) {
- warn "unlock: $$ failed to create lock tmpfile $lock_tmp";
+ warn "locker: safe_unlock: $$ failed to create lock tmpfile $lock_tmp";
close LTMP; unlink $lock_tmp;
return;
}
my $ourtmp_ctime = $stat_ourtmp[10]; # paranoia
if (!defined $ourtmp_ctime) {
- die "stat failed on $lock_tmp";
+ die "locker: safe_unlock: stat failed on $lock_tmp";
}
close LTMP; unlink $lock_tmp;
@@ -159,7 +159,7 @@
my $lock_ctime = $self->{lock_ctimes}->{$path};
if (!defined $lock_ctime) {
- warn "unlock: $$ no ctime recorded for $lock_file";
+ warn "locker: safe_unlock: $$ no ctime recorded for $lock_file";
return;
}
@@ -169,13 +169,13 @@
if (defined $now_ctime && $now_ctime == $lock_ctime)
{
# things are good: the ctimes match so it was our lock
- unlink ($lock_file) || warn "unlock: $$ unlink failed: $lock_file\n";
- dbg("unlock: $$ unlink $lock_file");
+ unlink ($lock_file) || warn "locker: safe_unlock: $$ unlink failed: $lock_file\n";
+ dbg("locker: safe_unlock: $$ unlink $lock_file");
if ($ourtmp_ctime >= $lock_ctime + LOCK_MAX_AGE) {
# the lock has expired, so sleep a bit; use some randomness
# to avoid race conditions.
- dbg("unlock: $$ lock expired on $lock_file expired safely; sleeping");
+ dbg("locker: safe_unlock: $$ lock expired on $lock_file expired safely; sleeping");
my $i; for ($i = 0; $i < 5; $i++) {
$self->jittery_one_second_sleep();
}
@@ -188,9 +188,9 @@
# file, warn it was stolen. If not, then our lock is expired and
# someone else has grabbed the file, so warn it was lost.
if ($ourtmp_ctime < $lock_ctime + LOCK_MAX_AGE) {
- warn "unlock: $$ lock on $lock_file was stolen";
+ warn "locker: safe_unlock: $$ lock on $lock_file was stolen";
} else {
- warn "unlock: $$ lock on $lock_file was lost due to expiry";
+ warn "locker: safe_unlock: $$ lock on $lock_file was lost due to expiry";
}
}
@@ -213,11 +213,11 @@
my $lock_ctime = ($#stat < 11 ? undef : $stat[10]);
$self->{lock_ctimes}->{$path} = $lock_ctime;
- dbg("refresh: $$ refresh $path.lock");
+ dbg("locker: refresh_lock: $$ refresh $path.lock");
}
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Win32.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Win32.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Win32.pm Sat Oct 2 14:54:53 2004
@@ -53,17 +53,17 @@
my $lock_file = "$path.lock";
if (-e $lock_file && -M $lock_file > (LOCK_MAX_AGE / 86400)) {
- dbg("lock: $$ breaking stale lock: $lock_file");
- unlink($lock_file) || warn "lock: $$ unlink of lock file $lock_file failed: $!\n";
+ dbg("locker: safe_lock $$ breaking stale lock: $lock_file");
+ unlink($lock_file) || warn "locker: safe_lock: $$ unlink of lock file $lock_file failed: $!\n";
}
for (my $retries = 0; $retries < $max_retries; $retries++) {
if ($retries > 0) {
sleep(1);
# TODO: $self->jittery_one_second_sleep();?
}
- dbg("lock: $$ trying to get lock on $path with $retries retries");
+ dbg("locker: safe_lock: $$ trying to get lock on $path with $retries retries");
if (sysopen(LOCKFILE, $lock_file, O_RDWR|O_CREAT|O_EXCL)) {
- dbg("lock: $$ link to $lock_file: sysopen ok");
+ dbg("locker: safe_lock: $$ link to $lock_file: sysopen ok");
close(LOCKFILE);
return 1;
}
@@ -73,8 +73,8 @@
if ((!defined($age) && $retries > $max_retries / 2) ||
(defined($age) && (time - $age > LOCK_MAX_AGE)))
{
- dbg("lock: $$ breaking stale lock: $lock_file");
- unlink ($lock_file) || warn "lock: $$ unlink of lock file $lock_file failed: $!\n";
+ dbg("locker: safe_lock: $$ breaking stale lock: $lock_file");
+ unlink ($lock_file) || warn "locker: safe_lock: $$ unlink of lock file $lock_file failed: $!\n";
}
}
return 0;
@@ -85,8 +85,8 @@
sub safe_unlock {
my ($self, $path) = @_;
- unlink ("$path.lock") || warn "unlock: $$ unlink failed: $path.lock\n";
- dbg("unlock: $$ unlink $path.lock");
+ unlink ("$path.lock") || warn "locker: safe_unlock: $$ unlink failed: $path.lock\n";
+ dbg("locker: safe_unlock: $$ unlink $path.lock");
}
###########################################################################
@@ -100,12 +100,12 @@
# owns it, but this shouldn't, in theory, be an issue.
utime time, time, "$path.lock";
- dbg("refresh: $$ refresh $path.lock");
+ dbg("locker: refresh_lock: $$ refresh $path.lock");
}
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm Sat Oct 2 14:54:53 2004
@@ -278,17 +278,17 @@
# If we're called when we don't need to be, then just go ahead and return.
return if (!defined $toparse);
- dbg("---- MIME PARSER START ----");
+ dbg("message: ---- MIME PARSER START ----");
# Figure out the boundary
my ($boundary);
($self->{'type'}, $boundary) = Mail::SpamAssassin::Util::parse_content_type($self->header('content-type'));
- dbg("main message type: ".$self->{'type'});
+ dbg("message: main message type: ".$self->{'type'});
# Make the tree
$self->parse_body( $self, $self, $boundary, $toparse, 1 );
- dbg("---- MIME PARSER END ----");
+ dbg("message: ---- MIME PARSER END ----");
}
=item find_parts()
@@ -460,7 +460,7 @@
sub _parse_multipart {
my($self, $msg, $_msg, $boundary, $body) = @_;
- dbg("parsing multipart, got boundary: ".(defined $boundary ? $boundary : ''));
+ dbg("message: parsing multipart, got boundary: ".(defined $boundary ? $boundary : ''));
# NOTE: The MIME boundary REs here are very specific to be mostly RFC 1521
# compliant, but also allow possible malformations to still work. Please
@@ -520,7 +520,7 @@
my($p_boundary);
($part_msg->{'type'}, $p_boundary) = Mail::SpamAssassin::Util::parse_content_type($part_msg->header('content-type'));
$p_boundary ||= $boundary;
- dbg("found part of type ".$part_msg->{'type'}.", boundary: ".(defined $p_boundary ? $p_boundary : ''));
+ dbg("message: found part of type ".$part_msg->{'type'}.", boundary: ".(defined $p_boundary ? $p_boundary : ''));
$self->parse_body( $msg, $part_msg, $p_boundary, $part_array, 0 );
# rfc 1521 says /^--boundary--$/ but MUAs have a tendancy to just
@@ -587,7 +587,7 @@
sub _parse_normal {
my ($self, $msg, $part_msg, $boundary, $body) = @_;
- dbg("parsing normal part");
+ dbg("message: parsing normal part");
$part_msg->{'type'} =
Mail::SpamAssassin::Util::parse_content_type($part_msg->header('content-type'));
@@ -685,7 +685,7 @@
$text =~ tr/ \t\n\r\x0b\xa0/ /s; # whitespace => space
$text =~ tr/\f/\n/; # form feeds => newline
- # warn "JMD $text";
+ # warn "message: $text";
my @textary = split_into_array_of_short_lines ($text);
$self->{text_rendered} = \@textary;
@@ -838,7 +838,7 @@
sub get_metadata {
my ($self, $hdr) = @_;
if (!$self->{metadata}) {
- warn "oops! get_metadata() called after finish_metadata()"; return;
+ warn "metadata: oops! get_metadata() called after finish_metadata()"; return;
}
$self->{metadata}->{strings}->{$hdr};
}
@@ -850,7 +850,7 @@
sub put_metadata {
my ($self, $hdr, $text) = @_;
if (!$self->{metadata}) {
- warn "oops! put_metadata() called after finish_metadata()"; return;
+ warn "metadata: oops! put_metadata() called after finish_metadata()"; return;
}
$self->{metadata}->{strings}->{$hdr} = $text;
}
@@ -862,7 +862,7 @@
sub delete_metadata {
my ($self, $hdr) = @_;
if (!$self->{metadata}) {
- warn "oops! delete_metadata() called after finish_metadata()"; return;
+ warn "metadata: oops! delete_metadata() called after finish_metadata()"; return;
}
delete $self->{metadata}->{strings}->{$hdr};
}
@@ -875,7 +875,7 @@
my ($self) = @_;
if (!$self->{metadata}) {
- warn "oops! get_all_metadata() called after finish_metadata()"; return;
+ warn "metadata: oops! get_all_metadata() called after finish_metadata()"; return;
}
my @ret = ();
foreach my $key (sort keys %{$self->{metadata}->{strings}}) {
@@ -939,6 +939,6 @@
# ---------------------------------------------------------------------------
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata.pm Sat Oct 2 14:54:53 2004
@@ -116,7 +116,7 @@
# need about 256 bytes for reasonably accurate match (experimentally derived)
if ($self->{languages_body_len} < 256) {
- dbg("Message too short for language analysis");
+ dbg("metadata: message too short for language analysis");
$self->{textcat_matches} = [];
return;
}
@@ -128,7 +128,7 @@
# add to metadata so Bayes gets to take a look
$self->{msg}->put_metadata ("X-Languages", $matches_str);
- dbg ("metadata: X-Languages: $matches_str");
+ dbg("metadata: X-Languages: $matches_str");
}
# ---------------------------------------------------------------------------
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm Sat Oct 2 14:54:53 2004
@@ -168,7 +168,7 @@
# if the 'from' IP addr is in a reserved net range, it's not on
# the public internet.
if ($relay->{ip_is_reserved}) {
- dbg ("received-header: 'from' ".$relay->{ip}." has reserved IP");
+ dbg("received-header: 'from' ".$relay->{ip}." has reserved IP");
$inferred_as_trusted = 1;
}
@@ -176,7 +176,7 @@
# cannot lookup hostnames. :(
# Consider the first relay trusted, and all others untrusted.
if (!$self->{dns_pms}->is_dns_available()) {
- dbg ("received-header: cannot use DNS, do not trust any hosts from here on");
+ dbg("received-header: cannot use DNS, do not trust any hosts from here on");
}
# if the 'from' IP addr shares the same class B mask (/16) as
@@ -185,7 +185,7 @@
elsif (Mail::SpamAssassin::Util::ips_match_in_16_mask
([ $relay->{ip} ], $first_by))
{
- dbg ("received-header: 'from' ".$relay->{ip}." is near to first 'by'");
+ dbg("received-header: 'from' ".$relay->{ip}." is near to first 'by'");
$inferred_as_trusted = 1;
}
@@ -210,16 +210,16 @@
next if ($ip =~ /^${LOCALHOST}$/o);
if ($ip !~ /${IP_IN_RESERVED_RANGE}/o) {
- dbg ("received-header: 'by' ".$relay->{by}." has public IP $ip");
+ dbg("received-header: 'by' ".$relay->{by}." has public IP $ip");
$found_non_rsvd = 1;
} else {
- dbg ("received-header: 'by' ".$relay->{by}." has reserved IP $ip");
+ dbg("received-header: 'by' ".$relay->{by}." has reserved IP $ip");
$found_rsvd = 1;
}
}
if ($found_rsvd && !$found_non_rsvd) {
- dbg ("received-header: 'by' ".$relay->{by}." has no public IPs");
+ dbg("received-header: 'by' ".$relay->{by}." has no public IPs");
$inferred_as_trusted = 1;
}
}
@@ -232,7 +232,7 @@
if (!$inferred_as_trusted) {
if (SLOW_TRUST_BASED_ON_HELO_MXES) {
if ($self->mx_of_helo_near_ip ($relay->{helo}, $relay->{ip})) {
- dbg ("received-header: helo $relay->{helo} is near $relay->{ip}");
+ dbg("received-header: helo $relay->{helo} is near $relay->{ip}");
$inferred_as_trusted = 1;
}
}
@@ -241,7 +241,7 @@
if (!$inferred_as_trusted) { $in_trusted = 0; }
}
- dbg ("received-header: relay ".$relay->{ip}.
+ dbg("received-header: relay ".$relay->{ip}.
" trusted? ".($in_trusted ? "yes" : "no").
" internal? ".($in_internal ? "yes" : "no"));
@@ -294,8 +294,8 @@
$self->{num_relays_trusted} = scalar (@{$self->{relays_trusted}});
$self->{num_relays_untrusted} = scalar (@{$self->{relays_untrusted}});
- dbg ("metadata: X-Spam-Relays-Trusted: ".$self->{relays_trusted_str});
- dbg ("metadata: X-Spam-Relays-Untrusted: ".$self->{relays_untrusted_str});
+ dbg("metadata: X-Spam-Relays-Trusted: ".$self->{relays_trusted_str});
+ dbg("metadata: X-Spam-Relays-Untrusted: ".$self->{relays_untrusted_str});
}
sub lookup_all_ips {
@@ -345,8 +345,9 @@
}
if ($mxes && Mail::SpamAssassin::Util::ips_match_in_24_mask ([ $ip ], [ @mxips ]))
{
- dbg ("IP address $ip is near to an MX (".join (', ', @mxips).
- ") for ".$helodom);
+ dbg("received-header: IP address $ip is near an MX (" .
+ join (", ", @mxips) .
+ ") for ".$helodom);
return 1;
}
return 0;
@@ -397,7 +398,7 @@
# from 142.169.110.122 (SquirrelMail authenticated user synapse) by
# mail.nomis80.org with HTTP; Sat, 3 Apr 2004 10:33:43 -0500 (EST)
if (/ \(SquirrelMail authenticated user /) {
- dbg ("received-header: ignored SquirrelMail injection: $_");
+ dbg("received-header: ignored SquirrelMail injection: $_");
return;
}
@@ -998,7 +999,7 @@
# returned due to it being a known-crap format, let's warn so the user can
# file a bug report or something.
- dbg ("received-header: unknown format: $_");
+ dbg("received-header: unknown format: $_");
# and skip the line entirely! We can't parse it...
return;
@@ -1009,12 +1010,12 @@
# flag handovers we couldn't get an IP address from at all
if ($ip eq '') {
- dbg ("received-header: could not parse IP address from: $_");
+ dbg("received-header: could not parse IP address from: $_");
}
$ip = Mail::SpamAssassin::Util::extract_ipv4_addr_from_string ($ip);
if (!$ip) {
- dbg ("received-header: could not parse IPv4 address, assuming IPv6");
+ dbg("received-header: could not parse IPv4 address, assuming IPv6");
return; # ignore IPv6 handovers
}
@@ -1025,7 +1026,7 @@
# for the addr.
if (0) {
if ($ip eq '127.0.0.1') {
- dbg ("received-header: ignoring localhost handover");
+ dbg("received-header: ignoring localhost handover");
return; # ignore localhost handovers
}
}
@@ -1097,7 +1098,7 @@
# e.g. "ip" comes before "helo" will still work.
#
my $asstr = "[ ip=$ip rdns=$rdns helo=$helo by=$by ident=$ident envfrom=$envfrom intl=0 id=$id ]";
- dbg ("received-header: parsed as $asstr");
+ dbg("received-header: parsed as $asstr");
$relay->{as_string} = $asstr;
my $isrsvd = ($ip =~ /${IP_IN_RESERVED_RANGE}/o);
@@ -1111,7 +1112,7 @@
# spamcop does this, and it's a great idea ;)
sub found_pop_fetcher_sig {
my ($self) = @_;
- dbg ("found fetchmail marker, restarting parse");
+ dbg("received-header: found fetchmail marker, restarting parse");
$self->{relays} = [ ];
}
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm Sat Oct 2 14:54:53 2004
@@ -231,7 +231,7 @@
sub add_body_part {
my($self, $part) = @_;
- dbg("added part, type: ".$part->{'type'});
+ dbg("message: added part, type: ".$part->{'type'});
push @{ $self->{'body_parts'} }, $part;
}
@@ -274,13 +274,13 @@
my $encoding = lc $self->header('content-transfer-encoding') || '';
if ( $encoding eq 'quoted-printable' ) {
- dbg("decoding: quoted-printable");
+ dbg("message: decoding quoted-printable");
$self->{'decoded'} = [
map { s/\r\n/\n/; $_; } split ( /^/m, Mail::SpamAssassin::Util::qp_decode( join ( "", @{$self->{'raw'}} ) ) )
];
}
elsif ( $encoding eq 'base64' ) {
- dbg("decoding: base64");
+ dbg("message: decoding base64");
# if it's not defined or is 0, do the whole thing, otherwise only decode
# a portion
@@ -300,10 +300,10 @@
else {
# Encoding is one of 7bit, 8bit, binary or x-something
if ( $encoding ) {
- dbg("decoding: other encoding type ($encoding), ignoring");
+ dbg("message: decoding other encoding type ($encoding), ignoring");
}
else {
- dbg("decoding: no encoding detected");
+ dbg("message: no encoding detected");
}
$self->{'decoded'} = $self->{'raw'};
}
@@ -511,7 +511,7 @@
return Mail::SpamAssassin::Util::qp_decode($data);
}
else {
- die "Unknown encoding type '$cte' in RFC2047 header";
+ die "message: unknown encoding type '$cte' in RFC2047 header";
}
}
@@ -671,7 +671,7 @@
# ---------------------------------------------------------------------------
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
__END__
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/NetSet.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/NetSet.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/NetSet.pm Sat Oct 2 14:54:53 2004
@@ -52,17 +52,19 @@
foreach (@nets) {
my ($ip, $bits) = m#^\s*([\d\.]+)(?:/(\d+))?\s*$#;
- my $err = "illegal network address given: '$_'\n";
+ my $err = "netset: illegal network address given: '$_'\n";
if (!defined $ip) {
- warn $err; next;
-
- } elsif ($ip =~ /\.$/) {
+ warn $err;
+ next;
+ }
+ elsif ($ip =~ /\.$/) {
# just use string matching; much simpler than doing smart stuff with arrays ;)
if ($ip =~ /^(\d+)\.(\d+)\.(\d+)\.$/) { $ip = "$1.$2.$3.0"; $bits = 24; }
elsif ($ip =~ /^(\d+)\.(\d+)\.$/) { $ip = "$1.$2.0.0"; $bits = 16; }
elsif ($ip =~ /^(\d+)\.$/) { $ip = "$1.0.0.0"; $bits = 8; }
else {
- warn $err; next;
+ warn $err;
+ next;
}
}
@@ -100,7 +102,7 @@
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
###########################################################################
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgLearner.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgLearner.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgLearner.pm Sat Oct 2 14:54:53 2004
@@ -183,7 +183,7 @@
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
###########################################################################
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Sat Oct 2 14:54:53 2004
@@ -136,7 +136,7 @@
# to do this switch if we're already using bayes ... ;)
my $set = $self->{conf}->get_score_set();
if (($set & 2) == 0 && $self->{main}->{bayes_scanner}->is_scan_available()) {
- dbg("debug: Scoreset $set but Bayes is available, switching scoresets");
+ dbg("check: scoreset $set but bayes is available, switching scoresets");
$self->{conf}->set_score_set ($set|2);
}
@@ -166,7 +166,7 @@
# happen in Conf.pm when we switch a rules from one priority to another
next unless ($self->{conf}->{priorities}->{$priority} > 0);
- dbg("Running tests for priority: $priority");
+ dbg("check: running tests for priority: $priority");
# only harvest the dnsbl queries once priority HARVEST_DNSBL_PRIORITY
# has been reached and then only run once
@@ -240,10 +240,10 @@
# add 0 to force it back to numeric representation instead of string.
$self->{score} = (sprintf "%0.3f", $self->{score}) + 0;
- dbg ("is spam? score=".$self->{score}.
+ dbg("check: is spam? score=".$self->{score}.
" required=".$self->{conf}->{required_score});
- dbg ("tests=".$self->get_names_of_tests_hit());
- dbg ("subtests=".$self->get_names_of_subtests_hit());
+ dbg("check: tests=".$self->get_names_of_tests_hit());
+ dbg("check: subtests=".$self->get_names_of_subtests_hit());
$self->{is_spam} = $self->is_spam();
$self->{main}->call_plugins ("check_end", { permsgstatus => $self });
@@ -282,7 +282,7 @@
# Find out what score we should consider this message to have ...
my $score = $self->_get_autolearn_points();
- dbg ("auto-learn? ham=$min, spam=$max, ".
+ dbg("learn: auto-learn? ham=$min, spam=$max, ".
"body-points=".$self->{body_only_points}.", ".
"head-points=".$self->{head_only_points}.", ".
"learned-points=".$self->{learned_points});
@@ -293,7 +293,7 @@
} elsif ($score >= $max) {
$isspam = 1;
} else {
- dbg ("auto-learn? no: inside auto-learn thresholds, not considered ham or spam");
+ dbg("learn: auto-learn? no: inside auto-learn thresholds, not considered ham or spam");
$self->{auto_learn_status} = "no";
return;
}
@@ -307,33 +307,33 @@
if ($self->{body_only_points} < $required_body_points) {
$self->{auto_learn_status} = "no";
- dbg ("auto-learn? no: scored as spam but too few body points (".
- $self->{body_only_points}." < ".$required_body_points.")");
+ dbg("learn: auto-learn? no: scored as spam but too few body points (".
+ $self->{body_only_points}." < ".$required_body_points.")");
return;
}
if ($self->{head_only_points} < $required_head_points) {
$self->{auto_learn_status} = "no";
- dbg ("auto-learn? no: scored as spam but too few head points (".
- $self->{head_only_points}." < ".$required_head_points.")");
+ dbg("learn: auto-learn? no: scored as spam but too few head points (".
+ $self->{head_only_points}." < ".$required_head_points.")");
return;
}
if ($self->{learned_points} < $learner_said_ham_points) {
$self->{auto_learn_status} = "no";
- dbg ("auto-learn? no: scored as spam but learner indicated ham (".
- $self->{learned_points}." < ".$learner_said_ham_points.")");
+ dbg("learn: auto-learn? no: scored as spam but learner indicated ham (".
+ $self->{learned_points}." < ".$learner_said_ham_points.")");
return;
}
} else {
if ($self->{learned_points} > $learner_said_spam_points) {
$self->{auto_learn_status} = "no";
- dbg ("auto-learn? no: scored as ham but learner indicated spam (".
- $self->{learned_points}." > ".$learner_said_spam_points.")");
+ dbg("learn: auto-learn? no: scored as ham but learner indicated spam (".
+ $self->{learned_points}." > ".$learner_said_spam_points.")");
return;
}
}
- dbg ("auto-learn? yes, ".($isspam?"spam ($score > $max)":"ham ($score < $min)"));
+ dbg("learn: auto-learn? yes, ".($isspam?"spam ($score > $max)":"ham ($score < $min)"));
$self->{main}->call_plugins ("autolearn", {
permsgstatus => $self,
@@ -354,7 +354,7 @@
};
if ($@) {
- dbg ("auto-learning failed: $@");
+ dbg("learn: auto-learning failed: $@");
$self->{auto_learn_status} = "failed";
}
}
@@ -393,11 +393,11 @@
my $scores = $self->{conf}->{scores};
if (($orig_scoreset & 2) == 0) { # we don't need to recompute
- dbg ("auto-learn: currently using scoreset $orig_scoreset.");
+ dbg("learn: auto-learn: currently using scoreset $orig_scoreset");
}
else {
$new_scoreset = $orig_scoreset & ~2;
- dbg ("auto-learn: currently using scoreset $orig_scoreset, recomputing score based on scoreset $new_scoreset.");
+ dbg("learn: auto-learn: currently using scoreset $orig_scoreset, recomputing score based on scoreset $new_scoreset");
$scores = $self->{conf}->{scoreset}->[$new_scoreset];
}
@@ -442,7 +442,7 @@
# Figure out the final value we'll use for autolearning
$points = (sprintf "%0.3f", $points) + 0;
- dbg ("auto-learn: message score: ".$self->{score}.", computed score for autolearn: $points");
+ dbg("learn: auto-learn: message score: ".$self->{score}.", computed score for autolearn: $points");
return $points;
}
@@ -925,7 +925,7 @@
$text = '=?'.$cs.'?Q?'.$text.'?=';
- dbg ("encoding header in $cs: $text");
+ dbg("markup: encoding header in $cs: $text");
return $text;
}
@@ -1439,15 +1439,12 @@
sub ran_rule_debug_code {
my ($self, $rulename, $ruletype, $bit) = @_;
- return '' if (!$Mail::SpamAssassin::DEBUG->{enabled}
- && !$self->{save_pattern_hits});
+ return '' if (!$Mail::SpamAssassin::DEBUG && !$self->{save_pattern_hits});
my $log_hits_code = '';
my $save_hits_code = '';
- if ($Mail::SpamAssassin::DEBUG->{enabled} &&
- ($Mail::SpamAssassin::DEBUG->{rulesrun} & $bit) != 0)
- {
+ if ($Mail::SpamAssassin::DEBUG) {
# note: keep this in 'single quotes' to avoid the $ & performance hit,
# unless specifically requested by the caller.
$log_hits_code = ': match=\'$&\'';
@@ -1460,16 +1457,10 @@
}
return '
- dbg ("Ran '.$ruletype.' rule '.$rulename.' ======> got hit'.
- $log_hits_code.'", "rulesrun", '.$bit.');
+ dbg("rules: ran '.$ruletype.' rule '.$rulename.' ======> got hit'.
+ $log_hits_code.'");
'.$save_hits_code.'
';
-
- # do we really need to see when we *don't* get a hit? If so, it should be a
- # separate level as it's *very* noisy.
- #} else {
- # dbg ("Ran '.$ruletype.' rule '.$rulename.' but did not get hit", "rulesrun", '.
- # $bit.');
}
sub hash_line_for_rule {
@@ -1489,7 +1480,7 @@
# eval tests need to use stuff in here.
$self->{test_log_msgs} = (); # clear test state
- dbg ("running header regexp tests; score so far=".$self->{score});
+ dbg("rules: running header regexp tests; score so far=".$self->{score});
my $doing_user_rules =
$self->{conf}->{user_rules_to_compile}->{$Mail::SpamAssassin::Conf::TYPE_HEAD_TESTS};
@@ -1516,7 +1507,7 @@
$rule =~ /^\s*(\S+)\s*(\=|\!)\~\s*(\S.*?\S)\s*$/;
if (!defined $pat) {
- warn "invalid rule: $rulename\n";
+ warn "rules: invalid rule: $rulename\n";
$self->{rule_errors}++;
next;
}
@@ -1575,7 +1566,7 @@
eval $evalstr;
if ($@) {
- warn "Failed to run header SpamAssassin tests, skipping some: $@\n";
+ warn "rules: failed to run header tests, skipping some: $@\n";
$self->{rule_errors}++;
}
else {
@@ -1589,7 +1580,7 @@
my ($self, $priority, $textary) = @_;
local ($_);
- dbg ("running body-text per-line regexp tests; score so far=".$self->{score});
+ dbg("rules: running body-text per-line regexp tests; score so far=".$self->{score});
my $doing_user_rules =
$self->{conf}->{user_rules_to_compile}->{$Mail::SpamAssassin::Conf::TYPE_BODY_TESTS};
@@ -1665,8 +1656,7 @@
# and run it.
eval $evalstr;
if ($@) {
- warn("Failed to compile body SpamAssassin tests, skipping:\n".
- "\t($@)\n");
+ warn("rules: failed to compile body tests, skipping:\n" . "\t($@)\n");
$self->{rule_errors}++;
}
else {
@@ -1790,7 +1780,7 @@
}
}
- # warn("Got URI: $uri\n");
+ # warn("uri: got URI: $uri\n");
push @uris, $uri;
}
while (/($Addr_spec_re)/go) {
@@ -1798,7 +1788,7 @@
$uri = "mailto:$uri";
- #warn("Got URI: $uri\n");
+ #warn("uri: got URI: $uri\n");
push @uris, $uri;
}
}
@@ -1822,9 +1812,9 @@
$self->{uri_list} = \@uris;
# list out the URLs for debugging ...
- if ($Mail::SpamAssassin::DEBUG->{enabled}) {
+ if ($Mail::SpamAssassin::DEBUG) {
foreach my $nuri (@uris) {
- dbg("uri found: $nuri");
+ dbg("uri: uri found: $nuri");
}
}
@@ -1835,7 +1825,7 @@
my ($self, $priority, @uris) = @_;
local ($_);
- dbg ("running uri tests; score so far=".$self->{score});
+ dbg("uri: running uri tests; score so far=".$self->{score});
my $doing_user_rules =
$self->{conf}->{user_rules_to_compile}->{$Mail::SpamAssassin::Conf::TYPE_URI_TESTS};
@@ -1910,8 +1900,7 @@
# and run it.
eval $evalstr;
if ($@) {
- warn("Failed to compile URI SpamAssassin tests, skipping:\n".
- "\t($@)\n");
+ warn("rules: failed to compile URI tests, skipping:\n" . "\t($@)\n");
$self->{rule_errors}++;
}
else {
@@ -1925,7 +1914,7 @@
my ($self, $priority, $textary) = @_;
local ($_);
- dbg ("running raw-body-text per-line regexp tests; score so far=".$self->{score});
+ dbg("rules: running raw-body-text per-line regexp tests; score so far=".$self->{score});
my $doing_user_rules =
$self->{conf}->{user_rules_to_compile}->{$Mail::SpamAssassin::Conf::TYPE_RAWBODY_TESTS};
@@ -2000,8 +1989,7 @@
# and run it.
eval $evalstr;
if ($@) {
- warn("Failed to compile body SpamAssassin tests, skipping:\n".
- "\t($@)\n");
+ warn("rules: failed to compile body tests, skipping:\n" . "\t($@)\n");
$self->{rule_errors}++;
}
else {
@@ -2015,7 +2003,7 @@
my ($self, $priority, $fullmsgref) = @_;
local ($_);
- dbg ("running full-text regexp tests; score so far=".$self->{score});
+ dbg("rules: running full-text regexp tests; score so far=".$self->{score});
my $doing_user_rules =
$self->{conf}->{user_rules_to_compile}->{$Mail::SpamAssassin::Conf::TYPE_FULL_TESTS};
@@ -2072,8 +2060,7 @@
eval $evalstr;
if ($@) {
- warn "Failed to compile full SpamAssassin tests, skipping:\n".
- "\t($@)\n";
+ warn "rules: failed to compile full tests, skipping:\n" . "\t($@)\n";
$self->{rule_errors}++;
} else {
no strict "refs";
@@ -2114,7 +2101,7 @@
my ($self, $priority) = @_;
local ($_);
- dbg( "running meta tests; score so far=" . $self->{score} );
+ dbg("rules: running meta tests; score so far=" . $self->{score} );
my $doing_user_rules =
$self->{conf}->{user_rules_to_compile}->{$Mail::SpamAssassin::Conf::TYPE_META_TESTS};
@@ -2201,8 +2188,8 @@
my %metas = map { $_ => 1 } @metas; # keep a small cache for fast lookups
foreach $rulename (@metas) {
$self->{rule_errors}++; # flag to --lint that there was an error ...
- dbg( "Excluding meta test $rulename; unsolved meta dependencies: "
- . join(", ", grep($metas{$_},@{ $rule_deps{$rulename} })));
+ dbg("rules: excluding meta test $rulename; unsolved meta dependencies: " .
+ join(", ", grep($metas{$_}, @{ $rule_deps{$rulename} })));
}
if (defined &{'_meta_tests_'.$clean_priority}) {
@@ -2232,7 +2219,7 @@
eval $evalstr;
if ($@) {
- warn "Failed to run meta SpamAssassin tests, skipping some: $@\n";
+ warn "rules: failed to run meta tests, skipping some: $@\n";
$self->{rule_errors}++;
}
else {
@@ -2248,7 +2235,7 @@
my ($self, $evalhash, $prepend2desc, @extraevalargs) = @_;
local ($_);
- my $debugenabled = $Mail::SpamAssassin::DEBUG->{enabled};
+ my $debugenabled = $Mail::SpamAssassin::DEBUG;
my $scoreset = $self->{conf}->get_score_set();
while (my ($rulename, $test) = each %{$evalhash}) {
@@ -2281,7 +2268,7 @@
# we have a plugin for this. eval its function
$self->register_plugin_eval_glue ($pluginobj, $function);
} else {
- dbg ("no method found for eval test $function");
+ dbg("rules: no method found for eval test $function");
}
}
@@ -2294,25 +2281,25 @@
};
if ($@) {
- warn "Failed to run $rulename SpamAssassin test, skipping:\n".
- "\t($@)\n";
+ warn "rules: failed to run $rulename test, skipping:\n" . "\t($@)\n";
$self->{rule_errors}++;
next;
}
if ($result) {
- $self->got_hit ($rulename, $prepend2desc);
- dbg("Ran run_eval_test rule $rulename ======> got hit", "rulesrun", 32) if $debugenabled;
- } else {
- #dbg("Ran run_eval_test rule $rulename but did not get hit", "rulesrun", 32) if $debugenabled;
+ $self->got_hit ($rulename, $prepend2desc);
+ dbg("rules: ran run_eval_test rule $rulename ======> got hit") if $debugenabled;
}
+ #else {
+ # dbg("rules: ran run_eval_test rule $rulename but did not get hit") if $debugenabled;
+ #}
}
}
sub register_plugin_eval_glue {
my ($self, $pluginobj, $function) = @_;
- dbg ("registering glue method for $function ($pluginobj)");
+ dbg("plugin: registering glue method for $function ($pluginobj)");
my $evalstr = <<"ENDOFEVAL";
{
package Mail::SpamAssassin::PerMsgStatus;
@@ -2329,7 +2316,7 @@
eval $evalstr;
if ($@) {
- warn "Failed to run header SpamAssassin tests, skipping some: $@\n";
+ warn "rules: failed to run header tests, skipping some: $@\n";
$self->{rule_errors}++;
}
}
@@ -2342,11 +2329,11 @@
local ($_);
if ($self->{main}->{local_tests_only}) {
- dbg ("local tests only, ignoring RBL eval", "rulesrun", 32);
+ dbg("rules: local tests only, ignoring RBL eval");
return 0;
}
- my $debugenabled = $Mail::SpamAssassin::DEBUG->{enabled};
+ my $debugenabled = $Mail::SpamAssassin::DEBUG;
while (my ($rulename, $test) = each %{$evalhash}) {
my $score = $self->{conf}->{scores}->{$rulename};
@@ -2362,8 +2349,7 @@
};
if ($@) {
- warn "Failed to run $rulename RBL SpamAssassin test, skipping:\n".
- "\t($@)\n";
+ warn "rules: failed to run $rulename RBL test, skipping:\n" . "\t($@)\n";
$self->{rule_errors}++;
next;
}
@@ -2511,7 +2497,7 @@
if ($self->get ("X-Sender") =~ /\@/) {
my $rcvd = join (' ', $self->get ("Received"));
if ($rcvd =~ /\(fetchmail/) {
- dbg ("X-Sender and fetchmail signatures found, cannot trust envelope-from");
+ dbg("message: X-Sender and fetchmail signatures found, cannot trust envelope-from");
return undef;
}
}
@@ -2522,7 +2508,7 @@
# heuristic: this could have been relayed via a list which then used
# a *new* Envelope-from. check
if ($self->get ("ALL") =~ /(?:^|\n)Received:\s.*\nX-Envelope-From:\s/s) {
- dbg ("X-Envelope-From header found after 1 or more Received lines, cannot trust envelope-from");
+ dbg("message: X-Envelope-From header found after 1 or more Received lines, cannot trust envelope-from");
} else {
goto ok;
}
@@ -2533,7 +2519,7 @@
# heuristic: this could have been relayed via a list which then used
# a *new* Envelope-from. check
if ($self->get ("ALL") =~ /(?:^|\n)Received:\s.*\nEnvelope-Sender:\s/s) {
- dbg ("Envelope-Sender header found after 1 or more Received lines, cannot trust envelope-from");
+ dbg("message: Envelope-Sender header found after 1 or more Received lines, cannot trust envelope-from");
} else {
goto ok;
}
@@ -2544,7 +2530,7 @@
# heuristic: this could have been relayed via a list which then used
# a *new* Envelope-from. check
if ($self->get ("ALL") =~ /(?:^|\n)Received:\s.*\nReturn-Path:\s/s) {
- dbg ("Return-Path header found after 1 or more Received lines, cannot trust envelope-from");
+ dbg("message: Return-Path header found after 1 or more Received lines, cannot trust envelope-from");
} else {
goto ok;
}
@@ -2561,8 +2547,8 @@
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
-sub sa_die { Mail::SpamAssassin::sa_die (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
+sub sa_die { Mail::SpamAssassin::sa_die(@_); }
###########################################################################
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PersistentAddrList.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PersistentAddrList.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PersistentAddrList.pm Sat Oct 2 14:54:53 2004
@@ -82,7 +82,7 @@
sub new_checker {
my ($factory, $main) = @_;
- die "unimpled base method"; # override this
+ die "auto-whitelist: unimplemented base method"; # override this
}
###########################################################################
@@ -110,7 +110,7 @@
sub get_addr_entry {
my ($self, $addr) = @_;
my $entry = { };
- die "unimpled base method"; # override this
+ die "auto-whitelist: unimplemented base method"; # override this
return $entry;
}
@@ -125,7 +125,7 @@
sub add_score {
my ($self, $entry, $score) = @_;
- die "unimpled base method"; # override this
+ die "auto-whitelist: unimplemented base method"; # override this
}
###########################################################################
@@ -138,7 +138,7 @@
sub remove_entry {
my ($self, $entry) = @_;
- die "unimpled base method"; # override this
+ die "auto-whitelist: unimplemented base method"; # override this
}
###########################################################################
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm Sat Oct 2 14:54:53 2004
@@ -481,7 +481,7 @@
$self->{_inhibit_further_callbacks} = 1;
}
-=item dbg ($message)
+=item dbg($message)
Output a debugging message C<$message>, if the SpamAssassin object is running
with debugging turned on.
@@ -493,7 +493,7 @@
=cut
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Hashcash.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Hashcash.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Hashcash.pm Sat Oct 2 14:54:53 2004
@@ -202,18 +202,18 @@
# extensions are, as yet, unused by SpamAssassin
}
else {
- dbg ("hashcash: version $ver stamps not yet supported");
+ dbg("hashcash: version $ver stamps not yet supported");
return 0;
}
if (!$trial) {
- dbg ("hashcash: no trial in stamp '$hc'");
+ dbg("hashcash: no trial in stamp '$hc'");
return 0;
}
my $accept = $scanner->{conf}->{hashcash_accept};
if (!$self->_check_hashcash_resource ($scanner, $accept, $rsrc)) {
- dbg ("hashcash: resource $rsrc not accepted here");
+ dbg("hashcash: resource $rsrc not accepted here");
return 0;
}
@@ -233,7 +233,7 @@
$value = $bits;
}
- dbg ("hashcash token value: $value");
+ dbg("hashcash: token value: $value");
if ($self->was_hashcash_token_double_spent ($scanner, $hc)) {
$scanner->{hashcash_double_spent} = 1;
@@ -249,11 +249,11 @@
my $main = $self->{main};
if (!$main->{conf}->{hashcash_doublespend_path}) {
- dbg ("hashcash_doublespend_path not defined or empty");
+ dbg("hashcash: hashcash_doublespend_path not defined or empty");
return 0;
}
if (!HAS_DB_FILE) {
- dbg ("hashcash: DB_File module not installed, cannot use double-spend db");
+ dbg("hashcash: DB_File module not installed, cannot use double-spend db");
return 0;
}
@@ -270,18 +270,18 @@
if (!tie %spenddb, "DB_File", $path, O_RDWR|O_CREAT,
(oct ($main->{conf}->{hashcash_doublespend_file_mode}) & 0666))
{
- dbg ("hashcash: failed to tie to $path: $@ $!");
+ dbg("hashcash: failed to tie to $path: $@ $!");
# not a serious error. TODO?
return 0;
}
if (exists $spenddb{$token}) {
- dbg ("hashcash: token '$token' spent already");
+ dbg("hashcash: token '$token' spent already");
return 1;
}
$spenddb{$token} = time;
- dbg ("hashcash: marking token '$token' as spent");
+ dbg("hashcash: marking token '$token' as spent");
# TODO: expiry?
@@ -315,6 +315,6 @@
############################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Razor2.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Razor2.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Razor2.pm Sat Oct 2 14:54:53 2004
@@ -47,15 +47,15 @@
$mailsaobject->{conf}->{razor2_timeout} = 10;
if ($mailsaobject->{local_tests_only}) {
- dbg ("local tests only, ignoring Razor2", "razor", -1);
+ dbg("razor2: local tests only, skipping razor2");
}
else {
if (eval { require Razor2::Client::Agent; }) {
- dbg("Razor2 is available", "razor", -1);
+ dbg("razor2: razor2 is available");
$self->{razor2_available} = 1;
}
else {
- dbg("Razor2 is not available", "razor", -1);
+ dbg("razor2: razor2 is not available");
}
}
@@ -121,7 +121,7 @@
if (!$self->{razor2_available}) { return 0; }
# razor also debugs to stdout. argh. fix it to stderr...
- if ($Mail::SpamAssassin::DEBUG->{enabled}) {
+ if ($Mail::SpamAssassin::DEBUG) {
open (OLDOUT, ">&STDOUT");
open (STDOUT, ">&STDERR");
}
@@ -139,20 +139,20 @@
if ($rc) {
my %opt = (
- debug => ($Mail::SpamAssassin::DEBUG->{enabled} and
- $Mail::SpamAssassin::DEBUG->{razor} < -2),
- foreground => 1,
- config => $self->{main}->{conf}->{razor_config}
+ debug => ($Mail::SpamAssassin::DEBUG &&
+ $Mail::SpamAssassin::facilities->{razor}),
+ foreground => 1,
+ config => $self->{main}->{conf}->{razor_config}
);
$rc->{opt} = \%opt;
- $rc->do_conf() or die $rc->errstr;
+ $rc->do_conf() or die "razor2: " . $rc->errstr;
my $tmptext = $$fulltext;
my @msg = (\$tmptext);
my $objects = $rc->prepare_objects( \@msg )
- or die "error in prepare_objects";
- $rc->get_server_info() or die $rc->errprefix("spamassassin");
+ or die "razor2: error in prepare_objects";
+ $rc->get_server_info() or die $rc->errprefix("razor2: spamassassin");
# let's reset the alarm since get_server_info() calls
# nextserver() which calls discover() which very likely will
@@ -160,7 +160,7 @@
alarm $timeout;
my $sigs = $rc->compute_sigs($objects)
- or die "error in compute_sigs";
+ or die "razor2: error in compute_sigs";
#
# if mail isn't whitelisted, check it out
@@ -169,10 +169,10 @@
if (!$rc->connect()) {
# provide a better error message when servers are unavailable,
# than "Bad file descriptor Died".
- die "could not connect to any servers\n";
+ die "razor2: could not connect to any servers\n";
}
- $rc->check($objects) or die $rc->errprefix("spamassassin");
- $rc->disconnect() or die $rc->errprefix("spamassassin");
+ $rc->check($objects) or die $rc->errprefix("razor2: spamassassin");
+ $rc->disconnect() or die $rc->errprefix("razor2: spamassassin");
# if we got here, we're done doing remote stuff, abort the alert
alarm 0;
@@ -193,7 +193,8 @@
close $rc->{logref}->{fd} if ($untie);
}
- dbg("Using results from Razor v".$Razor2::Client::Version::VERSION, "razor", -1);
+ dbg("razor2: using results from Razor version " .
+ $Razor2::Client::Version::VERSION . "\n");
# so $objects->[0] is the first (only) message, and ->{spam} is a general yes/no
$self->{razor2_result} = $objects->[0]->{spam} || 0;
@@ -219,14 +220,14 @@
my $tmpcf = $tmp->{cf} || 0; # Part confidence
my $tmpct = $tmp->{ct} || 0; # Part contested?
my $engine = $cf->{sent}->[$response]->{e};
- dbg("Found Razor2 part: part=$part engine=$engine ct=$tmpct cf=$tmpcf", "razor", -1);
+ dbg("razor2: found razor2 part: part=$part engine=$engine ct=$tmpct cf=$tmpcf");
$self->{razor2_cf_score} = $tmpcf if ( !$tmpct && $tmpcf > $self->{razor2_cf_score} );
}
}
else {
my $text = "part=$part noresponse";
$text .= " skipme=1" if ( $cf->{skipme} );
- dbg("Found Razor2 part: $text", "razor", -1);
+ dbg("razor2: found razor2 part: $text");
}
$part++;
}
@@ -235,13 +236,12 @@
# If we have some new $objects format that isn't close to
# the current razor-agents 2.x version, we won't FP but we
# should alert in debug.
- dbg("It looks like the internal Razor object has changed format! Tell spamassassin-devel!",
- "razor", -1);
+ dbg("razor2: it looks like the internal Razor object has changed format!");
}
}
}
else {
- warn "undefined Razor2::Client::Agent\n";
+ warn "razor2: undefined Razor2::Client::Agent\n";
}
alarm 0;
@@ -251,14 +251,14 @@
if ($@) {
if ( $@ =~ /alarm/ ) {
- dbg("razor2 check timed out after $timeout secs.");
+ dbg("razor2: check timed out after $timeout seconds");
} elsif ($@ =~ /(?:could not connect|network is unreachable)/) {
# make this a dbg(); SpamAssassin will still continue,
# but without Razor checking. otherwise there may be
# DSNs and errors in syslog etc., yuck
- dbg("razor2 check could not connect to any servers");
+ dbg("razor2: check could not connect to any servers");
} else {
- warn("razor2 check skipped: $! $@");
+ warn("razor2: check skipped: $! $@");
}
}
@@ -268,13 +268,13 @@
$permsgstatus->leave_helper_run_mode();
# razor also debugs to stdout. argh. fix it to stderr...
- if ($Mail::SpamAssassin::DEBUG->{enabled}) {
+ if ($Mail::SpamAssassin::DEBUG) {
open (STDOUT, ">&OLDOUT");
close OLDOUT;
}
- dbg("Razor2 results: spam? ".$self->{razor2_result}." highest cf score: ".$self->{razor2_cf_score},
- "razor", -1);
+ dbg("razor2: results: spam? " . $self->{razor2_result} .
+ " highest cf score: " . $self->{razor2_cf_score} . "\n");
if ($self->{razor2_result} > 0) {
return 1;
@@ -314,6 +314,6 @@
return 0;
}
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm Sat Oct 2 14:54:53 2004
@@ -44,7 +44,7 @@
$reg = IP::Country::Fast->new();
};
if ($@) {
- dbg ("failed to load 'IP::Country::Fast', skipping");
+ dbg("metadata: failed to load 'IP::Country::Fast', skipping");
return 1;
}
@@ -59,11 +59,11 @@
chop $countries;
$msg->put_metadata ("X-Relay-Countries", $countries);
- dbg ("metadata: X-Relay-Countries: $countries");
+ dbg("metadata: X-Relay-Countries: $countries");
return 1;
}
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/SPF.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/SPF.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/SPF.pm Sat Oct 2 14:54:53 2004
@@ -133,7 +133,7 @@
my $lasthop = $scanner->{relays_untrusted}->[0];
if (!defined $lasthop) {
- dbg ("SPF: message was delivered entirely via trusted relays, not required");
+ dbg("spf: message was delivered entirely via trusted relays, not required");
return;
}
@@ -142,20 +142,20 @@
my $sender = '';
if ($ishelo) {
- dbg ("SPF: checking HELO (helo=$helo, ip=$ip)");
+ dbg("spf: checking HELO (helo=$helo, ip=$ip)");
if ($helo !~ /^\d+\.\d+\.\d+\.\d+$/) {
# get rid of hostname part of domain, understanding delegation
$helo = Mail::SpamAssassin::Util::RegistrarBoundaries::trim_domain ($helo);
}
- dbg ("SPF: trimmed HELO down to '$helo'");
+ dbg("spf: trimmed HELO down to '$helo'");
} else {
$sender = $lasthop->{envfrom};
if ($sender) {
- dbg ("SPF: found Envelope-From in last untrusted Received header");
+ dbg("spf: found Envelope-From in last untrusted Received header");
}
else {
# We cannot use the env-from data, since it went through 1 or
@@ -163,7 +163,7 @@
# rewritten it.
#
if ($scanner->{num_relays_trusted} > 0) {
- dbg ("SPF: relayed through one or more trusted relays, cannot use header-based Envelope-From, skipping");
+ dbg("spf: relayed through one or more trusted relays, cannot use header-based Envelope-From, skipping");
return;
}
@@ -176,25 +176,25 @@
}
if (!$sender) {
- dbg ("SPF: cannot get Envelope-From, cannot use SPF");
+ dbg("spf: cannot get Envelope-From, cannot use SPF");
return;
}
- dbg ("SPF: checking EnvelopeFrom (helo=$helo, ip=$ip, envfrom=$sender)");
+ dbg("spf: checking EnvelopeFrom (helo=$helo, ip=$ip, envfrom=$sender)");
}
# this test could probably stand to be more strict, but try to test
# any invalid HELO hostname formats with a header rule
if ($ishelo && ($helo =~ /^\d+\.\d+\.\d+\.\d+$/ || $helo =~ /^[^.]+$/)) {
- dbg ("SPF: cannot check HELO of '$helo', skipping");
+ dbg("spf: cannot check HELO of '$helo', skipping");
return;
}
if (!$helo) {
- dbg ("SPF: cannot get HELO, cannot use SPF");
+ dbg("spf: cannot get HELO, cannot use SPF");
return;
}
if ($scanner->server_failed_to_respond_for_domain($helo)) {
- dbg ("SPF: we had a previous timeout on '$helo', skipping");
+ dbg("spf: we had a previous timeout on '$helo', skipping");
return;
}
@@ -202,7 +202,7 @@
eval {
require Mail::SPF::Query;
if ($Mail::SPF::Query::VERSION < 1.996) {
- die "Mail::SPF::Query 1.996 or later required, this is $Mail::SPF::Query::VERSION\n";
+ die "spf: Mail::SPF::Query 1.996 or later required, this is $Mail::SPF::Query::VERSION\n";
}
$query = Mail::SPF::Query->new (ip => $ip,
sender => $sender,
@@ -212,7 +212,7 @@
};
if ($@) {
- dbg ("SPF: cannot load or create Mail::SPF::Query module");
+ dbg("spf: cannot load or create Mail::SPF::Query module");
return;
}
@@ -230,9 +230,9 @@
if ($@) {
if ($@ =~ /^__alarm__$/) {
- dbg ("SPF: lookup timed out after $timeout secs.");
+ dbg("spf: lookup timed out after $timeout seconds");
} else {
- warn ("SPF: lookup failed: $@\n");
+ warn("spf: lookup failed: $@\n");
}
return 0;
}
@@ -259,11 +259,11 @@
}
}
- dbg ("SPF: query for $sender/$ip/$helo: result: $result, comment: $comment");
+ dbg("spf: query for $sender/$ip/$helo: result: $result, comment: $comment");
}
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm Sat Oct 2 14:54:53 2004
@@ -117,7 +117,7 @@
};
if ($@) {
- dbg ("failed to load Net::DNS::Resolver: $@");
+ dbg("uridnsbl: failed to load Net::DNS::Resolver: $@");
}
if ($self->{res}) {
@@ -186,7 +186,7 @@
my $dom = Mail::SpamAssassin::Util::uri_to_domain($uri);
if ($dom) {
if (exists $scanner->{main}->{conf}->{uridnsbl_skip_domains}->{$dom}) {
- dbg("URIDNSBL: found domain $dom in skip list");
+ dbg("uridnsbl: found domain $dom in skip list");
}
else {
$domlist{$dom} = 1;
@@ -206,7 +206,7 @@
# and query
my @doms = keys %domlist;
- dbg ("URIDNSBL: domains to query: ".join(' ',@doms));
+ dbg("uridnsbl: domains to query: ".join(' ',@doms));
foreach my $dom (@doms) {
$self->query_domain ($scanstate, $dom);
}
@@ -301,12 +301,12 @@
# try to complete a few more
if (!$self->complete_lookups($scanstate)) {
my $secs_to_wait = $scan->{conf}->{uridnsbl_timeout};
- dbg ("waiting $secs_to_wait seconds for URIDNSBL lookups to complete");
+ dbg("uridnsbl: waiting $secs_to_wait seconds for URIDNSBL lookups to complete");
while ($secs_to_wait-- >= 0) {
last if ($self->complete_lookups($scanstate));
sleep 1;
}
- dbg ("done waiting for URIDNSBL lookups to complete");
+ dbg("uridnsbl: done waiting for URIDNSBL lookups to complete");
}
foreach my $rulename (keys %{$scanstate->{active_rules_revipbl}},
@@ -340,7 +340,8 @@
sub query_domain {
my ($self, $scanstate, $dom) = @_;
- #warn "domain $dom\n"; return;
+ #warn "uridnsbl: domain $dom\n";
+ #return;
$dom = lc $dom;
return if $scanstate->{seen_domain}->{$dom}; $scanstate->{seen_domain}->{$dom}=1;
@@ -518,7 +519,7 @@
my ($self, $scanstate, $ent, $str, $dom, $rulename) = @_;
$str =~ s/\s+/ /gs; # long whitespace => short
- dbg ("URIDNSBL: domain \"$dom\" listed ($rulename): $str");
+ dbg("uridnsbl: domain \"$dom\" listed ($rulename): $str");
if (!defined $scanstate->{hits}->{$rulename}) {
$scanstate->{hits}->{$rulename} = { };
@@ -584,7 +585,7 @@
elsif ($type eq 'DNSBL') {
$self->complete_dnsbl_lookup ($scanstate, $ent, $val);
my $totalsecs = (time - $ent->{obj}->{querystart});
- dbg ("URIDNSBL: query for ".$ent->{obj}->{dom}." took ".
+ dbg("uridnsbl: query for ".$ent->{obj}->{dom}." took ".
$totalsecs." seconds to look up ($val)");
}
@@ -592,11 +593,11 @@
delete $scanstate->{pending_lookups}->{$key};
}
- dbg ("URIDNSBL: queries completed: ".$scanstate->{queries_completed}.
+ dbg("uridnsbl: queries completed: ".$scanstate->{queries_completed}.
" started: ".$scanstate->{queries_started});
if (1) {
- dbg ("URIDNSBL: queries active: ".
+ dbg("uridnsbl: queries active: ".
join (' ', map { "$_=$typecount{$_}" } sort keys %typecount)." at ".
localtime(time));
}
@@ -614,7 +615,7 @@
if ($scanstate->{last_count} == $numkeys) {
$scanstate->{times_count_was_same}++;
if ($scanstate->{times_count_was_same} > 20) {
- dbg ("URIDNSBL: escaping: must have lost requests");
+ dbg("uridnsbl: escaping: must have lost requests");
$self->abort_remaining_lookups ($scanstate);
$stillwaiting = 0;
}
@@ -638,7 +639,7 @@
foreach my $key (keys %{$pending})
{
if (!$foundone) {
- dbg ("URIDNSBL: aborting remaining lookups");
+ dbg("uridnsbl: aborting remaining lookups");
$foundone = 1;
}
@@ -659,12 +660,12 @@
sub log_dns_result {
my $self = shift;
- #Mail::SpamAssassin::dbg ("URIDNSBL: ".join (' ', @_));
+ #Mail::SpamAssassin::dbg("uridnsbl: ".join (' ', @_));
}
# ---------------------------------------------------------------------------
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
# ---------------------------------------------------------------------------
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm Sat Oct 2 14:54:53 2004
@@ -80,28 +80,29 @@
$path = Mail::SpamAssassin::Util::untaint_file_path(
File::Spec->rel2abs($path)
);
- dbg ("plugin: loading $package from $path");
+ dbg("plugin: loading $package from $path");
$ret = do $path;
}
else {
- dbg ("plugin: loading $package from \@INC");
+ dbg("plugin: loading $package from \@INC");
$ret = eval qq{ require $package; };
$path = "(from \@INC)";
}
if (!$ret) {
- if ($@) { warn "failed to parse plugin $path: $@\n"; }
- elsif ($!) { warn "failed to load plugin $path: $!\n"; }
+ if ($@) { warn "plugin: failed to parse plugin $path: $@\n"; }
+ elsif ($!) { warn "plugin: failed to load plugin $path: $!\n"; }
}
my $plugin = eval $package.q{->new ($self->{main}); };
- if ($@ || !$plugin) { warn "failed to create instance of plugin $package: $@\n"; }
+ if ($@ || !$plugin) { warn "plugin: failed to create instance of plugin $package: $@\n"; }
# Don't load the same plugin twice!
foreach my $old_plugin (@{$self->{plugins}}) {
if (ref($old_plugin) eq ref($plugin)) {
- warn "Plugin " . ref($old_plugin) . " already registered\n";
+ # why are there two warnings here?
+ warn "plugin: plugin " . ref($old_plugin) . " already registered\n";
dbg("plugin: did not register $plugin, already registered");
return;
}
@@ -117,7 +118,7 @@
my ($self, $plugin) = @_;
$plugin->{main} = $self->{main};
push (@{$self->{plugins}}, $plugin);
- dbg ("plugin: registered $plugin");
+ dbg("plugin: registered $plugin");
# invalidate cache entries for any configuration-time hooks, in case
# one has already been built; this plugin may implement that hook!
@@ -142,7 +143,7 @@
my $methodref = $plugin->can ($subname);
if (defined $methodref) {
push (@subs, [ $plugin, $methodref ]);
- dbg ("plugin: ${plugin} implements '$subname'");
+ dbg("plugin: ${plugin} implements '$subname'");
}
}
$self->{cbs}->{$subname} = \@subs;
@@ -157,12 +158,12 @@
$ret = &$methodref ($plugin, @_);
};
if ($ret) {
- #dbg ("plugin: ${plugin}->${methodref} => $ret");
+ #dbg("plugin: ${plugin}->${methodref} => $ret");
$overallret = $ret;
}
if ($plugin->{_inhibit_further_callbacks}) {
- dbg ("plugin: $plugin inhibited further callbacks");
+ dbg("plugin: $plugin inhibited further callbacks");
last;
}
}
@@ -186,6 +187,6 @@
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Reporter.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Reporter.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Reporter.pm Sat Oct 2 14:54:53 2004
@@ -63,48 +63,48 @@
if (!$self->{options}->{dont_report_to_dcc} && $self->is_dcc_available()) {
if ($self->dcc_report($text)) {
$available = 1;
- dbg ("SpamAssassin: spam reported to DCC.");
+ dbg("reporter: spam reported to DCC");
$return = 0;
}
else {
- dbg ("SpamAssassin: could not report spam to DCC.");
+ dbg("reporter: could not report spam to DCC");
}
}
if (!$self->{options}->{dont_report_to_pyzor} && $self->is_pyzor_available()) {
if ($self->pyzor_report($text)) {
$available = 1;
- dbg ("SpamAssassin: spam reported to Pyzor.");
+ dbg("reporter: spam reported to Pyzor");
$return = 0;
}
else {
- dbg ("SpamAssassin: could not report spam to Pyzor.");
+ dbg("reporter: could not report spam to Pyzor");
}
}
if (!$self->{options}->{dont_report_to_razor} && $self->is_razor_available()) {
if ($self->razor_report($text)) {
$available = 1;
- dbg ("SpamAssassin: spam reported to Razor.");
+ dbg("reporter: spam reported to Razor");
$return = 0;
}
else {
- dbg ("SpamAssassin: could not report spam to Razor.");
+ dbg("reporter: could not report spam to Razor");
}
}
if (!$self->{options}->{dont_report_to_spamcop} && $self->is_spamcop_available()) {
if ($self->spamcop_report($text)) {
$available = 1;
- dbg ("SpamAssassin: spam reported to SpamCop.");
+ dbg("reporter: spam reported to SpamCop");
$return = 0;
}
else {
- dbg ("SpamAssassin: could not report spam to SpamCop.");
+ dbg("reporter: could not report spam to reporter.");
}
}
$self->delete_fulltext_tmpfile();
- if ( $available == 0 ) {
- warn "SpamAssassin: no Internet hashing methods available, so couldn't report.\n";
+ if ($available == 0) {
+ warn "reporter: no network reporting methods available, so couldn't report\n";
}
return $return;
@@ -116,18 +116,18 @@
my ($self) = @_;
my $return = 1;
- my $text = $self->{main}->remove_spamassassin_markup ($self->{msg});
+ my $text = $self->{main}->remove_spamassassin_markup($self->{msg});
if (!$self->{main}->{local_tests_only}
&& !$self->{options}->{dont_report_to_razor}
&& $self->is_razor_available()) # we only work with Razor2
{
if ($self->razor_revoke($text)) {
- dbg ("SpamAssassin: spam revoked from Razor.");
+ dbg("reporter: spam revoked from Razor");
$return = 0;
}
else {
- dbg ("SpamAssassin: could not revoke spam from Razor.");
+ dbg("reporter: could not revoke spam from Razor");
}
}
@@ -140,7 +140,7 @@
###########################################################################
# non-public methods.
-# This is to reset the alarm before dieing - spamd can die of a stray alarm!
+# This is to reset the alarm before die() - spamd can die of a stray alarm!
sub adie {
my $msg = shift;
@@ -156,14 +156,14 @@
return if close ($fh);
my $exitstatus = $?;
- dbg ("raw exit code: $exitstatus");
+ dbg("reporter: raw exit code: $exitstatus");
if (WIFEXITED ($exitstatus) && (WEXITSTATUS ($exitstatus))) {
- die "Exited with non-zero exit code " . WEXITSTATUS ($exitstatus) . "\n";
+ die "reporter: exited with non-zero exit code " . WEXITSTATUS ($exitstatus) . "\n";
}
if (WIFSIGNALED ($exitstatus)) {
- die "Exited due to signal " . WTERMSIG ($exitstatus) . "\n";
+ die "reporter: exited due to signal " . WTERMSIG ($exitstatus) . "\n";
}
}
@@ -176,7 +176,7 @@
my $type = (defined($revoke) && $revoke) ? 'revoke' : 'report';
# razor also debugs to stdout. argh. fix it to stderr...
- if ($Mail::SpamAssassin::DEBUG->{enabled}) {
+ if ($Mail::SpamAssassin::DEBUG) {
open (OLDOUT, ">&STDOUT");
open (STDOUT, ">&STDERR");
}
@@ -197,21 +197,21 @@
if ($rc) {
my %opt = (
- debug => $Mail::SpamAssassin::DEBUG->{enabled},
+ debug => $Mail::SpamAssassin::DEBUG,
foreground => 1,
config => $self->{conf}->{razor_config}
);
$rc->{opt} = \%opt;
- $rc->do_conf() or adie($rc->errstr);
+ $rc->do_conf() or adie("reporter: razor2: " . $rc->errstr);
# Razor2 requires authentication for reporting
my $ident = $rc->get_ident
- or adie ("Razor2 $type requires authentication");
+ or adie("reporter: razor2: $type requires authentication");
my @msg = (\$fulltext);
my $objects = $rc->prepare_objects( \@msg )
- or adie ("error in prepare_objects");
- $rc->get_server_info() or adie $rc->errprefix("reportit");
+ or adie("reporter: razor2: error in prepare_objects");
+ $rc->get_server_info() or adie $rc->errprefix("reporter: razor2");
# let's reset the alarm since get_server_info() calls
# nextserver() which calls discover() which very likely will
@@ -219,33 +219,33 @@
alarm $timeout;
my $sigs = $rc->compute_sigs($objects)
- or adie ("error in compute_sigs");
+ or adie("reporter: razor2: error in compute_sigs");
- $rc->connect() or adie ($rc->errprefix("reportit"));
- $rc->authenticate($ident) or adie ($rc->errprefix("reportit"));
- $rc->report($objects) or adie ($rc->errprefix("reportit"));
- $rc->disconnect() or adie ($rc->errprefix("reportit"));
+ $rc->connect() or adie($rc->errprefix("reporter: razor2"));
+ $rc->authenticate($ident) or adie($rc->errprefix("reporter: razor2"));
+ $rc->report($objects) or adie($rc->errprefix("reporter: razor2"));
+ $rc->disconnect() or adie($rc->errprefix("reporter: razor2"));
$response = 1; # Razor 2.14 says that if we get here, we did ok.
}
else {
- warn "undefined Razor2::Client::Agent\n";
+ warn "reporter: undefined Razor2::Client::Agent\n";
}
alarm 0;
- dbg("Razor2: spam $type, response is \"$response\".");
+ dbg("reporter: razor2 spam $type, response is \"$response\".");
};
alarm 0;
if ($@) {
if ( $@ =~ /alarm/ ) {
- dbg("razor2 $type timed out after $timeout secs.");
+ dbg("reporter: razor2 $type timed out after $timeout secs.");
} elsif ($@ =~ /could not connect/) {
- dbg("razor2 $type could not connect to any servers");
+ dbg("reporter: razor2 $type could not connect to any servers");
} elsif ($@ =~ /timeout/i) {
- dbg("razor2 $type timed out connecting to razor servers");
+ dbg("reporter: razor2 $type timed out connecting to razor servers");
} else {
- warn "razor2 $type failed: $! $@";
+ warn "reporter: razor2 $type failed: $! $@";
}
undef $response;
}
@@ -256,7 +256,7 @@
$self->leave_helper_run_mode();
- if ($Mail::SpamAssassin::DEBUG->{enabled}) {
+ if ($Mail::SpamAssassin::DEBUG) {
open (STDOUT, ">&OLDOUT");
close OLDOUT;
}
@@ -313,11 +313,11 @@
if ($@) {
if ($@ =~ /^__alarm__$/) {
- dbg ("DCC -> report timed out after $timeout secs.");
+ dbg("reporter: DCC report timed out after $timeout seconds");
} elsif ($@ =~ /^__brokenpipe__$/) {
- dbg ("DCC -> report failed: Broken pipe.");
+ dbg("reporter: DCC report failed: broken pipe");
} else {
- warn ("DCC -> report failed: $@\n");
+ warn("reporter: DCC report failed: $@\n");
}
return 0;
}
@@ -365,11 +365,11 @@
if ($@) {
if ($@ =~ /^__alarm__$/) {
- dbg ("Pyzor -> report timed out after $timeout secs.");
+ dbg("reporter: pyzor report timed out after $timeout seconds");
} elsif ($@ =~ /^__brokenpipe__$/) {
- dbg ("Pyzor -> report failed: Broken pipe.");
+ dbg("reporter: pyzor report failed: broken pipe");
} else {
- warn ("Pyzor -> report failed: $@\n");
+ warn("reporter: pyzor report failed: $@\n");
}
return 0;
}
@@ -380,14 +380,14 @@
sub smtp_dbg {
my ($command, $smtp) = @_;
- dbg("SpamCop -> sent $command");
+ dbg("reporter: SpamCop sent $command");
my $code = $smtp->code();
my $message = $smtp->message();
my $debug;
$debug .= $code if $code;
$debug .= ($code ? " " : "") . $message if $message;
chomp $debug;
- dbg("SpamCop -> received $debug");
+ dbg("reporter: SpamCop received $debug");
return 1;
}
@@ -399,7 +399,7 @@
$header =~ s/\r?\n\r?\n.*//s;
my $date = Mail::SpamAssassin::Util::receive_date($header);
if ($date && $date < time - 3*86400) {
- warn ("SpamCop -> message older than 3 days, not reporting\n");
+ warn("reporter: SpamCop message older than 3 days, not reporting\n");
return 0;
}
@@ -477,7 +477,7 @@
$smtp->quit() && smtp_dbg("QUIT", $smtp))
{
# tell user we succeeded after first attempt if we previously failed
- warn("SpamCop -> report to $exchange succeeded\n") if defined $failure;
+ warn("reporter: SpamCop report to $exchange succeeded\n") if defined $failure;
return 1;
}
my $code = $smtp->code();
@@ -486,7 +486,7 @@
}
$failure ||= "Net::SMTP error";
chomp $failure;
- warn("SpamCop -> report to $exchange failed: $failure\n");
+ warn("reporter: SpamCop report to $exchange failed: $failure\n");
}
return 0;
@@ -494,7 +494,7 @@
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
sub create_fulltext_tmpfile { Mail::SpamAssassin::PerMsgStatus::create_fulltext_tmpfile(@_) }
sub delete_fulltext_tmpfile { Mail::SpamAssassin::PerMsgStatus::delete_fulltext_tmpfile(@_) }
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/SQLBasedAddrList.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/SQLBasedAddrList.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/SQLBasedAddrList.pm Sat Oct 2 14:54:53 2004
@@ -117,7 +117,7 @@
if (!$main->{conf}->{user_awl_dsn} ||
!$main->{conf}->{user_awl_sql_table}) {
- dbg("auto-whitelist (sql-based): invalid config");
+ dbg("auto-whitelist: sql-based invalid config");
return undef;
}
@@ -128,7 +128,7 @@
my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'PrintError' => 0});
if(!$dbh) {
- dbg("auto-whitelist (sql-based): Unable to Connect to DB");
+ dbg("auto-whitelist: sql-based unable to connect to database");
return undef;
}
@@ -138,7 +138,7 @@
'tablename' => $main->{conf}->{user_awl_sql_table},
};
- dbg("SQL Based AWL: Connected to $dsn");
+ dbg("auto-whitelist: sql-based connected to $dsn");
return bless ($self, $class);
}
@@ -180,7 +180,7 @@
if (!$rc) { # there was an error, but try to go on
my $err = $self->{dbh}->errstr;
- dbg("auto-whitelist (sql-based) get_addr_entry: SQL Error: $err");
+ dbg("auto-whitelist: sql-based get_addr_entry: SQL error: $err");
$entry->{count} = 0;
$entry->{totscore} = 0;
}
@@ -191,15 +191,15 @@
$entry->{count} = $aryref->[0] || 0;
$entry->{totscore} = $aryref->[1] || 0;
$entry->{exists_p} = 1;
- dbg("auto-whitelist (sql-based) get_addr_entry: Found existing entry for $addr");
+ dbg("auto-whitelist: sql-based get_addr_entry: found existing entry for $addr");
}
else {
- dbg("auto-whitelist (sql-based) get_addr_entry: No entry found for $addr");
+ dbg("auto-whitelist: sql-based get_addr_entry: no entry found for $addr");
}
}
$sth->finish();
- dbg ("auto-whitelist (sql-based): $addr scores ".$entry->{count}.'/'.$entry->{totscore});
+ dbg("auto-whitelist: sql-based $addr scores ".$entry->{count}.'/'.$entry->{totscore});
return $entry;
}
@@ -243,10 +243,10 @@
if (!$rc) {
my $err = $self->{dbh}->errstr;
- dbg("auto-whitelist (sql-based) add_score: SQL Error: $err");
+ dbg("auto-whitelist: sql-based add_score: SQL error: $err");
}
else {
- dbg("auto-whitelist (sql-based) add_score: New count: ". $entry->{count} .", new totscore: ".$entry->{totscore}." for ".$entry->{addr});
+ dbg("auto-whitelist: sql-based add_score: new count: ". $entry->{count} .", new totscore: ".$entry->{totscore}." for ".$entry->{addr});
}
$sth->finish();
}
@@ -256,10 +256,10 @@
my $rc = $sth->execute($username,$email,$ip,1,$score);
if (!$rc) {
my $err = $self->{dbh}->errstr;
- dbg("auto-whitelist (sql-based) add_score: SQL Error: $err");
+ dbg("auto-whitelist: sql-based add_score: SQL error: $err");
}
$entry->{exists_p} = 1;
- dbg("auto-whitelist (sql-based) add_score: Created new entry for ".$entry->{addr}." with totscore: $score");
+ dbg("auto-whitelist: sql-based add_score: created new entry for ".$entry->{addr}." with totscore: $score");
$sth->finish();
}
@@ -294,13 +294,13 @@
if ($ip eq 'none') {
$sql = "DELETE FROM $self->{tablename} WHERE username = ? AND email = ?";
@args = ($username, $email);
- dbg("auto-whitelist (sql-based) remove_entry: Removing all entries matching $email");
+ dbg("auto-whitelist: sql-based remove_entry: removing all entries matching $email");
}
else {
$sql = "DELETE FROM $self->{tablename}
WHERE username = ? AND email = ? AND ip = ?";
@args = ($username, $email, $ip);
- dbg("auto-whitelist (sql-based) remove_entry: Removing single entry matching ".$entry->{addr});
+ dbg("auto-whitelist: sql-based remove_entry: removing single entry matching ".$entry->{addr});
}
my $sth = $self->{dbh}->prepare($sql);
@@ -308,7 +308,7 @@
if (!$rc) {
my $err = $self->{dbh}->errstr;
- dbg("auto-whitelist (sql-based) remove_entry: SQL Error: $err");
+ dbg("auto-whitelist: sql-based remove_entry: SQL error: $err");
}
else {
# We might normally have a dbg saying we removed the address
@@ -328,7 +328,7 @@
sub finish {
my ($self) = @_;
- dbg("auto-whitelist (sql-based) finish: Disconnected from " . $self->{dsn});
+ dbg("auto-whitelist: sql-based finish: disconnected from " . $self->{dsn});
$self->{dbh}->disconnect();
}
@@ -348,12 +348,12 @@
my ($email, $ip) = split(/\|ip=/, $addr);
unless ($email && $ip) {
- dbg("auto-whitelist (sql-based): _unpack_addr: Unable to decode $addr");
+ dbg("auto-whitelist: sql-based _unpack_addr: unable to decode $addr");
}
return ($email, $ip);
}
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/TextCat.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/TextCat.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/TextCat.pm Sat Oct 2 14:54:53 2004
@@ -61,14 +61,14 @@
my @lm;
my $ngram = {};
my $rang = 1;
- dbg("Loading languages file...");
+ dbg("textcat: loading languages file...");
if (!defined $languages_filename) {
return;
}
open(LM, $languages_filename)
- || die "cannot open languages: $!\n";
+ || die "textcat: cannot open languages: $!\n";
local $/ = undef;
@lm = split(/\n/, <LM>);
close(LM);
@@ -110,11 +110,11 @@
@answers=(@answers, shift(@results));
}
if (@answers > $opt_a) {
- dbg("Can't determine language uniquely enough");
+ dbg("textcat: can't determine language uniquely enough");
return ();
}
else {
- dbg("Language possibly: ".join(",",@answers));
+ dbg("textcat: language possibly: ".join(",",@answers));
return @answers;
}
}
@@ -155,6 +155,6 @@
return @sorted;
}
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm Sat Oct 2 14:54:53 2004
@@ -59,17 +59,17 @@
clean_path_in_taint_mode();
if ( !$displayed_path++ ) {
- dbg("Current PATH is: ".join($Config{'path_sep'},File::Spec->path()));
+ dbg("util: current PATH is: ".join($Config{'path_sep'},File::Spec->path()));
}
foreach my $path (File::Spec->path()) {
my $fname = File::Spec->catfile ($path, $filename);
if ( -f $fname ) {
if (-x $fname) {
- dbg ("executable for $filename was found at $fname");
+ dbg("util: executable for $filename was found at $fname");
return $fname;
}
else {
- dbg("$filename was found at $fname, but isn't executable");
+ dbg("util: $filename was found at $fname, but isn't executable");
}
}
}
@@ -85,10 +85,10 @@
my $cleaned_taint_path = 0;
sub clean_path_in_taint_mode {
- return if ( $cleaned_taint_path++ );
+ return if ($cleaned_taint_path++);
return unless am_running_in_taint_mode();
- dbg("Running in taint mode, removing unsafe env vars, and resetting PATH");
+ dbg("util: running in taint mode, removing unsafe env vars, and resetting PATH");
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
@@ -102,31 +102,31 @@
$dir = File::Spec->canonpath($1);
if (!File::Spec->file_name_is_absolute($dir)) {
- dbg("PATH included '$dir', which is not absolute, dropping.");
+ dbg("util: PATH included '$dir', which is not absolute, dropping");
next;
}
elsif (!(@stat=stat($dir))) {
- dbg("PATH included '$dir', which doesn't exist, dropping.");
+ dbg("util: PATH included '$dir', which doesn't exist, dropping");
next;
}
elsif (!-d _) {
- dbg("PATH included '$dir', which isn't a directory, dropping.");
+ dbg("util: PATH included '$dir', which isn't a directory, dropping");
next;
}
elsif (($stat[2]&2) != 0) {
# World-Writable directories are considered insecure.
# We could be more paranoid and check all of the parent directories as well,
# but it's good for now.
- dbg("PATH included '$dir', which is world writable, dropping.");
+ dbg("util: PATH included '$dir', which is world writable, dropping");
next;
}
- dbg("PATH included '$dir', keeping.");
+ dbg("util: PATH included '$dir', keeping");
push(@path, $dir);
}
$ENV{'PATH'} = join($Config{'path_sep'}, @path);
- dbg("Final PATH set to: ".$ENV{'PATH'});
+ dbg("util: final PATH set to: ".$ENV{'PATH'});
}
}
@@ -155,7 +155,7 @@
# seriously mind-bending perl
$AM_TAINTED = not eval { eval "1 || $blank" || 1 };
}
- dbg ("running in taint mode? ". ($AM_TAINTED ? "yes" : "no"));
+ dbg("util: running in taint mode? ". ($AM_TAINTED ? "yes" : "no"));
return $AM_TAINTED;
}
@@ -189,7 +189,7 @@
if ($path =~ $re) {
return $1;
} else {
- warn "security: cannot untaint path: \"$path\"\n";
+ warn "util: cannot untaint path: \"$path\"\n";
return $path;
}
}
@@ -208,7 +208,7 @@
return $1;
}
else {
- warn "security: cannot untaint hostname: \"$host\"\n";
+ warn "util: cannot untaint hostname: \"$host\"\n";
return $host;
}
}
@@ -250,7 +250,7 @@
${$_} = untaint_var(${$_});
}
else {
- warn "Can't untaint a " . ref($_) . "!\n";
+ warn "util: can't untaint a " . ref($_) . "!\n";
}
return $_;
}
@@ -348,7 +348,7 @@
} elsif (s/ (\d+) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{2,3}) / /i) {
$dd = $1; $mon = lc($2); $yyyy = $3;
} else {
- dbg ("time cannot be parsed: $date");
+ dbg("util: time cannot be parsed: $date");
return undef;
}
@@ -392,7 +392,7 @@
};
if ($@) {
- dbg ("time cannot be parsed: $date, $yyyy-$mmm-$dd $hh:$mm:$ss");
+ dbg("util: time cannot be parsed: $date, $yyyy-$mmm-$dd $hh:$mm:$ss");
return undef;
}
@@ -502,12 +502,12 @@
if (!RUNNING_ON_WINDOWS) {
eval ' sub _getpwuid_wrapper { getpwuid($_[0]); } ';
} else {
- dbg ("defining getpwuid() wrapper using 'unknown' as username");
+ dbg("util: defining getpwuid() wrapper using 'unknown' as username");
eval ' sub _getpwuid_wrapper { fake_getpwuid($_[0]); } ';
}
if ($@) {
- warn "Failed to define getpwuid() wrapper: $@\n";
+ warn "util: failed to define getpwuid() wrapper: $@\n";
} else {
return Mail::SpamAssassin::Util::_getpwuid_wrapper(@_);
}
@@ -759,7 +759,7 @@
File::Spec->tmpdir()
);
if (!$tmpdir) {
- die "Cannot find a temporary directory! set TMP or TMPDIR in env";
+ die "util: cannot find a temporary directory, set TMP or TMPDIR in environment";
}
my ($reportfile,$tmpfile);
@@ -986,7 +986,7 @@
my $touid = $>;
if ($< != $touid) {
- dbg ("changing real uid from $< to match effective uid $touid");
+ dbg("util: changing real uid from $< to match effective uid $touid");
$< = $touid; # try the simple method first
# bug 3586: Some perl versions, typically those on a BSD-based
@@ -994,7 +994,7 @@
# can be changed. So this is a kluge for us to get around the
# typical spamd-ish behavior of: $< = 0, $> = someuid ...
if ( $< != $touid ) {
- dbg("initial attempt to change real uid failed, trying BSD workaround");
+ dbg("util: initial attempt to change real uid failed, trying BSD workaround");
$> = $<; # revert euid to ruid
$< = $touid; # change ruid to target
@@ -1003,7 +1003,7 @@
# Check that we have now accomplished the setuid
if ($< != $touid) {
- die "setuid $< to $touid failed!";
+ die "util: setuid $< to $touid failed!";
}
}
}
@@ -1033,7 +1033,7 @@
# do a fork-open, so we can setuid() back
my $pid = open ($fh, '-|');
if (!defined $pid) {
- die "cannot fork: $!";
+ die "util: cannot fork: $!";
}
if ($pid != 0) {
@@ -1042,24 +1042,24 @@
# else, child process. go setuid...
setuid_to_euid();
- dbg ("setuid: helper proc $$: ruid=$< euid=$>");
+ dbg("util: setuid: helper proc $$: ruid=$< euid=$>");
if ($stdinfile) { # < $tmpfile
close STDIN;
- open (STDIN, "<$stdinfile") or die "cannot open $stdinfile: $!";
+ open (STDIN, "<$stdinfile") or die "util: cannot open $stdinfile: $!";
}
if ($duperr2out) { # 2>&1
close STDERR;
- open STDERR, ">&STDOUT" or die "dup STDOUT failed: $!";
+ open STDERR, ">&STDOUT" or die "util: dup STDOUT failed: $!";
}
exec @cmdline;
- die "exec failed: $!";
+ die "util: exec failed: $!";
}
###########################################################################
-sub dbg { Mail::SpamAssassin::dbg (@_); }
+sub dbg { Mail::SpamAssassin::dbg(@_); }
1;
Modified: spamassassin/trunk/masses/mass-check
==============================================================================
--- spamassassin/trunk/masses/mass-check (original)
+++ spamassassin/trunk/masses/mass-check Sat Oct 2 14:54:53 2004
@@ -26,7 +26,8 @@
-j=jobs specify the number of processes to run simultaneously
--net turn on network checks!
--mid report Message-ID from each message
- --debug report debugging information
+ --debug=LIST report debugging information (default is all facilities, LIST
+ is a comma-separated list of facilities)
--progress show progress updates during check
--rewrite=OUT save rewritten message to OUT (default is /tmp/out)
--showdots print a dot for each scanned message
@@ -75,9 +76,9 @@
use vars qw($opt_c $opt_p $opt_f $opt_j $opt_n $opt_o $opt_all $opt_bayes
$opt_debug $opt_format $opt_hamlog $opt_head $opt_loghits
- $opt_mid $opt_mh $opt_ms $opt_net $opt_nosort $opt_progress
- $opt_showdots $opt_spamlog $opt_tail $opt_rules $opt_restart
- $opt_loguris $opt_after $opt_before $opt_rewrite $opt_deencap);
+ $opt_mid $opt_net $opt_nosort $opt_progress $opt_showdots
+ $opt_spamlog $opt_tail $opt_rules $opt_restart $opt_loguris
+ $opt_after $opt_before $opt_rewrite $opt_deencap);
use FindBin;
use lib "$FindBin::Bin/../lib";
@@ -97,7 +98,7 @@
$opt_hamlog = "ham.log";
$opt_spamlog = "spam.log";
-GetOptions("c=s", "p=s", "f=s", "j=i", "n", "o", "all", "bayes", "debug",
+GetOptions("c=s", "p=s", "f=s", "j=i", "n", "o", "all", "bayes", "debug:s",
"hamlog=s", "head=i", "loghits", "mh", "mid", "ms", "net",
"progress", "rewrite:s", "showdots", "spamlog=s", "tail=i",
"rules=s", "restart=i", "after=s", "before=s", "loguris", "deencap=s",
@@ -115,15 +116,18 @@
if (scalar @targets == 0) { usage(); }
-#if ($opt_ms) {
-#find_missed($opt_spamlog);
-#}
-#elsif ($opt_mh) {
-#find_missed($opt_hamlog);
-#}
+my @debug;
+if (defined $opt_debug) {
+ if ($opt_debug) {
+ @debug = split(/,/, $opt_debug);
+ }
+ else {
+ @debug = ("all");
+ }
+}
$spamtest = new Mail::SpamAssassin ({
- 'debug' => $opt_debug,
+ 'debug' => \@debug,
'rules_filename' => $opt_c,
'userprefs_filename' => "$opt_p/user_prefs",
'site_rules_filename' => "$opt_p/local.cf",
Modified: spamassassin/trunk/spamassassin.raw
==============================================================================
--- spamassassin/trunk/spamassassin.raw (original)
+++ spamassassin/trunk/spamassassin.raw Sat Oct 2 14:54:53 2004
@@ -157,7 +157,7 @@
'add-to-whitelist|W' => \$opt{'add-to-whitelist'},
'configpath|config-file|config-dir|c|C=s' => \$opt{'configpath'},
'create-prefs!' => \$opt{'create-prefs'},
- 'debug-level|debug|D:s' => \$opt{'debug-level'},
+ 'debug|D:s' => \$opt{'debug'},
'error-code|exit-code|e:i' => \$opt{'error-code'},
'help|h|?' => \$opt{'help'},
'lint' => \$opt{'lint'},
@@ -209,6 +209,19 @@
exit($resphash{'EX_OK'});
}
+# set debug areas, if any specified (only useful for command-line tools)
+my @debug;
+if (defined $opt{'debug'}) {
+ if ($opt{'debug'}) {
+ @debug = split(/,/, $opt{'debug'});
+ if (grep { !/^\S+$/ } @debug) {
+ print_usage_and_exit("bad areas in --debug option!");
+ }
+ }
+ else {
+ @debug = ("all");
+ }
+}
# create the tester factory
my $spamtest = new Mail::SpamAssassin(
@@ -217,7 +230,7 @@
site_rules_filename => $opt{'siteconfigpath'},
userprefs_filename => $opt{'prefspath'},
local_tests_only => $opt{'local'},
- debug => defined( $opt{'debug-level'} ),
+ debug => \@debug,
dont_copy_prefs => ( $opt{'create-prefs'} ? 0 : 1 ),
PREFIX => $PREFIX,
DEF_RULES_DIR => $DEF_RULES_DIR,
@@ -225,18 +238,6 @@
}
);
-# set debug levels, if any specified (only useful for this command-line
-# tool really)
-if ( defined $opt{'debug-level'} && $opt{'debug-level'} ne '' ) {
- my $levels = $opt{'debug-level'};
- while ( $levels =~ s/^([a-z]+)=([+-]?\d+)[,;:]*//s ) {
- $Mail::SpamAssassin::DEBUG->{$1} = $2 + 0;
- }
- if ( $levels !~ /^\s*$/ ) {
- print_usage_and_exit("bad areas in --debug option ($levels)!");
- }
-}
-
if ( $opt{'lint'} ) {
$spamtest->debug_diagnostics();
my $res = $spamtest->lint_rules();
@@ -342,7 +343,7 @@
# this is never called, it's just used to shut up the warnings
sub NEVERCALLED {
- $Mail::SpamAssassin::DEBUG = {};
+ $Mail::SpamAssassin::DEBUG = 0;
}
###########################################################################
@@ -665,15 +666,17 @@
Read user score preferences from I<prefs> (usually C<$HOME/.spamassassin/user_prefs>).
-=item B<-D> [I<area=n,...>], B<--debug> [I<area=n,...>]
+=item B<-D> [I<area,...>], B<--debug> [I<area,...>]
+
+Produce debugging output. If no areas are listed, all debugging information is
+printed. Diagnostic output can also be enabled for each area individually;
+I<area> is the area of the code to instrument. For example, to produce
+diagnostic output on bayes, learn, and dns, use:
-Produce diagnostic output. The level of diagnostic output can be set for each
-area separately; I<area> is the area of the code to instrument, and I<n> is
-a positive or negative number indicating the debug level or bitmask for that
-area of code. For example, to produce diagnostic output on all rules that
-hit, use:
+ spamassassin -D bayes,learn,dns
- spamassassin -D rulesrun=255
+Higher priority informational messages that are suitable for logging in normal
+circumstances are available with an area of "info".
=item B<-x>, B<--nocreate-prefs>
Modified: spamassassin/trunk/spamd/spamd.raw
==============================================================================
--- spamassassin/trunk/spamd/spamd.raw (original)
+++ spamassassin/trunk/spamd/spamd.raw Sat Oct 2 14:54:53 2004
@@ -144,9 +144,8 @@
'c' => \$opt{'create-prefs'},
'create-prefs!' => \$opt{'create-prefs'},
'daemonize!' => \$opt{'daemonize'},
- 'debug!' => \$opt{'debug'},
+ 'debug|D:s' => \$opt{'debug'},
'd' => \$opt{'daemonize'},
- 'D' => \$opt{'debug'},
'helper-home-dir|H:s' => \$opt{'home_dir_for_helpers'},
'help|h' => \$opt{'help'},
'ident-timeout=f' => \$opt{'ident-timeout'},
@@ -358,7 +357,7 @@
# Logging via syslog is requested. Falling back to INET and then STDERR
# if opening a UNIX socket fails.
if ( $log_socket ne 'file' and $log_facility ne 'null' ) {
- warn "trying to connect to syslog/${log_socket}...\n" if $opt{'debug'};
+ warn "trying to connect to syslog/${log_socket}...\n" if defined $opt{'debug'};
eval {
defined( setlogsock($log_socket) ) || die $!;
@@ -373,7 +372,7 @@
# same is true for perl 5.6.0 build on an early version of Red Hat 7!
# In that case we try it with INET.
if ( $err and $log_socket ne 'inet' ) {
- if ( $opt{'debug'} ) {
+ if ( defined $opt{'debug'} ) {
warn "connection failed: $err\n";
warn "trying to connect to syslog/inet...\n";
}
@@ -395,7 +394,7 @@
$log_facility = 'stderr';
}
else {
- warn "no error connecting to syslog/${log_socket}\n" if $opt{'debug'};
+ warn "no error connecting to syslog/${log_socket}\n" if defined $opt{'debug'};
}
}
@@ -427,10 +426,10 @@
: 'syslog'
)
. "\n"
- if $opt{'debug'};
+ if defined $opt{'debug'};
# Don't duplicate log messages in debug mode.
-if ( $log_facility eq 'stderr' and $opt{'debug'} ) {
+if ( $log_facility eq 'stderr' and defined $opt{'debug'} ) {
warn "logging to stderr disabled: already debugging to stderr\n";
$log_facility = 'null';
}
@@ -472,8 +471,8 @@
### End initialization of logging ##########################
# REIMPLEMENT: if $log_socket is none, fall back to log_facility 'stderr'.
-# If log_fac is stderr and $opt{'debug'}, set log_fac to 'null' to avoid
-# duplicating log messages.
+# If log_fac is stderr and defined $opt{'debug'}, set log_fac to 'null' to
+# avoid duplicating log messages.
# TVD: isn't this already done up above?
# support setuid() to user unless:
@@ -601,7 +600,7 @@
Type => SOCK_STREAM,
Listen => SOMAXCONN,
);
- warn("creating UNIX socket:\n" . join("\n", map { "\t$_: " . (defined $socket{$_} ? $socket{$_} : "(undef)") } sort keys %socket) . "\n") if $opt{'debug'};
+ warn("creating UNIX socket:\n" . join("\n", map { "\t$_: " . (defined $socket{$_} ? $socket{$_} : "(undef)") } sort keys %socket) . "\n") if defined $opt{'debug'};
$server = new IO::Socket::UNIX(%socket)
|| die "Could not create UNIX socket on $path: $! ($@)\n";
@@ -648,7 +647,7 @@
SSL_key_file => $opt{'server-key'},
SSL_cert_file => $opt{'server-cert'}
);
- warn("creating SSL socket:\n" . join("\n", map { "\t$_: " . (defined $socket{$_} ? $socket{$_} : "(undef)") } sort keys %socket) . "\n") if $opt{'debug'};
+ warn("creating SSL socket:\n" . join("\n", map { "\t$_: " . (defined $socket{$_} ? $socket{$_} : "(undef)") } sort keys %socket) . "\n") if defined $opt{'debug'};
$server = new IO::Socket::SSL(%socket)
|| die "Could not create SSL socket on $addr:$port: $! ($@)\n";
}
@@ -661,7 +660,7 @@
ReuseAddr => 1,
Listen => SOMAXCONN
);
- warn("creating INET socket:\n" . join("\n", map { "\t$_: " . (defined $socket{$_} ? $socket{$_} : "(undef)") } sort keys %socket) . "\n") if $opt{'debug'};
+ warn("creating INET socket:\n" . join("\n", map { "\t$_: " . (defined $socket{$_} ? $socket{$_} : "(undef)") } sort keys %socket) . "\n") if defined $opt{'debug'};
$server = new IO::Socket::INET(%socket)
|| die "Could not create INET socket on $addr:$port: $! ($@)\n";
}
@@ -706,13 +705,27 @@
}
+# set debug areas, if any specified (only useful for command-line tools)
+my @debug;
+if (defined $opt{'debug'}) {
+ if ($opt{'debug'}) {
+ @debug = split(/,/, $opt{'debug'});
+ if (grep { !/^\S+$/ } @debug) {
+ warn "bad areas in --debug option\n";
+ }
+ }
+ else {
+ @debug = ("all");
+ }
+}
+
my $spamtest = Mail::SpamAssassin->new(
{
dont_copy_prefs => $dontcopy,
rules_filename => ( $opt{'configpath'} || 0 ),
site_rules_filename => ( $opt{'siteconfigpath'} || 0 ),
local_tests_only => ( $opt{'local'} || 0 ),
- debug => ( $opt{'debug'} || 0 ),
+ debug => \@debug,
paranoid => ( $opt{'paranoid'} || 0 ),
home_dir_for_helpers => (
defined $opt{'home_dir_for_helpers'}
@@ -770,7 +783,7 @@
# log server started, but processes watching the log to wait for connect
# should wait until they see the pid, after signal handlers are in place
-if ( $opt{'debug'} ) {
+if ( defined $opt{'debug'} ) {
warn "server started on $listeninfo (running version "
. Mail::SpamAssassin::Version() . ")\n";
}
@@ -798,7 +811,7 @@
# now allow waiting processes to connect, if they're watching the log.
# The test suite does this!
-if ( $opt{'debug'} ) {
+if ( defined $opt{'debug'} ) {
warn "server pid: $$\n";
}
@@ -1348,7 +1361,7 @@
my $username = shift;
my $ident_username = ident_lookup( $client, $opt{'ident-timeout'} );
my $dn = $ident_username || 'NONE'; # display name
- warn "ident_username = $dn, spamc_username = $username\n" if $opt{'debug'};
+ warn "ident_username = $dn, spamc_username = $username\n" if defined $opt{'debug'};
if ( $username ne $ident_username ) {
logmsg( "fatal: ident username ($dn) does not match "
. "spamc username ($username)" );
@@ -1639,7 +1652,7 @@
$msg =~ s/[\r\n]+$//; # remove any trailing newlines
$msg =~ s/[\x00-\x1f]/_/g; # replace all other control chars with underscores
- warn "logmsg: $msg\n" if $opt{'debug'};
+ warn "logmsg: $msg\n" if defined $opt{'debug'};
# log to file:
# bug 1360 <http://bugzilla.spamassassin.org/show_bug.cgi?id=1360>
@@ -1722,7 +1735,7 @@
# now report what happend
$msg = "SIGPIPE received, reopening log socket";
- warn "logmsg: $msg\n" if $opt{'debug'};
+ warn "logmsg: $msg\n" if defined $opt{'debug'};
syslog( 'warning', "%s", $msg );
# if we've received multiple sigpipes, logging is probably
@@ -1803,7 +1816,7 @@
unlink($opt{'socketpath'}) || warn "Can't unlink $opt{'socketpath'}: $!\n";
}
- warn "server socket closed\n" if $opt{'debug'};
+ warn "server socket closed\n" if defined $opt{'debug'};
}
$got_sighup = 1;
}
@@ -1811,7 +1824,7 @@
sub daemonize {
# Pretty command line in ps
- $0 = join ( ' ', $ORIG_ARG0, @ORIG_ARGV ) unless ( $opt{'debug'} );
+ $0 = join ( ' ', $ORIG_ARG0, @ORIG_ARGV ) unless ( defined $opt{'debug'} );
# Be a nice daemon and chdir() to the root so we don't block any unmount attempts
chdir '/' or die "Can't chdir to /: $!\n";
@@ -1937,7 +1950,7 @@
--auth-ident Use ident to authenticate spamc user
--ident-timeout=timeout Timeout for ident connections
-A host,..., --allowed-ips=..,.. Limit ip addresses which can connect
- -D, --debug Print debugging messages
+ -D, --debug[=areas] Print debugging messages (for areas)
-L, --local Use local tests only (no DNS)
-P, --paranoid Die upon user errors
-H [dir], --helper-home-dir[=dir] Specify a different HOME directory
@@ -2197,9 +2210,17 @@
By default, connections are only accepted from localhost [127.0.0.1].
-=item B<-D>, B<--debug>
+=item B<-D> [I<area,...>], B<--debug> [I<area,...>]
+
+Produce debugging output. If no areas are listed, all debugging information is
+printed. Diagnostic output can also be enabled for each area individually;
+I<area> is the area of the code to instrument. For example, to produce
+diagnostic output on bayes, learn, and dns, use:
+
+ spamassassin -D bayes,learn,dns
-Print debugging messages
+Higher priority informational messages that are suitable for logging in normal
+circumstances are available with an area of "info".
=item B<-L>, B<--local>