From f14370090e067ae878690b3886dbb13a1f22f52e Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 2 Jun 2006 16:57:59 +0000 Subject: Delete items from SpamD blacklist when they are deleted from the SpamDB as well. --- packages/spamd_db_ext.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'packages/spamd_db_ext.php') diff --git a/packages/spamd_db_ext.php b/packages/spamd_db_ext.php index 8a6b726c..ae6c51fb 100644 --- a/packages/spamd_db_ext.php +++ b/packages/spamd_db_ext.php @@ -73,6 +73,7 @@ if($_GET['action'] or $_POST['action']) { usleep(100); exec("/usr/local/sbin/spamdb -a {$srcip}"); mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + delete_from_spamd_bl($srcip); log_error("spamd: {$srcip} has been whitelisted by {$_SERVER['REMOTE_ADDR']} {$loginname}"); hup_spamd(); exit; @@ -82,6 +83,7 @@ if($_GET['action'] or $_POST['action']) { hup_spamd(); mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + delete_from_spamd_bl($srcip); log_error("spamd: {$srcip} has been deleted by {$_SERVER['REMOTE_ADDR']} {$loginname}"); exit; } else if($action == "spamtrap") { @@ -154,6 +156,27 @@ if($_GET['whitelist'] <> "") { exit; } +function delete_from_spamd_bl($ip) { + config_lock(); + if(!file_exists("/var/db/blacklist.txt")) + return; + $blacklist = file("/var/db/blacklist.txt"); + $new_blacklist = array(); + foreach($blacklist as $bl) { + if(stristr($bl, $ip)) { + /* don't add item */ + } else { + $new_blacklist[] = $bl; + } + } + $fd = fopen("/var/db/blacklist.txt", "w"); + foreach($new_blacklist as $bl) + fwrite($fd, $bl . "\n"); + flose($fd); + mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + config_unlock(); +} + function delete_from_spamd_db($srcip) { config_lock(); $fd = fopen("/tmp/execcmds", "w"); -- cgit v1.2.3