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 2006/10/18 12:20:00 UTC

svn commit: r465198 - in /spamassassin/trunk: MANIFEST lib/spamassassin-run.pod sa-learn.raw spamassassin.raw spamd/spamd.raw t/config_text.t

Author: jm
Date: Wed Oct 18 03:19:57 2006
New Revision: 465198

URL: http://svn.apache.org/viewvc?view=rev&rev=465198
Log:
add --cf switch to spamassassin, spamd, and sa-learn.  This allows the user to provide additional lines of configuration (or rules) directly from the command-line; surprisingly handy

Added:
    spamassassin/trunk/t/config_text.t   (with props)
Modified:
    spamassassin/trunk/MANIFEST
    spamassassin/trunk/lib/spamassassin-run.pod
    spamassassin/trunk/sa-learn.raw
    spamassassin/trunk/spamassassin.raw
    spamassassin/trunk/spamd/spamd.raw

Modified: spamassassin/trunk/MANIFEST
URL: http://svn.apache.org/viewvc/spamassassin/trunk/MANIFEST?view=diff&rev=465198&r1=465197&r2=465198
==============================================================================
--- spamassassin/trunk/MANIFEST (original)
+++ spamassassin/trunk/MANIFEST Wed Oct 18 03:19:57 2006
@@ -269,6 +269,7 @@
 t/cidrs.t
 t/config.dist
 t/config_errs.t
+t/config_text.t
 t/cpp_comments_in_spamc.t
 t/data/01_test_rules.cf
 t/data/etc/hello.txt

Modified: spamassassin/trunk/lib/spamassassin-run.pod
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/spamassassin-run.pod?view=diff&rev=465198&r1=465197&r2=465198
==============================================================================
--- spamassassin/trunk/lib/spamassassin-run.pod (original)
+++ spamassassin/trunk/lib/spamassassin-run.pod Wed Oct 18 03:19:57 2006
@@ -44,6 +44,7 @@
                                    Set user preferences file
  --siteconfigpath=path             Path for site configs
                                    (def: /etc/mail/spamassassin)
+ --cf='config line'                Additional line of configuration
  -x, --nocreate-prefs              Don't create user preferences file
  -e, --exit-code                   Exit with a non-zero exit code if the
                                    tested message was spam
@@ -237,6 +238,15 @@
 
 Use the specified path for locating site-specific configuration files.  Ignore
 the default directories (usually C</etc/mail/spamassassin> or similar).
+
+=item B<--cf='config line'>
+
+Add additional lines of configuration directly from the command-line, parsed
+after the configuration files are read.   Multiple B<--cf> arguments can be
+used, and each will be considered a separate line of configuration.  For
+example:
+
+        spamassassin -t --cf="body NEWRULE /text/" --cf="score NEWRULE 3.0"
 
 =item B<-p> I<prefs>, B<--prefspath>=I<prefs>, B<--prefs-file>=I<prefs>
 

Modified: spamassassin/trunk/sa-learn.raw
URL: http://svn.apache.org/viewvc/spamassassin/trunk/sa-learn.raw?view=diff&rev=465198&r1=465197&r2=465198
==============================================================================
--- spamassassin/trunk/sa-learn.raw (original)
+++ spamassassin/trunk/sa-learn.raw Wed Oct 18 03:19:57 2006
@@ -85,7 +85,8 @@
 %opt = (
   'force-expire' => 0,
   'use-ignores'  => 0,
-  'nosync'    => 0,
+  'nosync'       => 0,
+  'cf'           => []
 );
 
 Getopt::Long::Configure(
@@ -104,6 +105,7 @@
   'configpath|config-file|config-dir|c|C=s' => \$opt{'configpath'},
   'prefspath|prefs-file|p=s'                => \$opt{'prefspath'},
   'siteconfigpath=s'                        => \$opt{'siteconfigpath'},
+  'cf=s'                                    => \@{$opt{'cf'}},
 
   'folders|f=s'          => \$opt{'folders'},
   'force-expire|expire'  => \$opt{'force-expire'},
@@ -216,6 +218,8 @@
   $post_config .= "use_bayes 1\n";
 }
 
