You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by do...@apache.org on 2006/11/17 04:09:42 UTC

svn commit: r476035 - in /spamassassin/trunk: lib/Mail/SpamAssassin.pm sa-update.raw

Author: dos
Date: Thu Nov 16 19:09:41 2006
New Revision: 476035

URL: http://svn.apache.org/viewvc?view=rev&rev=476035
Log:
bug 5171: load site pre files when lint checking sa-update channel updates

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin.pm
    spamassassin/trunk/sa-update.raw

Modified: spamassassin/trunk/lib/Mail/SpamAssassin.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin.pm?view=diff&rev=476035&r1=476034&r2=476035
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin.pm Thu Nov 16 19:09:41 2006
@@ -236,6 +236,12 @@
 If set to 1, no tests that require internet access will be performed. (default:
 0)
 
+=item ignore_site_cf_files
+
+If set to 1, any rule files found in the C<site_rules_filename> directory will
+be ignored.  *.pre files (used for loading plugins) found in the
+C<site_rules_filename> directory will still be used. (default: 0)
+
 =item dont_copy_prefs
 
 If set to 1, the user preferences file will not be created if it doesn't
@@ -1411,7 +1417,7 @@
       $self->{languages_filename} = $self->find_rule_support_file("languages");
     }
 
-    if ($siterules) {
+    if ($siterules && !$self->{ignore_site_cf_files}) {
       $self->{config_text} .= $self->read_cf($siterules, 'site rules dir');
     }
 

Modified: spamassassin/trunk/sa-update.raw
URL: http://svn.apache.org/viewvc/spamassassin/trunk/sa-update.raw?view=diff&rev=476035&r1=476034&r2=476035
==============================================================================
--- spamassassin/trunk/sa-update.raw (original)
+++ spamassassin/trunk/sa-update.raw Thu Nov 16 19:09:41 2006
@@ -383,6 +383,9 @@
 # Use a temporary directory for all update channels
 my $UPDTmp;
 
+# we only need to lint the site pre files once
+my $site_pre_linted = 0;
+
 # Go ahead and loop through all of the channels
 foreach my $channel (@channels) {
   dbg("channel: attempting channel $channel");
@@ -450,6 +453,30 @@
     next;
   }
 
+  # we need a directory we control that we can use to aviod loading any rules
+  # when we lint the site pre files, we might as well use the channel temp dir
+  dbg("channel: preparing temp directory for new channel");
+  if (!$UPDTmp) {
+    $UPDTmp = Mail::SpamAssassin::Util::secure_tmpdir();
+    dbg("generic: update tmp directory $UPDTmp");
+  }
+  elsif (!clean_update_dir($UPDTmp)) {
+    die "channel: attempt to clean update dir failed, aborting";
+  }
+
+  # lint the site pre files (that will be used when lint checking the channel)
+  # before downloading the channel update
+  unless ($site_pre_linted) {
+    dbg("generic: lint checking site pre files once before attempting channel updates");
+    unless (lint_check_dir(File::Spec->catfile($UPDTmp, "doesnotexist"))) {
+      dbg("generic: lint of site pre files failed, cannot continue"); 
+      $exit = 2;
+      last;
+    }
+    dbg("generic: lint check of site pre files succeeded, continuing with channel updates");
+    $site_pre_linted = 1;
+  }
+
   # Read in the MIRRORED.BY file if it exists
   if (open(MIRBY, $mirby_path)) {
     local $/ = undef;
@@ -692,15 +719,6 @@
   # OK, we're all validated at this point, install the new version
   dbg("channel: file verification passed, testing update");
 
-  dbg("channel: preparing temp directory for new channel");
-  if (!$UPDTmp) {
-    $UPDTmp = Mail::SpamAssassin::Util::secure_tmpdir();
-    dbg("generic: update tmp directory $UPDTmp");
-  }
-  elsif (!clean_update_dir($UPDTmp)) {
-    die "channel: attempt to clean update dir failed, aborting";
-  }
-
   dbg("channel: extracting archive");
   if (!taint_safe_archive_extract($UPDTmp, $content_file)) {
     channel_failed("channel: archive extraction failed");
@@ -1246,17 +1264,18 @@
   # Logger setup), we can't change the debug level here to only include
   # "config" or otherwise be more terse. :(
   my $spamtest = new Mail::SpamAssassin( {
-    rules_filename      => $dir,
-    site_rules_filename => File::Spec->catfile($dir, "doesnotexist"),
-    userprefs_filename  => File::Spec->catfile($dir, "doesnotexist"),
-
-    local_tests_only    => 1,
-    dont_copy_prefs     => 1,
-
-    PREFIX              => $PREFIX,
-    DEF_RULES_DIR       => $DEF_RULES_DIR,
-    LOCAL_RULES_DIR     => $LOCAL_RULES_DIR,
-    LOCAL_STATE_DIR     => $LOCAL_STATE_DIR,
+    rules_filename       => $dir,
+    site_rules_filename  => $LOCAL_RULES_DIR,
+    ignore_site_cf_files => 1,
+    userprefs_filename   => File::Spec->catfile($dir, "doesnotexist"),
+
+    local_tests_only     => 1,
+    dont_copy_prefs      => 1,
+
+    PREFIX               => $PREFIX,
+    DEF_RULES_DIR        => $DEF_RULES_DIR,
+    LOCAL_RULES_DIR      => $LOCAL_RULES_DIR,
+    LOCAL_STATE_DIR      => $LOCAL_STATE_DIR,
   });
 
   # need to kluge disabling bayes since it may try to expire the DB, and
@@ -1436,6 +1455,10 @@
 installed successfully if --checkonly was not specified.
 
 An exit code of C<1> means no fresh updates were available.
+
+An exit code of C<2> means that at least one update is available but that a
+lint check of the site pre files failed.  The site pre files must pass a lint
+check before any updates are attempted.
 
 An exit code of C<4> or higher, indicates that errors occurred while
 attempting to download and extract updates.