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 2009/08/03 00:25:31 UTC

svn commit: r800152 - in /spamassassin/trunk: ./ MANIFEST MANIFEST.SKIP Makefile.PL contrib/check_spamd sa-awl.raw sa-check_spamd.raw t/sa_awl.t t/sa_check_spamd.t tools/check_whitelist

Author: jm
Date: Sun Aug  2 22:25:31 2009
New Revision: 800152

URL: http://svn.apache.org/viewvc?rev=800152&view=rev
Log:
bug 5873: include check_whitelist and check_spamd in distribution.   Now called 'sa-awl' and 'sa-check_spamd'

Added:
    spamassassin/trunk/sa-awl.raw
      - copied, changed from r799660, spamassassin/trunk/tools/check_whitelist
    spamassassin/trunk/sa-check_spamd.raw
      - copied, changed from r799660, spamassassin/trunk/contrib/check_spamd
    spamassassin/trunk/t/sa_awl.t   (with props)
    spamassassin/trunk/t/sa_check_spamd.t   (with props)
Removed:
    spamassassin/trunk/contrib/check_spamd
    spamassassin/trunk/tools/check_whitelist
Modified:
    spamassassin/trunk/   (props changed)
    spamassassin/trunk/MANIFEST
    spamassassin/trunk/MANIFEST.SKIP
    spamassassin/trunk/Makefile.PL

Propchange: spamassassin/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Aug  2 22:25:31 2009
@@ -24,3 +24,5 @@
 wordfreqs
 MANIFEST.bak
 Build
+sa-check_spamd
+sa-awl

Modified: spamassassin/trunk/MANIFEST
URL: http://svn.apache.org/viewvc/spamassassin/trunk/MANIFEST?rev=800152&r1=800151&r2=800152&view=diff
==============================================================================
--- spamassassin/trunk/MANIFEST (original)
+++ spamassassin/trunk/MANIFEST Sun Aug  2 22:25:31 2009
@@ -118,15 +118,22 @@
 lib/Mail/SpamAssassin/Util/DependencyInfo.pm
 lib/Mail/SpamAssassin/Util/Progress.pm
 lib/Mail/SpamAssassin/Util/RegistrarBoundaries.pm
-lib/Mail/SpamAssassin/Util/TieOneStringHash.pm
 lib/Mail/SpamAssassin/Util/ScopedTimer.pm
+lib/Mail/SpamAssassin/Util/TieOneStringHash.pm
 lib/spamassassin-run.pod
 procmailrc.example
+rules/init.pre
 rules/languages
 rules/local.cf
 rules/regression_tests.cf
 rules/sa-update-pubkey.txt
 rules/user_prefs.template
+rules/v310.pre
+rules/v312.pre
+rules/v320.pre
+rules/v330.pre
+sa-awl.raw
+sa-check_spamd.raw
 sa-compile.raw
 sa-learn.raw
 sa-update.raw
@@ -204,6 +211,7 @@
 t/SATest.pl
 t/SATest.pm
 t/basic_lint.t
+t/basic_meta.t
 t/basic_obj_api.t
 t/bayesbdb.t
 t/bayesdbm.t
@@ -218,8 +226,23 @@
 t/config.dist
 t/config_errs.t
 t/config_text.t
+t/config_tree_recurse.t
 t/cpp_comments_in_spamc.t
 t/data/01_test_rules.cf
+t/data/01_test_rules.pre
+t/data/Dumpheaders.pm
+t/data/dkim/test-adsp-11.msg
+t/data/dkim/test-adsp-12.msg
+t/data/dkim/test-adsp-13.msg
+t/data/dkim/test-adsp-14.msg
+t/data/dkim/test-adsp-15.msg
+t/data/dkim/test-adsp-16.msg
+t/data/dkim/test-adsp-17.msg
+t/data/dkim/test-adsp-18.msg
+t/data/dkim/test-adsp-19.msg
+t/data/dkim/test-adsp-20.msg
+t/data/dkim/test-adsp-21.msg
+t/data/dkim/test-adsp-22.msg
 t/data/dkim/test-fail-01.msg
 t/data/dkim/test-fail-02.msg
 t/data/dkim/test-fail-03.msg
@@ -228,6 +251,7 @@
 t/data/dkim/test-fail-06.msg
 t/data/dkim/test-fail-07.msg
 t/data/dkim/test-fail-08.msg
