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/07/23 12:23:10 UTC
svn commit: r558682 - in /spamassassin/branches/3.2/lib/Mail:
SpamAssassin.pm SpamAssassin/Conf.pm SpamAssassin/Conf/Parser.pm
SpamAssassin/Plugin.pm SpamAssassin/Plugin/Check.pm
SpamAssassin/Plugin/ReplaceTags.pm
Author: jm
Date: Mon Jul 23 03:23:09 2007
New Revision: 558682
URL: http://svn.apache.org/viewvc?view=rev&rev=558682
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/branches/3.2/lib/Mail/SpamAssassin.pm
spamassassin/branches/3.2/lib/Mail/SpamAssassin/Conf.pm
spamassassin/branches/3.2/lib/Mail/SpamAssassin/Conf/Parser.pm
spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin.pm
spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin/Check.pm
spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin/ReplaceTags.pm
Modified: spamassassin/branches/3.2/lib/Mail/SpamAssassin.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.2/lib/Mail/SpamAssassin.pm?view=diff&rev=558682&r1=558681&r2=558682
==============================================================================
--- spamassassin/branches/3.2/lib/Mail/SpamAssassin.pm (original)
+++ spamassassin/branches/3.2/lib/Mail/SpamAssassin.pm Mon Jul 23 03:23: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
}
@@ -1469,7 +1467,7 @@
# Go and parse the config!
$self->{conf}->{main} = $self;
$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/branches/3.2/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.2/lib/Mail/SpamAssassin/Conf.pm?view=diff&rev=558682&r1=558681&r2=558682
==============================================================================
--- spamassassin/branches/3.2/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/branches/3.2/lib/Mail/SpamAssassin/Conf.pm Mon Jul 23 03:23: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/branches/3.2/lib/Mail/SpamAssassin/Conf/Parser.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.2/lib/Mail/SpamAssassin/Conf/Parser.pm?view=diff&rev=558682&r1=558681&r2=558682
==============================================================================
--- spamassassin/branches/3.2/lib/Mail/SpamAssassin/Conf/Parser.pm (original)
+++ spamassassin/branches/3.2/lib/Mail/SpamAssassin/Conf/Parser.pm Mon Jul 23 03:23: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/branches/3.2/lib/Mail/SpamAssassin/Plugin.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin.pm?view=diff&rev=558682&r1=558681&r2=558682
==============================================================================
--- spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin.pm (original)
+++ spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin.pm Mon Jul 23 03:23: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/branches/3.2/lib/Mail/SpamAssassin/Plugin/Check.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin/Check.pm?view=diff&rev=558682&r1=558681&r2=558682
==============================================================================
--- spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin/Check.pm (original)
+++ spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin/Check.pm Mon Jul 23 03:23: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/branches/3.2/lib/Mail/SpamAssassin/Plugin/ReplaceTags.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin/ReplaceTags.pm?view=diff&rev=558682&r1=558681&r2=558682
==============================================================================
--- spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin/ReplaceTags.pm (original)
+++ spamassassin/branches/3.2/lib/Mail/SpamAssassin/Plugin/ReplaceTags.pm Mon Jul 23 03:23: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 = ();