+$post_config .= join("\n", @{$opt{'cf'}})."\n";
+
 # create the tester factory
 $spamtest = new Mail::SpamAssassin(
   {
@@ -585,6 +589,7 @@
  -C path, --configpath=path, --config-file=path   Path to standard configuration dir
  -p prefs, --prefspath=file, --prefs-file=file    Set user preferences file
  --siteconfigpath=path             Path for site configs (def: /etc/mail/spamassassin)
+ --cf='config line'                Additional line of configuration
  -D, --debug-level                 Print debugging messages
  -V, --version                     Print version
  -h, --help                        Print usage message
@@ -738,6 +743,12 @@
 
 Use the specified path for locating site-specific configuration files.  Ignore
 the default directories (usually C</etc/mail/spamassassin> or similar).
+
+=item B<--cf='config line'>
+
+Add additional lines of configuration directly from the command-line, parsed
+after the configuration files are read.   Multiple B<--cf> arguments can be
+used, and each will be considered a separate line of configuration.
 
 =item B<-p> I<prefs>, B<--prefspath>=I<prefs>, B<--prefs-file>=I<prefs>
 

Modified: spamassassin/trunk/spamassassin.raw
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamassassin.raw?view=diff&rev=465198&r1=465197&r2=465198
==============================================================================
--- spamassassin/trunk/spamassassin.raw (original)
+++ spamassassin/trunk/spamassassin.raw Wed Oct 18 03:19:57 2006
@@ -152,7 +152,7 @@
 # - create user preference files
 # - have ArchiveIterator detect the input message format (file vs dir)
 #
-my %opt = ( 'create-prefs' => 1, 'format' => 'detect' );
+my %opt = ( 'create-prefs' => 1, 'format' => 'detect', cf => [] );
 
 my $doing_whitelist_operation = 0;
 my $count                     = 0;
@@ -174,6 +174,7 @@
   'add-to-whitelist|W'                      => \$opt{'add-to-whitelist'},
   'configpath|config-file|config-dir|c|C=s' => \$opt{'configpath'},
   'create-prefs!'                           => \$opt{'create-prefs'},
+  'cf=s'                                    => \@{$opt{'cf'}},
   'debug|D:s'                               => \$opt{'debug'},
   'error-code|exit-code|e:i'                => \$opt{'error-code'},
   'help|h|?'                                => \$opt{'help'},
@@ -250,6 +251,7 @@
     local_tests_only    => $opt{'local'},
     debug               => $opt{'debug'},
     dont_copy_prefs     => ( $opt{'create-prefs'} ? 0 : 1 ),
+    post_config_text    => join("\n", @{$opt{'cf'}})."\n",
     PREFIX              => $PREFIX,
     DEF_RULES_DIR       => $DEF_RULES_DIR,
     LOCAL_RULES_DIR     => $LOCAL_RULES_DIR,

Modified: spamassassin/trunk/spamd/spamd.raw
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamd/spamd.raw?view=diff&rev=465198&r1=465197&r2=465198
==============================================================================
--- spamassassin/trunk/spamd/spamd.raw (original)
+++ spamassassin/trunk/spamd/spamd.raw Wed Oct 18 03:19:57 2006
@@ -170,6 +170,7 @@
   'min-children'  => 1,         # min kids to have running
   'min-spare'     => 1,         # min kids that must be spare
   'max-spare'     => 2,         # max kids that should be spare
+  'cf'            => [],        # extra config lines
 );
 
 
@@ -236,6 +237,7 @@
   'setuid-with-ldap'         => \$opt{'setuid-with-ldap'},
   'setuid-with-sql'          => \$opt{'setuid-with-sql'},
   'siteconfigpath=s'         => \$opt{'siteconfigpath'},
+  'cf=s'                     => \@{$opt{'cf'}},
   'socketgroup=s'            => \$opt{'socketgroup'},
   'socketmode=s'             => \$opt{'socketmode'},
   'socketowner=s'            => \$opt{'socketowner'},
@@ -731,6 +733,7 @@
     dont_copy_prefs      => $dontcopy,
     rules_filename       => ( $opt{'configpath'} || 0 ),
     site_rules_filename  => ( $opt{'siteconfigpath'} || 0 ),
+    post_config_text     => join("\n", @{$opt{'cf'}})."\n",
     force_ipv4           => ( $opt{'force_ipv4'} || 0 ),
     local_tests_only     => ( $opt{'local'} || 0 ),
     debug                => ( $opt{'debug'} || 0 ),
@@ -2216,6 +2219,7 @@
  -c, --create-prefs                 Create user preferences files
  -C path, --configpath=path         Path for default config files
  --siteconfigpath=path              Path for site configs
+ --cf='config line'                 Additional line of configuration
  -d, --daemonize                    Daemonize
  -h, --help                         Print usage message.
  -i [ipaddr], --listen-ip=ipaddr    Listen on the IP ipaddr
@@ -2319,6 +2323,12 @@
 
 Use the specified path for locating site-specific configuration files.  Ignore
 the default directories (usually C</etc/mail/spamassassin> or similar).
+
+=item B<--cf='config line'>
+
+Add additional lines of configuration directly from the command-line, parsed
+after the configuration files are read.   Multiple B<--cf> arguments can be
+used, and each will be considered a separate line of configuration.
 
 =item B<-d>, B<--daemonize>
 

Added: spamassassin/trunk/t/config_text.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/config_text.t?view=auto&rev=465198
==============================================================================
--- spamassassin/trunk/t/config_text.t (added)
+++ spamassassin/trunk/t/config_text.t Wed Oct 18 03:19:57 2006
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+
+use lib '.'; use lib 't';
+use SATest; sa_t_init("config_text");
+use Test; BEGIN { plan tests => 2 };
+
+# ---------------------------------------------------------------------------
+
+%patterns = (
+
+q{ FOO } => 'FOO',
+q{ BAR } => 'BAR',
+
+);
+
+sarun ("-L -t ".
+    "--cf='body FOO /VFS/' ".
+    "--cf='body BAR /source/' ".
+    "< data/nice/001", \&patterns_run_cb);
+
+ok_all_patterns();
+

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