+t/data/dkim/test-fail-09.msg
 t/data/dkim/test-pass-01.msg
 t/data/dkim/test-pass-02.msg
 t/data/dkim/test-pass-03.msg
@@ -365,6 +389,7 @@
 t/dnsbl.t
 t/dnsbl_sc_meta.t
 t/duplicates.t
+t/get_all_headers.t
 t/get_headers.t
 t/gtube.t
 t/hashcash.t
@@ -375,9 +400,9 @@
 t/ip_addrs.t
 t/lang_lint.t
 t/lang_pl_tests.t
+t/line_endings.t
 t/lint_nocreate_prefs.t
 t/memory_cycles.t
-t/basic_meta.t
 t/metadata.t
 t/mimeheader.t
 t/mimeparse.t
@@ -401,16 +426,30 @@
 t/reportheader.t
 t/reportheader_8bit.t
 t/reuse.t
+t/root_spamd.t
+t/root_spamd_tell.t
+t/root_spamd_tell_paranoid.t
+t/root_spamd_tell_x.t
+t/root_spamd_tell_x_paranoid.t
+t/root_spamd_u.t
+t/root_spamd_u_dcc.t
+t/root_spamd_virtual.t
+t/root_spamd_x.t
+t/root_spamd_x_paranoid.t
+t/root_spamd_x_u.t
 t/rule_multiple.t
 t/rule_names.t
 t/rule_tests.t
 t/rule_types.t
+t/sa_awl.t
+t/sa_check_spamd.t
 t/sha1.t
 t/shortcircuit.t
 t/spam.t
 t/spamc.t
 t/spamc_B.t
 t/spamc_E.t
+t/spamc_H.t
 t/spamc_c.t
 t/spamc_c_stdout_closed.t
 t/spamc_cf.t
@@ -418,6 +457,8 @@
 t/spamc_l.t
 t/spamc_optC.t
 t/spamc_optL.t
+t/spamc_x_E_R.t
+t/spamc_x_e.t
 t/spamc_y.t
 t/spamc_z.t
 t/spamd.t
@@ -451,6 +492,7 @@
 t/spamd_syslog.t
 t/spamd_unix.t
 t/spamd_unix_and_tcp.t
+t/spamd_user_rules_leak.t
 t/spamd_utf8.t
 t/spf.t
 t/sql_based_whitelist.t
@@ -472,28 +514,3 @@
 t/whitelist_subject.t
 t/whitelist_to.t
 t/zz_cleanup.t
-t/line_endings.t
-t/root_spamd.t
-t/root_spamd_tell.t
-t/root_spamd_tell_paranoid.t
-t/root_spamd_tell_x.t
-t/root_spamd_tell_x_paranoid.t
-t/root_spamd_x.t
-t/root_spamd_x_paranoid.t
-t/root_spamd_virtual.t
-t/spamc_H.t
-t/root_spamd_x_u.t
-t/spamc_x_E_R.t
-t/spamc_x_e.t
-t/root_spamd_u.t
-t/root_spamd_u_dcc.t
-t/get_all_headers.t
-t/data/Dumpheaders.pm
-t/spamd_user_rules_leak.t
-t/data/01_test_rules.pre
-t/config_tree_recurse.t
-rules/v310.pre
-rules/v330.pre
-rules/v312.pre
-rules/v320.pre
-rules/init.pre

Modified: spamassassin/trunk/MANIFEST.SKIP
URL: http://svn.apache.org/viewvc/spamassassin/trunk/MANIFEST.SKIP?rev=800152&r1=800151&r2=800152&view=diff
==============================================================================
--- spamassassin/trunk/MANIFEST.SKIP (original)
+++ spamassassin/trunk/MANIFEST.SKIP Sun Aug  2 22:25:31 2009
@@ -109,3 +109,5 @@
 ^t\.rules/
 t/make_install.t
 ^backend/
+^sa-awl$
+^sa-check_spamd$

Modified: spamassassin/trunk/Makefile.PL
URL: http://svn.apache.org/viewvc/spamassassin/trunk/Makefile.PL?rev=800152&r1=800151&r2=800152&view=diff
==============================================================================
--- spamassassin/trunk/Makefile.PL (original)
+++ spamassassin/trunk/Makefile.PL Sun Aug  2 22:25:31 2009
@@ -137,7 +137,9 @@
       'spamassassin.raw' => 'spamassassin',
       'sa-learn.raw'     => 'sa-learn',
       'sa-update.raw'    => 'sa-update',
