aboutsummaryrefslogtreecommitdiffstats
path: root/packages/spamd_db_ext.php
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-06-02 17:21:08 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-06-02 17:21:08 +0000
commit1b1b13f4118fb2561ebb3606d85cc1d43bb0b39c (patch)
tree59cca1bface895110e226589604bf596ba929771 /packages/spamd_db_ext.php
parenta493fed52d1075ccaf629a0ee7aa012855b7be7a (diff)
downloadpfsense-packages-1b1b13f4118fb2561ebb3606d85cc1d43bb0b39c.tar.gz
pfsense-packages-1b1b13f4118fb2561ebb3606d85cc1d43bb0b39c.tar.bz2
pfsense-packages-1b1b13f4118fb2561ebb3606d85cc1d43bb0b39c.zip
Delete from whitelist when required.
Diffstat (limited to 'packages/spamd_db_ext.php')
-rw-r--r--packages/spamd_db_ext.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/spamd_db_ext.php b/packages/spamd_db_ext.php
index b7d30589..85aa3c68 100644
--- a/packages/spamd_db_ext.php
+++ b/packages/spamd_db_ext.php
@@ -84,10 +84,12 @@ if($_GET['action'] or $_POST['action']) {
mwexec("/sbin/pfctl -q -t spamd -T delete $srcip");
mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt");
delete_from_blacklist($srcip);
+ delete_from_whitelist($srcip);
log_error("spamd: {$srcip} has been deleted by {$_SERVER['REMOTE_ADDR']} {$loginname}");
exit;
} else if($action == "spamtrap") {
delete_from_spamd_db($email);
+ delete_from_whitelist($srcip);
usleep(100);
exec("/usr/local/sbin/spamdb -a \"<{$email}>\" -T");
hup_spamd();
@@ -96,6 +98,7 @@ if($_GET['action'] or $_POST['action']) {
exit;
} else if($action == "trapped") {
delete_from_spamd_db($srcip);
+ delete_from_whitelist($srcip);
usleep(100);
exec("/usr/local/sbin/spamdb -a {$srcip} -t");
add_to_blacklist($srcip);
@@ -205,6 +208,21 @@ function delete_from_blacklist($srcip) {
config_unlock();
}
+function delete_from_whitelist($srcip) {
+ config_lock();
+ $whitelist = split("\n", file_get_contents("/var/db/whitelist.txt"));
+ $fd = fopen("/var/db/whitelist.txt", "w");
+ foreach($whitelist as $wl) {
+ if($wl <> "")
+ if(!stristr($wl, $srcip))
+ fwrite($fd, "{$wl}\n");
+ }
+ fclose($fd);
+ mwexec("/sbin/pfctl -q -t spamd -T delete $srcip");
+ mwexec("/sbin/pfctl -q -t whitelist -T replace -f /var/db/whitelist.txt");
+ config_unlock();
+}
+
function hup_spamd() {
mwexec("killall -HUP spamlogd");
}