From 9f64b0d09640533d9d5c881170fd2e94e69af426 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Tue, 7 Mar 2006 01:59:18 +0000 Subject: * Do not add ips to spamtrap, it really wants an email address * Add blacklist.txt and set it up as a blacklist in SpamD * Use new blacklist.txt when trapping $srcip --- packages/spamd.inc | 5 +++++ packages/spamd_db_ext.php | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'packages') diff --git a/packages/spamd.inc b/packages/spamd.inc index 2edcb129..3ef1b979 100644 --- a/packages/spamd.inc +++ b/packages/spamd.inc @@ -44,6 +44,10 @@ function sync_package_spamd() { fwrite($fd, "whitelist:\\\n"); fwrite($fd, "\t:white:\\\n"); fwrite($fd, "\t:file=/var/db/whitelist.txt\n"); + fwrite($fd, ":\n\n# begin of blacklist\n"); + fwrite($fd, "blacklist:\\\n"); + fwrite($fd, "\t:black:\\\n"); + fwrite($fd, "\t:file=/var/db/blacklist.txt\n"); /* loop through each item and write out its configuration */ fwrite($fd, "\n# begin of user created entries\n"); if($config['installedpackages']['spamdsources']['config'] != "") { @@ -169,6 +173,7 @@ function sync_spamd_config_to_backup() { function custom_php_install_command() { global $config, $g; system("touch /var/db/whitelist.txt"); + system("touch /var/db/blacklist.txt"); sync_package_spamd(); } diff --git a/packages/spamd_db_ext.php b/packages/spamd_db_ext.php index 72bbbe9e..a4da79ab 100644 --- a/packages/spamd_db_ext.php +++ b/packages/spamd_db_ext.php @@ -79,6 +79,7 @@ if($_GET['action'] or $_POST['action']) { fclose($fd); exec("chmod a+rx /tmp/execcmds"); system("/bin/sh /tmp/execcmds"); + remove_from_blacklist($srcip); config_unlock(); exit; } else if($action == "spamtrap") { @@ -92,6 +93,9 @@ if($_GET['action'] or $_POST['action']) { exec("/usr/local/sbin/spamdb -d -T \"<{$srcip}>\""); exec("/usr/local/sbin/spamdb -d -t \"<{$srcip}>\""); exec("/usr/local/sbin/spamdb -a {$srcip} -t"); + config_lock(); + add_to_blacklist($srcip); + config_unlock(); exit; } /* signal a reload for real time effect. */ @@ -154,6 +158,22 @@ function basic_auth_prompt(){ exit; } +function add_to_blacklist($srcip) { + $fd = fopen("/var/db/blacklist.txt", "a"); + fwrite($fd, $srcip); + fclose($fd); +} + +function delete_from_blacklist($srcip) { + $blacklist = split("\n", file_get_contents("/var/db/blacklist.txt")); + $fd = fopen("/var/db/blacklist.txt", "w"); + foreach($blacklist as $bl) { + if($blacklist <> $srcip) + fwrite($fd, "{$srcip}\n"; + } + fclose($fd); +} + exit; ?> \ No newline at end of file -- cgit v1.2.3