diff -uNr bin/MailScanner.orig bin/MailScanner --- bin/MailScanner.orig 2004-03-08 19:29:59.000000000 +0000 +++ bin/MailScanner 2004-03-19 13:37:44.000000000 +0000 @@ -173,6 +173,19 @@ CheckModuleVersions(); # Can't do this here, config not read yet: CheckQueuesAreTogether(); +# Check if we have a local "custom config file" defined, and if we do, +# require it, so we can use the functions from it. This saves people +# attempting to maintain patches specific to their installation against +# the MailScanner distribution. +my($lconfig); +$lconfig = MailScanner::Config::QuickPeek($ConfFile, 'localcustomconfig'); +if($lconfig) { + eval { require $lconfig; }; + if($@) { + die("Error loading local config functions from $lconfig: $@\n"); + } +} + # # Need MaxChildren to know how many children to fork # Debug to know whether to terminate diff -uNr etc/MailScanner.conf.orig etc/MailScanner.conf --- etc/MailScanner.conf.orig 2004-03-08 19:28:57.000000000 +0000 +++ etc/MailScanner.conf 2004-03-19 13:39:15.000000000 +0000 @@ -54,6 +54,12 @@ # --------------- # +# Where do we load the custom rules for config from. This should be +# a perl file that can be require()d, and all the functions should +# be in the package LocalConfig. If you don't know what any of the +# above means, it doesn't apply to you, and you shouldn't worry. +#Local Custom Config = /usr/local/lib/MailScannerLocalConfig.pm + # How many MailScanner processes do you want to run at a time? # There is no point increasing this figure if your MailScanner server # is happily keeping up with your mail traffic. diff -uNr lib/MailScanner/Config.pm.orig lib/MailScanner/Config.pm --- lib/MailScanner/Config.pm.orig 2004-02-29 19:00:21.000000000 +0000 +++ lib/MailScanner/Config.pm 2004-03-19 13:48:44.000000000 +0000 @@ -84,6 +84,19 @@ $DefaultAddressRegexp = '^.*\@.*\.?$'; $DefaultVirusRegexp = '.*'; +# Do the search for custom config functions +sub CustomSearch { + my($fn, @search) = @_; + + my($path); + foreach $path (@search) { + if(defined($path->can($fn))) { + return $path . "::" . $fn; + } + } + return undef; +} + # Need to read in a filename/ruleset whose value is the location of # filename.rules.conf files. Check every rule of every ruleset in # turn, stopping with the result of the first rule that matches. @@ -114,7 +127,10 @@ # User custom-written functions are easy to spot too $funcname = $CustomFunctions{$name}; if ($funcname) { - $funcname = 'MailScanner::CustomConfig::' . $funcname; + $funcname = CustomSearch($funcname, "LocalConfig", "MailScanner::CustomConfig"); + if(!defined($funcname)) { + MailScanner::Log::DieLog("CustomConfig: can't find function $funcname"); + } no strict 'refs'; $result = &$funcname($msg); use strict 'refs'; @@ -717,7 +733,15 @@ next unless $custom; MailScanner::Log::InfoLog("Config: calling custom init function %s", $custom); - $fn = 'MailScanner::CustomConfig::Init' . $custom; + $fn = CustomSearch("Init" . $custom, "LocalConfig", "MailScanner::CustomConfig"); + if(!defined($fn)) { + MailScanner::Log::InfoLog("Config: couldn't find custom init function %s", + $custom); + if(!defined(CustomSearch($custom, "LocalConfig", "MailScanner::CustomCofig"))) { + MailScanner::Log::DieLog("Config: Main function %s doesn't exist",$custom); + } + next; + } no strict 'refs'; &$fn(); use strict 'refs'; @@ -742,7 +766,12 @@ next unless $custom; MailScanner::Log::InfoLog("Config: calling custom end function %s", $custom); - $fn = 'MailScanner::CustomConfig::End' . $custom; + $fn = CustomSearch("End" . $custom, "LocalConfig", "MailScanner::CustomConfig"); + if(!defined($fn)) { + MailScanner::Log::InfoLog("Config: couldn't find custom end function %s", + $custom); + next; + } no strict 'refs'; &$fn(); use strict 'refs'; diff -uNr lib/MailScanner/ConfigDefs.pl.orig lib/MailScanner/ConfigDefs.pl --- lib/MailScanner/ConfigDefs.pl.orig 2004-03-02 11:40:53.000000000 +0000 +++ lib/MailScanner/ConfigDefs.pl 2004-03-19 15:52:26.000000000 +0000 @@ -202,6 +202,7 @@ SpamListDefinitions /opt/MailScanner/etc/spam.lists.conf mcpspamassassinprefsfile /opt/MailScanner/etc/mcp/mcp.spam.assassin.prefs.conf VirusScannerDefinitions /opt/MailScanner/etc/virus.scanners.conf +LocalCustomConfig # Check these to ensure they are just numbers [Simple,Number]