-      'sa-compile.raw'    => 'sa-compile',
+      'sa-compile.raw'   => 'sa-compile',
+      'sa-awl.raw'       => 'sa-awl',
+      'sa-check_spamd.raw' => 'sa-check_spamd',
       'spamc/spamc.c'    => 'spamc/spamc$(EXE_EXT)',
       'spamd/spamd.raw'  => 'spamd/spamd',
     },
@@ -1027,6 +1029,12 @@
 sa-compile: sa-compile.raw
 	$(PREPROCESS) $(FIXBYTES) $(FIXVARS) $(FIXBANG) -m$(PERM_RWX) -isa-compile.raw -osa-compile
 
+sa-awl: sa-awl.raw
+	$(PREPROCESS) $(FIXBYTES) $(FIXVARS) $(FIXBANG) -m$(PERM_RWX) -isa-awl.raw -osa-awl
+
+sa-check_spamd: sa-check_spamd.raw
+	$(PREPROCESS) $(FIXBYTES) $(FIXVARS) $(FIXBANG) -m$(PERM_RWX) -isa-check_spamd.raw -osa-check_spamd
+
 spamd/spamd: spamd/spamd.raw
 	$(PREPROCESS) $(FIXBYTES) $(FIXVARS) $(FIXBANG) -m$(PERM_RWX) -i$? -o$@
 

Copied: spamassassin/trunk/sa-awl.raw (from r799660, spamassassin/trunk/tools/check_whitelist)
URL: http://svn.apache.org/viewvc/spamassassin/trunk/sa-awl.raw?p2=spamassassin/trunk/sa-awl.raw&p1=spamassassin/trunk/tools/check_whitelist&r1=799660&r2=800152&rev=800152&view=diff
==============================================================================
--- spamassassin/trunk/tools/check_whitelist (original)
+++ spamassassin/trunk/sa-awl.raw Sun Aug  2 22:25:31 2009
@@ -1,14 +1,50 @@
 #!/usr/bin/perl
-#
-# TODO: should this be made a top-level script, called "sa-awl"?
+
+my $PREFIX          = '@@PREFIX@@';             # substituted at 'make' time
+my $DEF_RULES_DIR   = '@@DEF_RULES_DIR@@';      # substituted at 'make' time
+my $LOCAL_RULES_DIR = '@@LOCAL_RULES_DIR@@';    # substituted at 'make' time
+my $LOCAL_STATE_DIR = '@@LOCAL_STATE_DIR@@';    # substituted at 'make' time
+use lib '@@INSTALLSITELIB@@';                   # substituted at 'make' time
+
+use strict;
+use warnings;
+use re 'taint';
+
+use Errno qw(EBADF);
+use File::Spec;
+use Config;
+
+BEGIN {                          # see comments in "spamassassin.raw" for doco
+  my @bin = File::Spec->splitpath($0);
+  my $bin = ($bin[0] ? File::Spec->catpath(@bin[0..1]) : $bin[1])
+            || File::Spec->curdir;
+
+  if (-e $bin.'/lib/Mail/SpamAssassin.pm'
+        || !-e '@@INSTALLSITELIB@@/Mail/SpamAssassin.pm' )
+  {
+    my $searchrelative;
+    $searchrelative = 1;    # disabled during "make install": REMOVEFORINST
+    if ($searchrelative && $bin eq '../' && -e '../blib/lib/Mail/SpamAssassin.pm')
+    {
+      unshift ( @INC, '../blib/lib' );
+    } else {
+      foreach ( qw(lib ../lib/site_perl
+                ../lib/spamassassin ../share/spamassassin/lib))
+      {
+        my $dir = File::Spec->catdir( $bin, split ( '/', $_ ) );
+        if ( -f File::Spec->catfile( $dir, "Mail", "SpamAssassin.pm" ) )
+        { unshift ( @INC, $dir ); last; }
+      }
+    }
+  }
+}
 
 sub usage {
   die "
-usage: check_whitelist [--clean] [--min n] [dbfile]
+usage: sa-awl [--clean] [--min n] [dbfile]
 ";
 }
 
-use strict;
 use Fcntl;
 use Getopt::Long;
 
@@ -69,11 +105,11 @@
 
 =head1 NAME
 
-check_whitelist - examine and manipulate SpamAssassin's auto-whitelist db
+sa-awl - examine and manipulate SpamAssassin's auto-whitelist db
 
 =head1 SYNOPSIS
 
