You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2007/08/20 14:01:43 UTC

svn commit: r567661 - in /spamassassin/branches/jm_bug_3852_two_level_configs: ./ lib/Mail/ lib/Mail/SpamAssassin/ lib/Mail/SpamAssassin/Conf/ lib/Mail/SpamAssassin/Plugin/ lib/Mail/SpamAssassin/Util/ t/

Author: jm
Date: Mon Aug 20 05:01:40 2007
New Revision: 567661

URL: http://svn.apache.org/viewvc?rev=567661&view=rev
Log:
current (broken) state of the two-tier config code. needs a lot of work

Modified:
    spamassassin/branches/jm_bug_3852_two_level_configs/MANIFEST
    spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin.pm
    spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Conf/Parser.pm
    spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Dns.pm
    spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/PerMsgStatus.pm
    spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm
    spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/HTMLEval.pm
    spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/HeaderEval.pm
    spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/MIMEEval.pm
    spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Util/TwoTierHash.pm
    spamassassin/branches/jm_bug_3852_two_level_configs/t/priorities.t

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/MANIFEST
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/MANIFEST?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/MANIFEST (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/MANIFEST Mon Aug 20 05:01:40 2007
@@ -504,5 +504,3 @@
 t/root_spamd_x_u.t
 t/spamc_x_E_R.t
 t/spamc_x_e.t
-lib/Mail/SpamAssassin/Util/TwoTierArray.pm
-lib/Mail/SpamAssassin/Util/TwoTierHash.pm

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin.pm?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin.pm (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin.pm Mon Aug 20 05:01:40 2007
@@ -349,7 +349,7 @@
     $self->{username} = (Mail::SpamAssassin::Util::portable_getpwuid ($>))[0];
   }
 
-  $self->create_locker(1);
+  $self->create_locker();
 
   $self->{resolver} = Mail::SpamAssassin::DnsResolver->new($self);
 
@@ -357,19 +357,16 @@
 }
 
 sub create_locker {
-  my ($self, $withoutconf) = @_;
+  my ($self) = @_;
 
   my $class;
-  my $m;
-  if (!$withoutconf) {
-    $m = $self->{conf}->cf_lock_method;
-  }
+  my $m = $self->{conf}->{lock_method} || '';
 
   # let people choose what they want -- even if they may not work on their
   # OS.  (they could be using cygwin!)
-  if ($m && $m eq 'win32') { $class = 'Win32'; }
-  elsif ($m && $m eq 'flock') { $class = 'Flock'; }
-  elsif ($m && $m eq 'nfssafe') { $class = 'UnixNFSSafe'; }
+  if ($m eq 'win32') { $class = 'Win32'; }
+  elsif ($m eq 'flock') { $class = 'Flock'; }
+  elsif ($m eq 'nfssafe') { $class = 'UnixNFSSafe'; }
   else {
     # OS-specific defaults
     if (Mail::SpamAssassin::Util::am_running_on_windows()) {

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Conf.pm?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Conf.pm Mon Aug 20 05:01:40 2007
@@ -1549,7 +1549,7 @@
         return $INVALID_VALUE;
       }
       
-      $self->{activetier}->{lock_method} = $value;
+      $self->{lock_method} = $value;
       # recreate the locker
       $self->{main}->create_locker();
     },
@@ -3096,13 +3096,20 @@
 sub new {
   my $class = shift;
   $class = ref($class) || $class;
-  my $self = {
-    main => shift,
-    registered_commands => [],
-    plugins_loaded => { },
-    eval_plugins => { },
-    errors => 0,
-  }; bless ($self, $class);
+
+  my $self;
+  tie %{$self}, 'Mail::SpamAssassin::Util::TwoTierHash', { }, { }
+      or warn "tie failed";
+  $self->{ACTIVETIER} = 0;
+
+  # anything set here is now set in tier 0; that includes other
+  # hashes, in which *other* things can be set in turn
+  $self->{main} = shift;
+  $self->{registered_commands} = [];
+  $self->{plugins_loaded} = {};
+  $self->{eval_plugins} = {};
+  $self->{errors} = 0;
+  bless ($self, $class);
 
   $self->{parser} = Mail::SpamAssassin::Conf::Parser->new($self);
 
@@ -3115,10 +3122,10 @@
   $self->{parser}->register_commands($self->set_default_commands());
 
   # Make sure we add in X-Spam-Checker-Version
-  $self->{tiers}->[0]->{headers_spam}->{"Checker-Version"} =
+  $self->{headers_spam}->{"Checker-Version"} =
                 "SpamAssassin _VERSION_ (_SUBVERSION_) on _HOSTNAME_";
-  $self->{tiers}->[0]->{headers_ham}->{"Checker-Version"} =
-                $self->{tiers}->[0]->{headers_spam}->{"Checker-Version"};
+  $self->{headers_ham}->{"Checker-Version"} =
+                $self->{headers_spam}->{"Checker-Version"};
 
   # these should potentially be settable by end-users
   # perhaps via plugin?
@@ -3211,12 +3218,15 @@
   $self->{tiers}->[1] = $self->new_tier();
   $self->{activetier} = $self->{tiers}->[1];
   $self->create_lookup_doublehashes();
+  $self->{ACTIVETIER} = 1;
 }
 
 # and delete it once the user is no longer active
 sub pop_tier {
   my ($self) = @_;
   delete $self->{tiers}->[1];
+  $self = {};       # clears the top tier
+  $self->{ACTIVETIER} = 0;
   $self->{activetier} = $self->{tiers}->[0];
 }
 

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Conf/Parser.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Conf/Parser.pm?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Conf/Parser.pm (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Conf/Parser.pm Mon Aug 20 05:01:40 2007
@@ -64,16 +64,11 @@
            - $CONF_TYPE_HASH_KEY_VALUE: hash key/value pair,
              like "describe" or tflags
 
-If this is set, a 'code' block is assigned based on the type, if
-none already exists, and an accessor of the right type will be used
-for the generated $conf->cf_setting() method.
+If this is set, a 'code' block is assigned based on the type.
 
 Note that C<$CONF_TYPE_HASH_KEY_VALUE>-type settings require that the
 value be non-empty, otherwise they'll produce a warning message.
 
-If a type is omitted, a default accessor will be generated using the
-$CONF_TYPE_STRING type.
-
 =item code
 
 A subroutine to deal with the setting.  Only used if B<type> is not set.  ONE OF
@@ -116,13 +111,6 @@
 Set to 1 if this value occurs frequently in the config. this means it's looked
 up first for speed.
 
-=item accessor
-
-Set to a string containing the perl code of a method to get the configuration
-value. The string C<${SETTING}> will be replaced with the name of the setting.
-Optional; if C<type> is defined, an accessor suitable for that type of
-data will be provided automatically.
-
 =back
 
 =head1 METHODS
@@ -168,66 +156,6 @@
 
 ###########################################################################
 
-# Implementations for default accessors.
-# access a scalar configuration setting. e.g.:
-#   my $val = $conf->cf_foo_bar();
-our $cf_accessor_scalar_value = '
-
-  sub cf_${SETTING} {
-    if (defined $_[0]->{tiers}->[1]->{${SETTING}}) {
-      return $_[0]->{tiers}->[1]->{${SETTING}};
-    } else {
-      return $_[0]->{tiers}->[0]->{${SETTING}};
-    }
-  }
-
-';
-
-# access a hash key=>value configuration setting. e.g.:
-#   my $val = $conf->cf_foo_bar("baz");
-# note use of "exists" instead of "defined"; this is deliberate so that
-# "deletion" of a sys-level setting can take place at user-level,
-# by setting val to undef
-our $cf_accessor_hash_key_value = '
-
-  sub cf_${SETTING} {
-    if (exists $_[0]->{tiers}->[1]->{${SETTING}}->{$_[1]}) {
-      return $_[0]->{tiers}->[1]->{${SETTING}}->{$_[1]};
-    } else {
-      return $_[0]->{tiers}->[0]->{${SETTING}}->{$_[1]};
-    }
-  }
-
-';
-
-# access a whitelist/blacklist address-list hash in its entirety. e.g.:
-#   my $hashref = $conf->cf_foo_bar();
-#   foreach my $addr (keys %{$hashref}) {
-#     do something with $hashref->{$addr}
-#   }
-# TODO: it would be more efficient to fix calling code to iterate
-# through the tiers instead of using this API.
-our $cf_accessor_addrlist_value = '
-
-  sub cf_${SETTING} {
-    if (defined $_[0]->{tiers}->[1]->{${SETTING}}) {
-      # return the user configuration whitelists and system-wide stuff
-      return \(
-          %{$_[0]->{tiers}->[1]->{${SETTING}}},
-          %{$_[0]->{tiers}->[0]->{${SETTING}}}
-        );
-    } else {
-      # just the system-wide stuff
-      return \(
-          %{$_[0]->{tiers}->[0]->{${SETTING}}}
-        );
-    }
-  }
-
-';
-
-###########################################################################
-
 sub register_commands {
   my($self, $arrref) = @_;
   my $conf = $self->{conf};
@@ -244,10 +172,8 @@
     # note! exists, not defined -- we want to be able to set
     # "undef" default values.
     if (exists($cmd->{default})) {
-      $conf->{activetier}->{$cmd->{setting}} = $cmd->{default};
+      $conf->{$cmd->{setting}} = $cmd->{default};
     }
-
-    $self->setup_accessor($cmd);
   }
 }
 
@@ -643,56 +569,6 @@
 
 ###########################################################################
 
-sub setup_accessor {
-  my ($self, $cmd) = @_;
-
-  # find a default accessor method, if possible
-  if (!defined $cmd->{accessor}) {
-    my $type = $cmd->{accessortype} || $cmd->{type};
-
-    if (!$type || $type == $Mail::SpamAssassin::Conf::CONF_TYPE_STRING) {
-      $cmd->{accessor} = $cf_accessor_scalar_value;
-    }
-    elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_BOOL) {
-      $cmd->{accessor} = $cf_accessor_scalar_value;
-    }
-    elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_NUMERIC) {
-      $cmd->{accessor} = $cf_accessor_scalar_value;
-    }
-    elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_TEMPLATE) {
-      $cmd->{accessor} = $cf_accessor_scalar_value;
-    }
-    elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_HASH_KEY_VALUE) {
-      $cmd->{accessor} = $cf_accessor_hash_key_value;
-    }
-    elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_ADDRLIST) {
-      $cmd->{accessor} = $cf_accessor_addrlist_value;
-    }
-  }
-  
-  # now eval the accessor
-  # note: (accessor == "") means do not generate any accessor method
-  my $methodname = "Mail::SpamAssassin::Conf::cf_".$cmd->{setting};
-  if ($cmd->{accessor} && !defined &{$methodname})
-  {
-    my $evalstr = $cmd->{accessor};
-    $evalstr =~ s/\$\{SETTING\}/$cmd->{setting}/gs;
-    eval "package Mail::SpamAssassin::Conf; ".$evalstr;
-
-    if ($@) {
-      die "config: failed to parse accessor: $@\n";
-      return;
-    }
-
-    if (!defined &{$methodname}) {
-      die "config: accessor $methodname not created\n";
-      return;
-    }
-  }
-}
-
-###########################################################################
-
 sub setup_default_code_cb {
   my ($self, $cmd) = @_;
   my $type = $cmd->{type};
@@ -732,7 +608,7 @@
     return $Mail::SpamAssassin::Conf::INVALID_VALUE;
   }
 
