From cc47995dd0b4f7a44c36a94d6f4feabddc418e12 Mon Sep 17 00:00:00 2001 From: Charlie Date: Wed, 8 Jul 2009 14:45:06 +0000 Subject: Add needed code to packages to confirm to 2.0 rules for adding firewall rules. NOTE: other packages might need intervention but for now this is the neccessary minimum to remove dependency on pkg-utils.inc on filter.inc --- config/spamd.inc | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'config/spamd.inc') diff --git a/config/spamd.inc b/config/spamd.inc index 3088d037..6ee72ad7 100644 --- a/config/spamd.inc +++ b/config/spamd.inc @@ -160,6 +160,35 @@ function sync_package_spamd() { log_error("SpamD setup completed"); } +function spamd_generate_rules($type) { + global $config; + + $natrules = ""; + switch($type) { + case 'rdr': + $natrules .= "\n# spam table \n"; + $wanif = $FilterIflist["wan"]['if']; + $natrules .= "table persist\n"; + $natrules .= "table persist\n"; + $natrules .= "table persist\n"; + if(file_exists("/var/db/whitelist.txt")) + $natrules .= "table persist file \"/var/db/whitelist.txt\"\n"; + $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; + $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; + $natrules .= "rdr pass on {$wanif} proto tcp from ! to port smtp -> 127.0.0.1 port spamd\n"; + if($config['installedpackages']['spamdsettings']['config']) + foreach($config['installedpackages']['spamdsettings']['config'] as $ss) + $nextmta = $ss['nextmta']; + if($nextmta <> "") { + $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> {$nextmta} port smtp\n"; + } + + break; + } + + return $natrules; +} + function remove_spaces($string) { $string = str_replace(" ", "", $string); return $string; @@ -286,4 +315,4 @@ function spamd_validate_input($post, $input_errors) { } } -?> \ No newline at end of file +?> -- cgit v1.2.3