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 2005/11/17 02:55:17 UTC

svn commit: r345165 - in /spamassassin/trunk/build/automc: automc-by-mail buildbot_ready run_preflight

Author: jm
Date: Wed Nov 16 17:55:14 2005
New Revision: 345165

URL: http://svn.apache.org/viewcvs?rev=345165&view=rev
Log:
added mass-check-by-mail script and functionality

Added:
    spamassassin/trunk/build/automc/automc-by-mail   (with props)
Modified:
    spamassassin/trunk/build/automc/buildbot_ready
    spamassassin/trunk/build/automc/run_preflight

Added: spamassassin/trunk/build/automc/automc-by-mail
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/build/automc/automc-by-mail?rev=345165&view=auto
==============================================================================
--- spamassassin/trunk/build/automc/automc-by-mail (added)
+++ spamassassin/trunk/build/automc/automc-by-mail Wed Nov 16 17:55:14 2005
@@ -0,0 +1,110 @@
+#!/local/perl586/bin/perl
+
+use LWP::Simple;
+use MIME::Parser;
+
+# where the files are saved
+my $OUT_DIR = "/home/bbmass/bymail";
+
+# URL used to trigger the buildbot to build
+my $BB_URL = 'http://buildbot.spamassassin.org/preflight/__SLAVE__'.
+		'/force?username=mail&comments=__WHY__';
+
+# name of the Buildbot slaves to trigger
+my @SLAVES = qw(
+
+	  	mc-fast mc-med mc-slow mc-slower
+
+	);
+
+# feel free to add your name here -- or that of anyone you want
+# to allow to use this system
+my $ALLOWED_MAIL_PEOPLE = qr/^(?:
+
+		jm\@jmason\.org|
+		quinlan\@pathname\.com|
+		duncf\@debian\.org
+
+	)/isx;
+
+my $EXTRACT_LOG = "$OUT_DIR/extract.log";
+my $LATEST_CF =   "$OUT_DIR/latest.cf";
+
+# ---------------------------------------------------------------------------
+
+use strict;
+use warnings;
+
+open (STDOUT, ">$EXTRACT_LOG") or die "cannot redir STDOUT to $EXTRACT_LOG";
+open (STDERR, ">&STDOUT") or die "cannot redir STDERR";
+chmod 0666, $EXTRACT_LOG;
+
+my $parser = new MIME::Parser;
+(-d "$OUT_DIR/tmp") || mkdir("$OUT_DIR/tmp", 0700);
+$parser->output_dir("$OUT_DIR/tmp");
+
+my $ent = $parser->parse(\*STDIN) or die "parse failed\n";
+$ent->dump_skeleton();
+my $from = $ent->head()->get("From");
+if ($from =~ /<(.*?)>/) {
+  $from = $1;
+}
+else {
+  $from =~ s/\s*\(.*?\)\s*//;
+}
+
+if ($from !~ $ALLOWED_MAIL_PEOPLE) {
+  print "$from is not on the 'allowed' list, ignoring";
+  goto done;
+}
+
+foreach my $part ($ent->parts) {
+  my $ctype = $part->head->get("Content-Type") || '';
+  my $disp = $part->head->get("Content-Disposition") || '';
+  my $desc = $part->head->get("Content-Description") || '';
+
+  my $fname;
+  if ($desc && $desc =~ /\S/) {
+    chomp $desc; $fname = $desc;
+  } elsif ($disp && $disp =~ /filename=\"([^\"]+)\"/) {
+    $fname = $1;
+  } elsif ($disp && $disp =~ /filename=\'([^\']+)\'/) {
+    $fname = $1;
+  } elsif ($disp && $disp =~ /filename=([^\;\s]+)/) {
+    $fname = $1;
+  }
+
+  warn "part: (type=$ctype / disp=$disp)\n";
+
+  if ($ctype !~ /^text.plain\b/) {
+    warn "skipping part: not text/plain";
+    next;
+  }
+
+  if (!$fname || $fname !~ /\.cf$/) {
+    warn "skipping part: filename isn't 'something.cf'";
+    next;
+  }
+
+  open (SAVE, ">$LATEST_CF") or die "cannot save to $LATEST_CF";
+  $part->print_body(\*SAVE);
+  close SAVE or die "cannot write to $LATEST_CF";
+  chmod 0666, "$LATEST_CF";
+
+  system ("ls -l $LATEST_CF");
+
+  foreach my $slave (@SLAVES) {
+    my $url = $BB_URL;
+    $url =~ s/__SLAVE__/$slave/gs;
+    $url =~ s/__WHY__/mail/gs;
+
+    print "TODO: get $url\n";
+    # my $text = get($url);
+    # print $text;
+  }
+}
+
+done:
+$ent->purge();
+exit;
+

