diff -u old/spamd new/spamd --- old/spamd 2004-10-23 10:12:03.000000000 -0400 +++ new/spamd 2004-10-23 11:19:39.000000000 -0400 @@ -135,6 +135,37 @@ # somehow -- untaint the dir to be on the safe side. my $ORIG_CWD = Mail::SpamAssassin::Util::untaint_var( Cwd::cwd() ); +# Check to see if we want to ignore the spamd.args config file ('klear' config). +# Also check to see if a config file was specified, to override the default. +my $cmdline_args_only = 0; +my $auto_config_file = 1; +foreach (@ARGV) { + $cmdline_args_only = 1 if ($_ =~ /^-k$/); # don't use long-opts to avoid 'shortening issues' + $auto_config_file = 0 if ($_ =~ /^\@./); + if ($_ =~ /^\@$/) { + warn "There can be no spaces between the @ and the file path in a config file option.\n"; + exit 2; + } +} + +# Parse the spamd.args config file if Getopt::ArgvFile is available and we +# haven't been told to use command line options only. +unless ($cmdline_args_only) { + eval { require Getopt::ArgvFile }; + unless ($@) { + if ($Getopt::ArgvFile::VERSION >= 1.08) { + # 'justload' Getopt::Argv, otherwise it parses config file hints at hints + # at compile time, before we can conditionally push one on @ARGV. + use Getopt::ArgvFile justload => 1; + push @ARGV, '@'.$LOCAL_RULES_DIR.'/spamd.args' if $auto_config_file; + + # Parse available config files. + # Also check calling user's home directory for configuraton file. + Getopt::ArgvFile::argvFile (home => $auto_config_file, startupFilename => 'spamd.args'); + } + } +} + # Parse the command line Getopt::Long::Configure("bundling"); GetOptions( @@ -150,6 +181,7 @@ 'helper-home-dir|H:s' => \$opt{'home_dir_for_helpers'}, 'help|h' => \$opt{'help'}, 'ident-timeout=f' => \$opt{'ident-timeout'}, + 'k' => \$opt{'cmdline-only'}, 'ldap-config!' => \$opt{'ldap-config'}, 'listen-ip|ip-address|i:s' => \$opt{'listen-ip'}, 'local!' => \$opt{'local'}, @@ -1910,12 +1942,14 @@ Options: + @/configpath/filename Override default spamd config file setting -c, --create-prefs Create user preferences files -C path, --configpath=path Path for default config files --siteconfigpath=path Path for site configs -d, --daemonize Daemonize -h, --help Print usage message. -i [ipaddr], --listen-ip=ipaddr Listen on the IP ipaddr + -k Prevent the use of spamd config files -p port, --port Listen on specified port -m num, --max-children=num Allow maximum num children --max-conn-per-child=num Maximum connections accepted by child @@ -1980,6 +2014,19 @@ =over 4 +=item B<@/configpath/filename> + +Override the spamd configuration file setting. A full file path must be used. +There must be no spaces between the @ and the file path. + +This option may be used multiple times to specify that multiple configuration +files be used. + +=item B<-k> + +Prevent command line specified and default spamd configuration files from +being used. + =item B<-c>, B<--create-prefs> Create user preferences files if they don't exist (default: don't).