-B<check_whitelist> [--clean] [--min n] [dbfile]
+B<sa-awl> [--clean] [--min n] [dbfile]
 
 =head1 DESCRIPTION
 

Copied: spamassassin/trunk/sa-check_spamd.raw (from r799660, spamassassin/trunk/contrib/check_spamd)
URL: http://svn.apache.org/viewvc/spamassassin/trunk/sa-check_spamd.raw?p2=spamassassin/trunk/sa-check_spamd.raw&p1=spamassassin/trunk/contrib/check_spamd&r1=799660&r2=800152&rev=800152&view=diff
==============================================================================
--- spamassassin/trunk/contrib/check_spamd (original)
+++ spamassassin/trunk/sa-check_spamd.raw Sun Aug  2 22:25:31 2009
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w -T
+#!/usr/bin/perl -w
 
 ########################################################################
 #
@@ -22,15 +22,53 @@
 ########################################################################
 
 # Written by Daryl C. W. O'Shea, DOS Technologies <sp...@dostech.ca>
-# See  perldoc check_spamd  for program info.
+# See  perldoc sa-check_spamd  for program info.
+
+my $PREFIX          = '@@PREFIX@@';             # substituted at 'make' time
+my $DEF_RULES_DIR   = '@@DEF_RULES_DIR@@';      # substituted at 'make' time
+my $LOCAL_RULES_DIR = '@@LOCAL_RULES_DIR@@';    # substituted at 'make' time
+my $LOCAL_STATE_DIR = '@@LOCAL_STATE_DIR@@';    # substituted at 'make' time
+use lib '@@INSTALLSITELIB@@';                   # substituted at 'make' time
 
 use strict;
+use warnings;
+use re 'taint';
+
+use Errno qw(EBADF);
+use File::Spec;
+use Config;
+
+BEGIN {                          # see comments in "spamassassin.raw" for doco
+  my @bin = File::Spec->splitpath($0);
+  my $bin = ($bin[0] ? File::Spec->catpath(@bin[0..1]) : $bin[1])
+            || File::Spec->curdir;
+
+  if (-e $bin.'/lib/Mail/SpamAssassin.pm'
+        || !-e '@@INSTALLSITELIB@@/Mail/SpamAssassin.pm' )
+  {
+    my $searchrelative;
+    $searchrelative = 1;    # disabled during "make install": REMOVEFORINST
+    if ($searchrelative && $bin eq '../' && -e '../blib/lib/Mail/SpamAssassin.pm')
+    {
+      unshift ( @INC, '../blib/lib' );
+    } else {
+      foreach ( qw(lib ../lib/site_perl
+                ../lib/spamassassin ../share/spamassassin/lib))
+      {
+        my $dir = File::Spec->catdir( $bin, split ( '/', $_ ) );
+        if ( -f File::Spec->catfile( $dir, "Mail", "SpamAssassin.pm" ) )
+        { unshift ( @INC, $dir ); last; }
+      }
+    }
+  }
+}
 
 use Getopt::Long;
 
 use constant HAS_TIME_HIRES => eval { require Time::HiRes; };
 use constant HAS_MSA_CLIENT => eval { require Mail::SpamAssassin::Client; };
 use constant HAS_MSA_TIMEOUT => eval { require Mail::SpamAssassin::Timeout; };
+use Mail::SpamAssassin::Util;
 
 ### nagios plugin return codes: 0 OK / 1 Warning / 2 Critical / 3 Unknown ###
 use constant EX_OK	 => 0;
@@ -38,7 +76,7 @@
 use constant EX_CRITICAL => 2;
 use constant EX_UNKNOWN	 => 3;
 
-my $VERSION = "0.01";
+my $VERSION = $Mail::SpamAssassin::VERSION;
 
 my %opt = (
   'critical'	=> undef,
@@ -60,7 +98,7 @@
   'socketpath=s'	=> \$opt{'socketpath'},
   'timeout|t=s'		=> \$opt{'timeout'},
   'verbose|v'		=> \$opt{'verbose'},
-  'version|V'		=> sub { print "check_spamd version $VERSION\n"; exit EX_UNKNOWN; },
+  'version|V'		=> sub { print "sa-check_spamd version $VERSION\n"; exit EX_UNKNOWN; },
   'warning|w=s'		=> \$opt{'warning'},
 
 ) or print_usage_and_exit();
@@ -158,6 +196,14 @@
 }
 
 