Propchange: spamassassin/trunk/build/automc/automc-by-mail
------------------------------------------------------------------------------
    svn:executable = *

Modified: spamassassin/trunk/build/automc/buildbot_ready
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/build/automc/buildbot_ready?rev=345165&r1=345164&r2=345165&view=diff
==============================================================================
--- spamassassin/trunk/build/automc/buildbot_ready (original)
+++ spamassassin/trunk/build/automc/buildbot_ready Wed Nov 16 17:55:14 2005
@@ -4,6 +4,9 @@
 use warnings;
 sub run;
 
+my $BYMAILLOG = '/home/bbmass/bymail/extract.log';
+my $BYMAILCF = '/home/bbmass/bymail/latest.cf';
+
 my $LOCKDIR = "/home/bbmass/mclocks";
 my $got_lock = undef;
 
@@ -36,11 +39,25 @@
   # system ("svn info --non-interactive > masses/svninfo.tmp");
   system ("svn info > masses/svninfo.tmp < /dev/null");
 
-  if (!perform_singleton_actions()) {
-    # give the "winning" slave time to do the work we also need done
-    print "sleeping for 60 seconds so that corpus is rebuilt\n";
-    sleep 60;
+  if (-f $BYMAILCF) {
+    print "\nFound recent rules-by-mail rules file:\n\n";
+    system ("cp $BYMAILCF masses/mailed.cf");
+    print ("-" x 75), "\n";
+    system ("cat masses/mailed.cf");
+    print ("-" x 75), "\n";
+  } else {
+    unlink "masses/mailed.cf";
+  }
+  if (-f $BYMAILLOG) {
+    print "\nRules-by-mail extraction log:\n\n";
+    system ("cat $BYMAILLOG");
   }
+
+  # if (!perform_singleton_actions()) {
+    # # give the "winning" slave time to do the work we also need done
+    # print "sleeping for 60 seconds so that corpus is rebuilt\n";
+    # sleep 60;
+  # }
 }
 
 sub perform_singleton_actions {

Modified: spamassassin/trunk/build/automc/run_preflight
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/build/automc/run_preflight?rev=345165&r1=345164&r2=345165&view=diff
==============================================================================
--- spamassassin/trunk/build/automc/run_preflight (original)
+++ spamassassin/trunk/build/automc/run_preflight Wed Nov 16 17:55:14 2005
@@ -3,6 +3,9 @@
 use strict;
 sub run;
 
+my $BYMAILCF = '/home/bbmass/bymail/latest.cf';
+
+
 my $perl = $^X;
 if (!$perl) {
   die "no perl path found in ARGV!";
@@ -24,6 +27,8 @@
 #
 chdir "masses" or die;
 
+unlink ("ham.log", "spam.log");
+
 # just the sandbox rules and the timing plugin
 #
 system ("rm -rf tstrules");
@@ -31,6 +36,26 @@
 run "cp ../rules/70_sandbox.cf tstrules";
 run "cp plugins/*.* tstrules";
 
+# well, ok just those, and anything that's been mailed-in
+# 
+if (-f 'mailed.cf') {
+  run "cp mailed.cf tstrules/70_mailed.cf";
+}
+
+run "ls -l tstrules";
+
+# lint those rule files, and abort if they fail; this is a sanity check
+# now that we have mailed-in rules used in this mass-check
+#
+if (run ("../spamassassin --lint -C tstrules", 1) != 0) {
+  warn "*** lint failed; exiting without mass-check! ***\n\n";
+
+  warn "Deleting 'mailed.cf', if it exists.\n"; unlink $BYMAILCF;
+warn "Rule files:\n"; system ("cat tstrules/*.cf");
+
+  die "lint failure";
+}
+
 # notes on this mass-check command:
 #
 # this is run in a chroot jail, just in case there's hostile rule code in
@@ -55,6 +80,8 @@
 
   if (!$ignoreexit) {
     die "command '$cmd' failed with status $?" if (($? >> 8) != 0);
+  } else {
+    return ($? >> 8);
   }
 }