spamassassin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j.@apache.org
Subject svn commit: r555664 - in /spamassassin/trunk/lib/Mail: SpamAssassin.pm SpamAssassin/Conf.pm SpamAssassin/Conf/Parser.pm SpamAssassin/Plugin.pm SpamAssassin/Plugin/Check.pm SpamAssassin/Plugin/ReplaceTags.pm
Date Thu, 12 Jul 2007 15:38:10 GMT
Author: jm
Date: Thu Jul 12 08:38:09 2007
New Revision: 555664

URL: http://svn.apache.org/viewvc?view=rev&rev=555664
Log:
bug 5449: allow_user_rules causes Rule2XSBody plugin to emit spurious warnings; fix.  also,
add a new 'user_conf_parsing_end' plugin hook, which is called after the per-user configuration
is parsed

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ReplaceTags.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin.pm?view=diff&rev=555664&r1=555663&r2=555664
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin.pm Thu Jul 12 08:38:09 2007
@@ -1101,10 +1101,8 @@
 
   $self->{conf}->{main} = $self;
   $self->{conf}->parse_scores_only ($text);
-  if ($self->{conf}->{allow_user_rules}) {
-      dbg("config: finishing parsing!");
-      $self->{conf}->finish_parsing();
-  }
+  $self->{conf}->finish_parsing(1);
+
   delete $self->{conf}->{main};	# to allow future GC'ing
 }
 
@@ -1472,7 +1470,7 @@
     dbg('config_text: '.$self->{config_text});
   }
   $self->{conf}->parse_rules ($self->{config_text});
-  $self->{conf}->finish_parsing ();
+  $self->{conf}->finish_parsing(0);
   delete $self->{conf}->{main};	# to allow future GC'ing
 
   undef $self->{config_text};   # ensure it's actually freed

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?view=diff&rev=555664&r1=555663&r2=555664
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Thu Jul 12 08:38:09 2007
@@ -3391,7 +3391,8 @@
 ###########################################################################
 
 sub finish_parsing {
-  my ($self) = shift; $self->{parser}->finish_parsing();
+  my ($self, $user) = @_;
+  $self->{parser}->finish_parsing($user);
 }
 
 ###########################################################################

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm?view=diff&rev=555664&r1=555663&r2=555664
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm Thu Jul 12 08:38:09 2007
@@ -680,12 +680,20 @@
 ###########################################################################
 
 sub finish_parsing {
-  my ($self) = @_;
+  my ($self, $isuserconf) = @_;
   my $conf = $self->{conf};
 
+  # note: this function is called once for system-wide configuration
+  # with $isuserconf set to 0, then again for user conf with $isuserconf set to 1.
+
   $self->trace_meta_dependencies();
   $self->fix_priorities();
-  $self->find_dup_rules();          # must be after fix_priorities()
+
+  # don't do this if allow_user_rules is active, since it deletes entries
+  # from {tests}
+  if (!$conf->{allow_user_rules}) {
+    $self->find_dup_rules();          # must be after fix_priorities()
+  }
 
   dbg("conf: finish parsing");
 
@@ -759,13 +767,19 @@
 
   $self->lint_trusted_networks();
 
-  # named this way just in case we ever want a "finish_parsing_start"
-  $conf->{main}->call_plugins("finish_parsing_end", { conf => $conf });
+  if (!$isuserconf) {
+    # named this way just in case we ever want a "finish_parsing_start"
+    $conf->{main}->call_plugins("finish_parsing_end", { conf => $conf });
+  } else {
+    $conf->{main}->call_plugins("user_conf_parsing_end", { conf => $conf });
+  }
 
-  # free up stuff we no longer need
-  delete $conf->{tests};
-  delete $conf->{priority};
-  delete $conf->{test_types};
+  if (!$conf->{allow_user_rules}) {
+    # free up stuff we no longer need
+    delete $conf->{tests};
+    delete $conf->{priority};
+    delete $conf->{test_types};
+  }
 }
 
 sub trace_meta_dependencies {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm?view=diff&rev=555664&r1=555663&r2=555664
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm Thu Jul 12 08:38:09 2007
@@ -200,8 +200,8 @@
 
 =item $plugin->finish_parsing_end ( { options ... } )
 
-Signals that the configuration parsing has just finished, and SpamAssassin
-is nearly ready to check messages.
+Signals that the system-wide configuration parsing has just finished, and
+SpamAssassin is nearly ready to check messages.
 
 C<options> is a reference to a hash containing these options:
 
@@ -219,6 +219,25 @@
 this plugin hook, if you modify the rules data structures in a
 third-party plugin, all bets are off until such time that an API is
 present for modifying that configuration data.
+
+=item $plugin->user_conf_parsing_end ( { options ... } )
+
+Signals that the per-user configuration parsing has just finished, and
+SpamAssassin is nearly ready to check messages.   If C<allow_user_rules>
+is enabled in the configuration, it is possible that additional rules
+have been added in the user configuration file, since the
+C<finish_parsing_end> plugin hook invocation was called.
+
+C<options> is a reference to a hash containing these options:
+
+=over 4
+
+=item conf
+
+The C<Mail::SpamAssassin::Conf> object on which the configuration
+data should be stored.
+
+=back
 
 =item $plugin->signal_user_changed ( { options ... } )
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm?view=diff&rev=555664&r1=555663&r2=555664
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm Thu Jul 12 08:38:09 2007
@@ -385,6 +385,9 @@
 
         # If we depend on network tests, call ensure_rules_are_complete()
         # to block until they are
+        if (!defined $conf->{meta_dependencies}->{ $metas[$i] }) {
+          warn "no meta_dependencies defined for $metas[$i]";
+        }
         my $alldeps = join ' ', grep {
                 ($tflags->{$_}||'') =~ /\bnet\b/
               } split (' ', $conf->{meta_dependencies}->{ $metas[$i] } );

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ReplaceTags.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ReplaceTags.pm?view=diff&rev=555664&r1=555663&r2=555664
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ReplaceTags.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ReplaceTags.pm Thu Jul 12 08:38:09 2007
@@ -163,6 +163,11 @@
   dbg("replacetags: done replacing tags");
 }
 
+sub user_conf_parsing_end {
+  my ($self, $opts) = @_;
+  return $self->finish_parsing_end($opts);
+}
+
 sub set_config {
   my ($self, $conf) = @_;
   my @cmds = ();



Mime
View raw message