+# untaint the command-line args; since the root user supplied these, and
+# we're not a setuid script, we trust them.  This needs to be called explicitly
+foreach my $optkey (keys %opt) {
+  next if ref $opt{$optkey};
+  Mail::SpamAssassin::Util::untaint_var(\$opt{$optkey});
+}
+
+
 # If the client connection fails it'll spit out it's own error message which
 # is probably more appropriate than anything we can provide to Nagios ourself.
 # We'll still spit out something later, but Nagios will ignore it since it
@@ -242,12 +288,12 @@
 
 sub print_usage_and_exit {
   print <<EOF;
-check_spamd version $VERSION
+sa-check_spamd version $VERSION
 
-For more details, use "perldoc check_spamd".
+For more details, use "perldoc sa-check_spamd".
 
 Usage:
-   check_spamd [options]
+   sa-check_spamd [options]
 
     Options:
 
@@ -270,11 +316,11 @@
 
 =head1 NAME
 
-check_spamd - spamd monitoring script for use with Nagios, etc.
+sa-check_spamd - spamd monitoring script for use with Nagios, etc.
 
 =head1 SYNOPSIS
 
-check_spamd [options]
+sa-check_spamd [options]
 
 Options:
 
@@ -390,7 +436,7 @@
 =item 3
 
 UNKNOWN: An error, probably caused by a missing dependency or an invalid
-configuration parameter being supplied, occurred in the check_spamd program.
+configuration parameter being supplied, occurred in the sa-check_spamd program.
 
 =back
 
@@ -410,7 +456,7 @@
 
 =head1 LICENSE
 
-check_spamd is distributed under the Apache License, Version 2.0, as
+sa-check_spamd is distributed under the Apache License, Version 2.0, as
 described in the file C<LICENSE> included with the Apache SpamAssassin
 distribution and available at http://www.apache.org/licenses/LICENSE-2.0
 

Added: spamassassin/trunk/t/sa_awl.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/sa_awl.t?rev=800152&view=auto
==============================================================================
--- spamassassin/trunk/t/sa_awl.t (added)
+++ spamassassin/trunk/t/sa_awl.t Sun Aug  2 22:25:31 2009
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+
+use lib '.'; use lib 't';
+use SATest; sa_t_init("sa_awl");
+use Test; BEGIN { plan tests => 1 };
+
+# ---------------------------------------------------------------------------
+
+%patterns = (
+  q{ X-Spam-Status: Yes}, 'isspam',
+);
+
+tstprefs ("
+        $default_cf_lines
+        auto_whitelist_path ./log/awltest
+        auto_whitelist_file_mode 0755
+");
+
+sarun("--add-addr-to-whitelist whitelist_test\@whitelist.spamassassin.taint.org",
+      \&patterns_run_cb);
+
+system("pwd");
+system("../sa-awl --clean --min 9999 ./log/awltest");
+
+sarun ("-L -t < data/spam/004", \&patterns_run_cb);
+ok_all_patterns();
+

Propchange: spamassassin/trunk/t/sa_awl.t
------------------------------------------------------------------------------
    svn:executable = *

Added: spamassassin/trunk/t/sa_check_spamd.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/sa_check_spamd.t?rev=800152&view=auto
==============================================================================
--- spamassassin/trunk/t/sa_check_spamd.t (added)
+++ spamassassin/trunk/t/sa_check_spamd.t Sun Aug  2 22:25:31 2009
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+use lib '.'; use lib 't';
+use SATest; sa_t_init("sa-check_spamd");
+use Test; BEGIN { plan tests => ($SKIP_SPAMD_TESTS ? 0 : 7) };
+
+exit if $SKIP_SPAMD_TESTS;
+
+# ---------------------------------------------------------------------------
+
+%patterns = (
+
+q{ X-Spam-Status: Yes, score=}, 'status',
+q{ X-Spam-Flag: YES}, 'flag',
+
+);
+
+ok(start_spamd("-L"));
+
+ok(spamcrun("< data/spam/001", \&patterns_run_cb));
+ok_all_patterns();
+
+my $p = $spamdport;
+system("../sa-check_spamd --hostname 127.0.0.1 --port $p --verbose");
+ok (($? >> 8) == 0);
+
+ok(stop_spamd());
+
+system("../sa-check_spamd --hostname 127.0.0.1 --port $p --verbose");
+ok (($? >> 8) != 0);

Propchange: spamassassin/trunk/t/sa_check_spamd.t
------------------------------------------------------------------------------
    svn:executable = *