-  $conf->{activetier}->{$key} = $value+0.0;
+  $conf->{$key} = $value+0.0;
 }
 
 sub set_bool_value {
@@ -755,7 +631,7 @@
     return $Mail::SpamAssassin::Conf::INVALID_VALUE;
   }
 
-  $conf->{activetier}->{$key} = $value+0;
+  $conf->{$key} = $value+0;
 }
 
 sub set_string_value {
@@ -765,7 +641,7 @@
     return $Mail::SpamAssassin::Conf::MISSING_REQUIRED_VALUE;
   }
 
-  $conf->{activetier}->{$key} = $value;
+  $conf->{$key} = $value;
 }
 
 sub set_hash_key_value {

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Dns.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Dns.pm?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Dns.pm (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Dns.pm Mon Aug 20 05:01:40 2007
@@ -330,7 +330,7 @@
 
   return if !defined $self->{async}->get_last_start_lookup_time();
 
-  my $deadline = $self->{conf}->cf_rbl_timeout + $self->{async}->get_last_start_lookup_time();
+  my $deadline = $self->{conf}->{rbl_timeout} + $self->{async}->get_last_start_lookup_time();
   my $now = time;
 
   # should not give up before at least attempting to collect some responses
@@ -355,11 +355,11 @@
     @left = $self->{async}->get_pending_lookups();
 
     # complete_lookups could cause a change in get_last_start_lookup_time
-    $deadline = $self->{conf}->cf_rbl_timeout +
+    $deadline = $self->{conf}->{rbl_timeout} +
                 $self->{async}->get_last_start_lookup_time();
 
     # dynamic timeout
-    my $dynamic = (int($self->{conf}->cf_rbl_timeout
+    my $dynamic = (int($self->{conf}->{rbl_timeout}
                       * (1 - 0.7*(($total - @left) / $total) ** 2) + 1)
                   + $self->{async}->get_last_start_lookup_time());
     $deadline = $dynamic if ($dynamic < $deadline);
@@ -372,7 +372,7 @@
 
   return if !defined $self->{async}->get_last_start_lookup_time();
 
-  my $deadline = $self->{conf}->cf_rbl_timeout + $self->{async}->get_last_start_lookup_time();
+  my $deadline = $self->{conf}->{rbl_timeout} + $self->{async}->get_last_start_lookup_time();
   my $now = time;
 
   # should not give up before at least attempting to collect some responses
@@ -396,11 +396,11 @@
     # complete_lookups() may have called completed_callback, which may call
     # start_lookup() again (like in URIDNSBL), so get_last_start_lookup_time
     # may have changed and deadline needs to be recomputed
-    $deadline = $self->{conf}->cf_rbl_timeout +
+    $deadline = $self->{conf}->{rbl_timeout} +
                 $self->{async}->get_last_start_lookup_time();
 
     # dynamic timeout
-    my $dynamic = (int($self->{conf}->cf_rbl_timeout
+    my $dynamic = (int($self->{conf}->{rbl_timeout}
                       * (1 - 0.7*(($total - @left) / $total) ** 2) + 1)
                   + $self->{async}->get_last_start_lookup_time());
     $deadline = $dynamic if ($dynamic < $deadline);
@@ -628,8 +628,8 @@
 
 sub is_dns_available {
   my ($self) = @_;
-  my $dnsopt = $self->{conf}->cf_dns_available;
-  my $dnsint = $self->{conf}->cf_dns_test_interval || 600;
+  my $dnsopt = $self->{conf}->{dns_available};
+  my $dnsint = $self->{conf}->{dns_test_interval} || 600;
   my @domains;
 
   $LAST_DNS_CHECK ||= 0;

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/PerMsgStatus.pm Mon Aug 20 05:01:40 2007
@@ -178,7 +178,7 @@
   $self->{score} = (sprintf "%0.3f", $self->{score}) + 0;
   
   dbg("check: is spam? score=".$self->{score}.
-                        " required=".$self->{conf}->cf_required_score);
+                        " required=".$self->{conf}->{required_score});
   dbg("check: tests=".$self->get_names_of_tests_hit());
   dbg("check: subtests=".$self->get_names_of_subtests_hit());
   $self->{is_spam} = $self->is_spam();
@@ -204,8 +204,8 @@
 sub learn {
   my ($self) = @_;
 
-  if (!$self->{conf}->cf_bayes_auto_learn ||
-      !$self->{conf}->cf_use_bayes ||
+  if (!$self->{conf}->{bayes_auto_learn} ||
+      !$self->{conf}->{use_bayes} ||
       $self->{disable_auto_learning})
   {
     $self->{auto_learn_status} = "disabled";
@@ -395,7 +395,7 @@
 sub is_spam {
   my ($self) = @_;
   # changed to test this so sub-tests can ask "is_spam" during a run
-  return ($self->{score} >= $self->{conf}->cf_required_score);
+  return ($self->{score} >= $self->{conf}->{required_score});
 }
 
 ###########################################################################
@@ -463,7 +463,7 @@
 
 sub get_required_score {
   my ($self) = @_;
-  return $self->{conf}->cf_required_score;
+  return $self->{conf}->{required_score};
 }
 
 # left as backward compatibility
@@ -501,7 +501,7 @@
 
   if (!exists $self->{'report'}) {
     my $report;
-    $report = $self->{conf}->cf_report_template;
+    $report = $self->{conf}->{report_template};
     $report ||= '(no report template found)';
 
     $report = $self->_replace_tags($report);
@@ -616,7 +616,7 @@
 
   my $msg = $self->{msg}->get_mbox_separator() || '';
 
-  if ($self->{is_spam} && $self->{conf}->cf_report_safe) {
+  if ($self->{is_spam} && $self->{conf}->{report_safe}) {
     $msg .= $self->rewrite_report_safe();
   }
   else {
@@ -653,8 +653,8 @@
 
   # the report charset
   my $report_charset = "; charset=iso-8859-1";
-  if ($self->{conf}->cf_report_charset) {
-    $report_charset = "; charset=" . $self->{conf}->cf_report_charset;
+  if ($self->{conf}->{report_charset}) {
+    $report_charset = "; charset=" . $self->{conf}->{report_charset};
   }
 
   # the SpamAssassin report
@@ -761,7 +761,7 @@
   my $ct = $self->{msg}->get_header("Content-Type");
   if (defined $ct && $ct ne '' && $ct !~ m{text/plain}i) {
     $disposition = "attachment";
-    $report .= $self->_replace_tags($self->{conf}->cf_unsafe_report_template);
+    $report .= $self->_replace_tags($self->{conf}->{unsafe_report_template});
     # if we wanted to defang the attachment, this would be the place
   }
   else {
@@ -769,7 +769,7 @@
   }
 
   my $type = "message/rfc822";
-  $type = "text/plain" if $self->{conf}->cf_report_safe > 1;
+  $type = "text/plain" if $self->{conf}->{report_safe} > 1;
 
   my $description = $self->{conf}->{'encapsulated_content_description'};
 
@@ -937,7 +937,7 @@
   $hdr_data = $self->_replace_tags($hdr_data);
   $hdr_data =~ s/(?:\r?\n)+$//; # make sure there are no trailing newlines ...
 
-  if ($self->{conf}->cf_fold_headers) {
+  if ($self->{conf}->{fold_headers}) {
     if ($hdr_data =~ /\n/) {
       $hdr_data =~ s/\s*\n\s*/\n\t/g;
       return $hdr_data;
@@ -1141,7 +1141,7 @@
 
 sub _get_tag_value_for_required_score {
   my $self  = shift;
-  return sprintf("%2.1f", $self->{conf}->cf_required_score);
+  return sprintf("%2.1f", $self->{conf}->{required_score});
 }
 
 sub _get_tag {
@@ -1167,7 +1167,7 @@
             SUBVERSION => sub { $Mail::SpamAssassin::SUB_VERSION },
 
             HOSTNAME => sub {
-	      $self->{conf}->cf_report_hostname ||
+	      $self->{conf}->{report_hostname} ||
 	            Mail::SpamAssassin::Util::fq_hostname();
 	    },
 
@@ -1195,7 +1195,7 @@
               return $lasthop ? $lasthop->{helo} : '';
             },
 
-            CONTACTADDRESS => sub { $self->{conf}->cf_report_contact; },
+            CONTACTADDRESS => sub { $self->{conf}->{report_contact}; },
 
             BAYES => sub {
               defined($self->{bayes_score}) ?
@@ -2294,8 +2294,8 @@
   # Rely on the 'envelope-sender-header' header if the user has configured one.
   # Assume that because they have configured it, their MTA will always add it.
   # This will prevent us falling through and picking up inappropriate headers.
-  if (defined $self->{conf}->cf_envelope_sender_header) {
-    my $hdr = $self->{conf}->cf_envelope_sender_header;
+  my $hdr = $self->{conf}->{envelope_sender_header};
+  if (defined $hdr) {
     # make sure we get the most recent copy - there can be only one EnvelopeSender.
     $envf = $self->get($hdr.":addr");
     # ok if it contains an "@" sign, or is "" (ie. "<>" without the < and >)

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm Mon Aug 20 05:01:40 2007
@@ -124,8 +124,8 @@
 
   # Figure out min/max for autolearning.
   # Default to specified auto_learn_threshold settings
-  my $min = $conf->cf_bayes_auto_learn_threshold_nonspam;
-  my $max = $conf->cf_bayes_auto_learn_threshold_spam;
+  my $min = $conf->{bayes_auto_learn_threshold_nonspam};
+  my $max = $conf->{bayes_auto_learn_threshold_spam};
 
   # Find out what score we should consider this message to have ...
   my $score = $scan->get_autolearn_points();

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/HTMLEval.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/HTMLEval.pm?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/HTMLEval.pm (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/HTMLEval.pm Mon Aug 20 05:01:40 2007
@@ -89,7 +89,7 @@
 
   return 0 unless exists $pms->{html}{charsets};
 
-  my @locales = Mail::SpamAssassin::Util::get_my_locales($pms->{conf}->cf_ok_locales);
+  my @locales = Mail::SpamAssassin::Util::get_my_locales($pms->{conf}->{ok_locales});
   return 0 if grep { $_ eq "all" } @locales;
 
   my $okay = 0;

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/HeaderEval.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/HeaderEval.pm?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/HeaderEval.pm (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/HeaderEval.pm Mon Aug 20 05:01:40 2007
@@ -116,7 +116,7 @@
   my ($self, $pms) = @_;
   my $hdr;
 
-  my @locales = Mail::SpamAssassin::Util::get_my_locales($self->{main}->{conf}->cf_ok_locales);
+  my @locales = Mail::SpamAssassin::Util::get_my_locales($self->{main}->{conf}->{ok_locales});
 
   return 0 if grep { $_ eq "all" } @locales;
 

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/MIMEEval.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/MIMEEval.pm?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/MIMEEval.pm (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Plugin/MIMEEval.pm Mon Aug 20 05:01:40 2007
@@ -68,7 +68,7 @@
 
   my $type = $pms->get('Content-Type');
 
-  my @locales = Mail::SpamAssassin::Util::get_my_locales($self->{main}->{conf}->cf_ok_locales);
+  my @locales = Mail::SpamAssassin::Util::get_my_locales($self->{main}->{conf}->{ok_locales});
 
   return 0 if grep { $_ eq "all" } @locales;
 
@@ -196,7 +196,7 @@
     }
 
     if (! $pms->{mime_faraway_charset}) {
-      my @l = Mail::SpamAssassin::Util::get_my_locales($self->{main}->{conf}->cf_ok_locales);
+      my @l = Mail::SpamAssassin::Util::get_my_locales($self->{main}->{conf}->{ok_locales});
 
       if (!(grep { $_ eq "all" } @l) &&
 	  !Mail::SpamAssassin::Locales::is_charset_ok_for_locales($charset, @l))

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Util/TwoTierHash.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Util/TwoTierHash.pm?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Util/TwoTierHash.pm (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/lib/Mail/SpamAssassin/Util/TwoTierHash.pm Mon Aug 20 05:01:40 2007
@@ -36,13 +36,27 @@
   my $class = shift;
   my $h0 = shift;
   my $h1 = shift;
-  my $self = { h0 => $h0, h1 => $h1 };
+
+  my $self = {
+    h0 => $h0,
+    h1 => $h1,
+    activetier => $h1
+  };
   return bless $self, $class;
 }
 
 sub STORE {
   my ($self, $k, $v) = @_;
-  $self->{h1}->{$k} = $v;
+  if ($k eq 'ACTIVETIER') {
+    if ($v == 0) {
+      $self->{activetier} = $self->{h0};
+    } else {
+      $self->{activetier} = $self->{h1};
+    }
+  }
+  else {
+    $self->{activetier}->{$k} = $v;
+  }
   1;
 }
 
@@ -68,7 +82,7 @@
 
 sub DELETE {
   my ($self, $k) = @_;
-  return delete $self->{h1}->{$k};
+  return delete $self->{activetier}->{$k};
 }
 
 sub FIRSTKEY {
@@ -92,12 +106,12 @@
 
 sub CLEAR {
   my ($self) = @_;
-  $self->{h1} = { };
+  %{$self->{activetier}} = ( );
 }
 
 sub SCALAR {
   my ($self) = @_;
-  return scalar $self->{h1};
+  return scalar $self->{activetier};
 }
 
 1;

Modified: spamassassin/branches/jm_bug_3852_two_level_configs/t/priorities.t
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_bug_3852_two_level_configs/t/priorities.t?rev=567661&r1=567660&r2=567661&view=diff
==============================================================================
--- spamassassin/branches/jm_bug_3852_two_level_configs/t/priorities.t (original)
+++ spamassassin/branches/jm_bug_3852_two_level_configs/t/priorities.t Mon Aug 20 05:01:40 2007
@@ -99,7 +99,7 @@
 sub assert_rule_pri {
   my ($r, $pri) = @_;
 
-  if (defined $conf->{activetier}->{rbl_evals}->{$r}) {
+  if (defined $conf->{rbl_evals}->{$r}) {
     # ignore rbl_evals; they do not use the priority system at all
     return 1;
   }
@@ -109,11 +109,11 @@
     full_evals rawbody_evals head_evals body_evals
   ))
   {
-    if (defined $conf->{activetier}->{$ruletype}->{$pri}->{$r}) {
+    if (defined $conf->{$ruletype}->{$pri}->{$r}) {
       return 1;
     }
-    foreach my $foundpri (keys %{$conf->{activetier}->{priorities}}) {
-      next unless (defined $conf->{activetier}->{$ruletype}->{$foundpri}->{$r});
+    foreach my $foundpri (keys %{$conf->{priorities}}) {
+      next unless (defined $conf->{$ruletype}->{$foundpri}->{$r});
       warn "FAIL: rule '$r' not found at priority $pri; found at $foundpri\n";
       return 0;
     }