From 690c8c80452de6b565a2d552324c58ecd350d987 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 10:47:03 +0200 Subject: spamd - code style cleanup and multiple fixes - Code style and indentation fixes - Use install_cron_job() instead of re-implementing it - Use restart_service() - Clean up user/groups after itself on uninstall (fixes Bug #4929) - Fix input validation (no errors shown due to a typo in variable name) - Better log messages plus some cosmetics --- config/spamd/spamd.inc | 211 ++++++++++++++++++++++--------------------------- 1 file changed, 93 insertions(+), 118 deletions(-) diff --git a/config/spamd/spamd.inc b/config/spamd/spamd.inc index a72d8770..98cdc561 100644 --- a/config/spamd/spamd.inc +++ b/config/spamd/spamd.inc @@ -1,9 +1,9 @@ "") + log_error("[spamd] Looping through spamdsettings"); + if ($config['installedpackages']['spamdsettings']['config']) { + foreach ($config['installedpackages']['spamdsettings']['config'] as $ss) { + if ($ss['nextmta'] != "") { $nextmta = $ss['nextmta']; - if($ss['greylistingparms'] <> "") + } + if ($ss['greylistingparms'] != "") { $passtime = " -G " . $ss['greylistingparms']; - if($ss['identifier'] <> "") + } + if ($ss['identifier'] != "") { $identifier = " -n \"" . $ss['identifier'] . "\""; + } // Default is greylisting, turn on blacklisting if not checked. - if($ss['greylisting'] <> "on") + if ($ss['greylisting'] != "on") { $greylisting = " -b"; - if($ss['maxblack'] <> "") + } + if ($ss['maxblack'] != "") { $maxblack = " -B " . $ss['maxblack']; - if($ss['maxcon'] <> "") + } + if ($ss['maxcon'] != "") { $maxcon = " -c " . $ss['maxcon']; - if($ss['stuttersecs'] <> "") + } + if ($ss['stuttersecs'] != "") { $stuttersecs = " -S " . $ss['stuttersecs']; - if($ss['delaysecs'] <> "") + } + if ($ss['delaysecs'] != "") { $delaysecs = " -s " . $ss['delaysecs']; - if($ss['window'] <> "") + } + if ($ss['window'] != "") { $window = " -w " . $ss['window']; - if($ss['passtime'] <> "") + } + if ($ss['passtime'] != "") { $passtime = $ss['passtime']; - if($ss['greyexp'] <> "") + } + if ($ss['greyexp'] != "") { $greyexp = $ss['greyexp']; - if($ss['whiteexp'] <> "") + } + if ($ss['whiteexp'] != "") { $whiteexp = $ss['whiteexp']; + } } } $greyparms = " -G {$passtime}:{$greyexp}:{$whiteexp}"; - $start = "if [ `mount | grep -v grep | grep fdescfs | wc -l` -lt 1 ]; then \n" . + $start = "if [ `/sbin/mount | /usr/bin/grep -v grep | /usr/bin/grep fdescfs | /usr/bin/wc -l` -lt 1 ]; then \n" . "/sbin/mount -t fdescfs fdescfs /dev/fd\n" . "fi\n" . "/usr/local/sbin/spamd-setup -d &\n" . @@ -142,32 +154,25 @@ function sync_package_spamd() { "/usr/bin/killall spamlogd\n" . "/usr/bin/killall spamd\n" . "/usr/bin/killall pflogd\n" . - "sleep 2"; - log_error("Writing rc_file"); + "sleep 3"; + log_error("[spamd] Writing rc_file"); write_rcfile(array( "file" => "spamd.sh", "start" => $start, "stop" => $stop ) ); - log_error("Installing CRON"); - spamd_install_cron(true); - log_error("Mounting RO"); - conf_mount_ro(); - log_error("Restart cron"); - mwexec("killall -HUP cron"); - log_error("Setting up spamd.conf symlink"); + log_error("[spamd] Installing cron job"); + install_cron_job("/usr/bin/nice -n20 /usr/local/sbin/spamd-setup", true, "*/120"); + log_error("[spamd] Setting up spamd.conf symlink"); unlink_if_exists("$localpath/etc/spamd/spamd.conf"); symlink("/etc/spamd.conf", "$localpath/etc/spamd/spamd.conf"); - - log_error("Stopping spamd"); - mwexec("/usr/local/etc/rc.d/spamd.sh stop"); - sleep(1); - log_error("Starting spamd"); - mwexec_bg("/usr/local/etc/rc.d/spamd.sh start"); - log_error("Reconfiguring filter"); + conf_mount_ro(); + log_error("[spamd] Restarting spamd"); + restart_service("spamd"); + log_error("[spamd] Reconfiguring filter"); filter_configure(); - log_error("SpamD setup completed"); + log_error("[spamd] Package setup completed"); } function sync_package_spamd_whitelist() { @@ -175,8 +180,8 @@ function sync_package_spamd_whitelist() { conf_mount_rw(); /* write out ip to the whitelist db */ $fd = fopen("/var/db/whitelist.txt","w"); - if($config['installedpackages']['spamdwhitelist']['config'] != "") { - foreach($config['installedpackages']['spamdwhitelist']['config'] as $spamd) { + if ($config['installedpackages']['spamdwhitelist']['config'] != "") { + foreach ($config['installedpackages']['spamdwhitelist']['config'] as $spamd) { fwrite($fd, $spamd['ip'] . "\n"); } } @@ -219,7 +224,7 @@ function spamd_generate_rules($type) { $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 ($nextmta <> "") { + if ($nextmta != "") { $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> {$nextmta} port smtp\n"; } } @@ -229,7 +234,7 @@ function spamd_generate_rules($type) { break; } - + return $natrules; } @@ -239,28 +244,29 @@ function remove_spaces($string) { } function sync_spamd_config_to_backup() { - global $g, $config; - if(is_array($config['installedpackages']['carpsettings']['config'])) { - foreach($config['installedpackages']['carpsettings']['config'] as $carp) { - if($carp['synchronizetoip'] != "" ) { + global $config; + if (is_array($config['installedpackages']['carpsettings']['config'])) { + foreach ($config['installedpackages']['carpsettings']['config'] as $carp) { + if ($carp['synchronizetoip'] != "" ) { $synctoip = $carp['synchronizetoip']; $password = $carp['password']; - if($config['system']['username']) + if ($config['system']['username']) { $username = $config['system']['username']; - else + } else { $username = "admin"; + } } } } - if($synctoip and $password) { - if($config['system']['webgui']['protocol'] != "") { + if ($synctoip and $password) { + if ($config['system']['webgui']['protocol'] != "") { $synchronizetoip = $config['system']['webgui']['protocol']; $synchronizetoip .= "://"; } $port = $config['system']['webgui']['port']; /* if port is empty lets rely on the protocol selection */ - if($port == "") { - if($config['system']['webgui']['protocol'] == "http") { + if ($port == "") { + if ($config['system']['webgui']['protocol'] == "http") { $port = "80"; } else { $port = "443"; @@ -270,7 +276,7 @@ function sync_spamd_config_to_backup() { /* create files to sync array */ $filetosync = array("/var/db/spamd", "/var/db/whitelist.txt"); /* loop through files to sync list and sync them up */ - foreach($filetosync as $f2s) { + foreach ($filetosync as $f2s) { $f2c_contents = file_get_contents($f2s); xmlrpc_sync_file($url, $password, $f2s, $f2c_contents, $port); } @@ -281,7 +287,7 @@ function sync_spamd_config_to_backup() { } function custom_php_install_command() { - global $config, $g; + global $config; system("touch /var/db/whitelist.txt"); system("touch /var/db/blacklist.txt"); exec("/usr/sbin/pw usermod _spamd -g proxy -G _spamd,proxy"); @@ -289,69 +295,38 @@ function custom_php_install_command() { } function custom_php_deinstall_command() { - global $config, $g; + global $config; unlink_if_exists("/usr/local/pkg/pf/spamd_rules.php"); - spamd_install_cron(false); - filter_configure(); -} - -function spamd_install_cron($should_install) { - global $config, $g; - $is_installed = false; - if(!$config['cron']['item']) - return; - $x=0; - foreach($config['cron']['item'] as $item) { - if(strstr($item['command'], "spamd-setup")) { - $is_installed = true; - break; - } - $x++; + install_cron_job("/usr/bin/nice -n20 /usr/local/sbin/spamd-setup", false); + /* clean up user/groups */ + if (exec("/usr/sbin/pw groupshow proxy | /usr/bin/grep _spamd")) { + exec ("/usr/sbin/pw groupmod proxy -d _spamd"); } - switch($should_install) { - case true: - if(!$is_installed) { - $cron_item = array(); - $cron_item['minute'] = "*/120"; - $cron_item['hour'] = "*"; - $cron_item['mday'] = "*"; - $cron_item['month'] = "*"; - $cron_item['wday'] = "*"; - $cron_item['who'] = "root"; - $cron_item['command'] = "/usr/bin/nice -n20 /usr/local/sbin/spamd-setup"; - $config['cron']['item'][] = $cron_item; - write_config("Installed SPAMD crontab entries."); - configure_cron(); - } - break; - case false: - if($is_installed == true) { - if($x > 0) { - unset($config['cron']['item'][$x]); - write_config(); - } - configure_cron(); - } - break; + if (exec("/usr/sbin/pw usershow _spamd")) { + exec("/usr/sbin/pw userdel _spamd"); + } + if (exec("/usr/sbin/pw groupshow _spamd")) { + exec("/usr/sbin/pw groupdel _spamd"); } + filter_configure(); } function spamd_validate_input($post, &$input_errors) { - global $config, $g; + global $config; $nextmta = str_replace("$", "", $post['nextmta']); - if(stristr($nextmta, "{")) { + if (stristr($nextmta, "{")) { /* item is an alias, make sure the name exists */ $nextmta = str_replace("$", "", $nextmta); $found = false; - if($config['aliases']['alias']) { - foreach($config['aliases']['alias'] as $alias) { - if($alias['name'] == $nextmta) { + if ($config['aliases']['alias']) { + foreach ($config['aliases']['alias'] as $alias) { + if ($alias['name'] == $nextmta) { $found = true; } } } - if($found == false) - $intput_errors = "Could not locate alias named " . htmlentities($nextmta); + if ($found == false) + $input_errors[] = "Could not locate alias named " . htmlentities($nextmta); } } -- cgit v1.2.3 From 6a58a877040b1d2e92e8345c181fe4b0dcdfd98b Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 11:02:34 +0200 Subject: spamd - code style cleanup and multiple fixes - Update copyright header - Fix file permissions (no need for these to be executable) - Fix whitespace/indentation - Nuke useless comments - Sanitize package version --- config/spamd/spamd.xml | 170 +++++++++++++++++++++++-------------------------- 1 file changed, 79 insertions(+), 91 deletions(-) diff --git a/config/spamd/spamd.xml b/config/spamd/spamd.xml index 45cc9168..6bd1574c 100644 --- a/config/spamd/spamd.xml +++ b/config/spamd/spamd.xml @@ -1,63 +1,62 @@ - - + + - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* ====================================================================================== */ + ]]> + spamdsources - 4.9.1 v1.1 + 1.1.5 SpamD: External Sources /usr/local/pkg/spamd.inc /var/db/spamd - SpamD
Services
spamd.xml
- spamd - spamd.sh - spamd - SPAMD Greylisting Daemon - + spamd + spamd.sh + spamd + SpamD Greylisting Daemon + SpamD External Sources @@ -77,8 +76,6 @@ /spamd_db.php - ['installedpackages']['spamd']['config'] @@ -94,82 +91,71 @@ providerdescription - - /usr/local/www/ - 0755 - https://packages.pfsense.org/packages/config/spamd/spamd_rules.php + + /usr/local/www/ + https://packages.pfsense.org/packages/config/spamd/spamd_rules.php - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/spamd/spamd_whitelist.xml + + /usr/local/pkg/ + https://packages.pfsense.org/packages/config/spamd/spamd_whitelist.xml - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/spamd/spamd_outlook.xml + + /usr/local/pkg/ + https://packages.pfsense.org/packages/config/spamd/spamd_outlook.xml - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/spamd/spamd.inc + + /usr/local/pkg/ + https://packages.pfsense.org/packages/config/spamd/spamd.inc - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/spamd/spamd_settings.xml + + /usr/local/pkg/ + https://packages.pfsense.org/packages/config/spamd/spamd_settings.xml - - /usr/local/www/ - 0755 - https://packages.pfsense.org/packages/config/spamd/spamd_db.php + + /usr/local/www/ + https://packages.pfsense.org/packages/config/spamd/spamd_db.php - - /usr/local/www/ - 0755 - https://packages.pfsense.org/packages/config/spamd/spamd_db_ext.php + + /usr/local/www/ + https://packages.pfsense.org/packages/config/spamd/spamd_db_ext.php + + + /usr/local/bin/ + https://packages.pfsense.org/packages/config/spamd/spamd_gather_stats.php - - /usr/local/bin/ - 0755 - https://packages.pfsense.org/packages/config/spamd/spamd_gather_stats.php - - - Provider Name providername - Enter the name of the source + Enter the name of the source. input 30 Provider Type providertype - Select the Provider Type + Select the Provider Type. select 1 black - - + + Provider Description providerdescription - Enter the description for this item + Enter the description for this item. textarea 30 - 40 + 40 4 Reject message rejectmessage - Enter the message to display to emailing parties that are on this providers list + Enter the message to display to emailing parties that are on this providers list. textarea 30 40 @@ -178,14 +164,14 @@ Provider Method providermethod - Select the Provider Method + Select the Provider Method. select 1 http - - + + @@ -209,5 +195,7 @@ custom_php_deinstall_command(); - spamd_generate_rules + + spamd_generate_rules(); +
-- cgit v1.2.3 From 88c825e34adb660b141e0448e504c9bf4276da59 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 12:59:57 +0200 Subject: spamd - code style cleanup and multiple fixes - Code style and indentation fixes - Use shell_exec() instead of backticks - Don't add the same email address to spamtrap twice (?!) - XHTML fixes --- config/spamd/spamd_db.php | 321 +++++++++++++++++++++++----------------------- 1 file changed, 161 insertions(+), 160 deletions(-) diff --git a/config/spamd/spamd_db.php b/config/spamd/spamd_db.php index 3fe439ef..90215e6f 100644 --- a/config/spamd/spamd_db.php +++ b/config/spamd/spamd_db.php @@ -1,9 +1,9 @@ ","",$srcip); - $srcip = str_replace(" ","",$srcip); - // Make input safe + } + $srcip = str_replace("<", "", $srcip); + $srcip = str_replace(">", "", $srcip); + $srcip = str_replace(" ", "", $srcip); + // make input safe $srcip = escapeshellarg($srcip); /* execute spamdb command */ - if($action == "whitelist") { + if ($action == "whitelist") { exec("/usr/local/sbin/spamdb -d {$srcip} -T"); exec("/usr/local/sbin/spamdb -d {$srcip} -t"); delete_from_blacklist($srcip); mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); exec("echo spamdb -a {$srcip} > /tmp/tmp"); exec("/usr/local/sbin/spamdb -a {$srcip}"); - } else if($action == "delete") { + } elseif ($action == "delete") { exec("/usr/local/sbin/spamdb -d {$srcip}"); exec("/usr/local/sbin/spamdb -d {$srcip} -T"); exec("/usr/local/sbin/spamdb -d {$srcip} -t"); delete_from_blacklist($srcip); mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - } else if($action == "trapped") { + } elseif ($action == "trapped") { exec("/usr/local/sbin/spamdb -d {$srcip}"); exec("/usr/local/sbin/spamdb -d {$srcip}"); exec("/usr/local/sbin/spamdb -d -t {$srcip}"); exec("/usr/local/sbin/spamdb -a -t {$srcip}"); - } else if($action == "spamtrap") { + } elseif ($action == "spamtrap") { exec("/usr/local/sbin/spamdb -a -T {$spamtrapemailarg}"); } /* signal a reload for real time effect. */ - mwexec("killall -HUP spamlogd"); + mwexec("/usr/bin/killall -HUP spamlogd"); exit; } -/* spam trap e-mail address */ -if($spamtrapemail <> "") { - exec("spamdb -T -a {$spamtrapemailarg}"); - mwexec("killall -HUP spamlogd"); - $savemsg = htmlentities($spamtrapemail) . " added to spam trap database."; -} - -if($_GET['getstatus'] <> "") { - $status = exec("/usr/local/sbin/spamdb | grep " . escapeshellarg($_GET['getstatus'])); - if(stristr($status, "WHITE") == true) { +if ($_GET['getstatus'] != "") { + $status = exec("/usr/local/sbin/spamdb | /usr/bin/grep " . escapeshellarg($_GET['getstatus'])); + if (stristr($status, "WHITE") == true) { echo "WHITE"; - } else if(stristr($status, "TRAPPED") == true) { + } elseif (stristr($status, "TRAPPED") == true) { echo "TRAPPED"; - } else if(stristr($status, "GREY") == true) { + } elseif (stristr($status, "GREY") == true) { echo "GREY"; - } else if(stristr($status, "SPAMTRAP") == true) { + } elseif (stristr($status, "SPAMTRAP") == true) { echo "SPAMTRAP"; } else { echo "NOT FOUND"; @@ -122,35 +119,38 @@ if($_GET['getstatus'] <> "") { } /* spam trap e-mail address */ -if($_GET['spamtrapemail'] <> "") { - $status = exec("spamdb -T -a {$spamtrapemailarg}"); - mwexec("killall -HUP spamlogd"); - if($status) +if ($spamtrapemail != "") { + $status = exec("/usr/local/sbin/spamdb -T -a {$spamtrapemailarg}"); + mwexec("/usr/bin/killall -HUP spamlogd"); + if ($status) { echo $status; - else - echo htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; + } else { + echo htmlentities($spamtrapemail) . " added to spam trap database."; + } exit; } /* whitelist e-mail address */ -if($_GET['whitelist'] <> "") { - $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); - $status = exec("spamdb -a {$spamtrapemail}"); - mwexec("killall -HUP spamlogd"); - if($status) +if ($_GET['whitelist'] != "") { + $status = exec("/usr/local/sbin/spamdb -a {$spamtrapemail}"); + mwexec("/usr/bin/killall -HUP spamlogd"); + if ($status) { echo $status; - else - echo htmlentities($_POST['spamtrapemail']) . " added to whitelist database."; + } else { + echo htmlentities($spamtrapemail) . " added to whitelist database."; + } exit; } function delete_from_blacklist($srcip) { $blacklist = explode("\n", file_get_contents("/var/db/blacklist.txt")); $fd = fopen("/var/db/blacklist.txt", "w"); - foreach($blacklist as $bl) { - if($bl <> "") - if(!stristr($bl, $srcip)) + foreach ($blacklist as $bl) { + if ($bl != "") { + if (!stristr($bl, $srcip)) { fwrite($fd, "{$bl}\n"); + } + } } fclose($fd); mwexec("/sbin/pfctl -q -t spamd -T delete {$srcip}"); @@ -161,9 +161,11 @@ function delete_from_whitelist($srcip) { $whitelist = explode("\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)) + if ($wl != "") { + if (!stristr($wl, $srcip)) { fwrite($fd, "{$wl}\n"); + } + } } fclose($fd); mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); @@ -173,23 +175,25 @@ function delete_from_whitelist($srcip) { $pgtitle = "SpamD: Database"; include("head.inc"); -if(file_exists("/var/db/whitelist.txt")) - $whitelist_items = `cat /var/db/whitelist.txt | wc -l`; -else +if (file_exists("/var/db/whitelist.txt")) { + $whitelist_items = shell_exec("/bin/cat /var/db/whitelist.txt | /usr/bin/wc -l"); +} else { $whitelist_items = 0; +} -if(file_exists("/var/db/blacklist.txt")) - $blacklist_items = `cat /var/db/blacklist.txt | wc -l`; -else +if (file_exists("/var/db/blacklist.txt")) { + $blacklist_items = shell_exec("/bin/cat /var/db/blacklist.txt | /usr/bin/wc -l"); +} else { $blacklist_items = 0; +} // Get an overall count of the database -$spamdb_items = `/usr/local/sbin/spamdb | wc -l`; +$spamdb_items = shell_exec("/usr/local/sbin/spamdb | /usr/bin/wc -l"); // Get blacklist and whitelist count from database -$spamdb_white = `/usr/local/sbin/spamdb | grep WHITE | wc -l`; -$spamdb_black = `/usr/local/sbin/spamdb | grep BLACK | wc -l`; -$spamdb_grey = `/usr/local/sbin/spamdb | grep GREY | wc -l`; +$spamdb_white = shell_exec("/usr/local/sbin/spamdb | /usr/bin/grep WHITE | /usr/bin/wc -l"); +$spamdb_black = shell_exec("/usr/local/sbin/spamdb | /usr/bin/grep BLACK | /usr/bin/wc -l"); +$spamdb_grey = shell_exec("/usr/local/sbin/spamdb | /usr/bin/grep GREY | /usr/bin/wc -l"); // Now count the user contributed whitelist and blacklist count $whitelist_items = $whitelist_items + $spamdb_white; @@ -198,22 +202,20 @@ $blacklist_items = $blacklist_items + $spamdb_black; ?> - -

-
- -

+
- - - +
+
-
+
- +
+ } +?> + +
- - - - - - - -
Filter by test:  Inverse filter (NOT):>
Limit:
 
* Add spam trap E-mail address:

- - - + + + + + +
Filter by test:  Inverse filter (NOT): />
Limit:
 
* Add spam trap E-mail address:
+
- + @@ -322,68 +321,65 @@ if (typeof getURL == 'undefined') { " . date("H:i:s", $dt); + return date("Y-m-d", $dt) . "
" . date("H:i:s", $dt); } - if($filter) { - if($not) { + if ($filter) { + if ($not) { $fd = fopen("/tmp/spamdb", "w"); - $cmd = "/usr/local/sbin/spamdb | grep -v " . escapeshellarg($filter) . " | tail -n {$limit}"; + $cmd = "/usr/local/sbin/spamdb | /usr/bin/grep -v " . escapeshellarg($filter) . " | /usr/bin/tail -n {$limit}"; fwrite($fd, $cmd); fclose($fd); exec($cmd, $pkgdb); - if(file_exists("/var/db/blacklist.txt")) { - $cmd = "cat /var/db/blacklist.txt | grep -v \"" . escapeshellarg($filter) . "\" "; + if (file_exists("/var/db/blacklist.txt")) { + $cmd = "/bin/cat /var/db/blacklist.txt | /usr/bin/grep -v \"" . escapeshellarg($filter) . "\" "; exec($cmd, $pkgdba); foreach($pkgdba as $pkg) { $pkgdb[] = "TRAPPED|{$pkg}|1149324397"; } } } else { - $cmd = "/usr/local/sbin/spamdb | grep " . escapeshellarg($filter) . " | tail -n {$limit}"; + $cmd = "/usr/local/sbin/spamdb | /usr/bin/grep " . escapeshellarg($filter) . " | /usr/bin/tail -n {$limit}"; exec($cmd, $pkgdb); - if(file_exists("/var/db/blacklist.txt")) { - $cmd = "cat /var/db/blacklist.txt | grep " . escapeshellarg($filter); + if (file_exists("/var/db/blacklist.txt")) { + $cmd = "/bin/cat /var/db/blacklist.txt | /usr/bin/grep " . escapeshellarg($filter); exec($cmd, $pkgdba); - foreach($pkgdba as $pkg) { + foreach ($pkgdba as $pkg) { $pkgdb[] = "TRAPPED|{$pkg}|1149324397"; } echo ""; } } } else { - exec("/usr/local/sbin/spamdb | tail -n {$limit}", $pkgdb); + exec("/usr/local/sbin/spamdb | /usr/bin/tail -n {$limit}", $pkgdb); } $rows = 0; $lastseenip = ""; $srcip = "|"; - foreach($pkgdb as $pkgdb_row) { + foreach ($pkgdb as $pkgdb_row) { - if($rows > $limit) + if($rows > $limit) { break; + } $dontdisplay = false; - if(!$pkgdb_row) + if (!$pkgdb_row) { continue; + } $pkgdb_split = explode("|", $pkgdb_row); /* - - For TRAPPED entries the format is: - + For TRAPPED entries the format is: type|ip|expire - where type will be TRAPPED, IP will be the IP address blacklisted due to - hitting a spamtrap, and expire will be when the IP is due to be removed - from the blacklist. - - For GREY entries, the format is: + where type will be TRAPPED, IP will be the IP address blacklisted due to + hitting a spamtrap, and expire will be when the IP is due to be removed + from the blacklist. + For GREY entries, the format is: type|source IP|helo|from|to|first|pass|expire|block|pass - For WHITE entries, the format is: - + For WHITE entries, the format is: type|source IP|||first|pass|expire|block|pass - */ switch($pkgdb_split[0]) { case "SPAMTRAP": @@ -427,8 +423,9 @@ function formatspamddatetime($dt) { $attempts = htmlentities($pkgdb_split[8]); break; } - if($srcip == "" and $fromaddress == "" and $toaddress == "") + if ($srcip == "" and $fromaddress == "" and $toaddress == "") { continue; + } echo ""; echo ""; echo ""; @@ -438,40 +435,44 @@ function formatspamddatetime($dt) { echo ""; echo ""; echo ""; - echo ""; $rows++; - } -?>
Type IP From
{$recordtype}{$srcip}" . $pass . "" . $expire . "{$attempts}"; - $rowtext = "\"Add "; - $rowtext .= "\"Blacklist\" "; - $rowtext .= "\"Delete\""; - $rowtext .= "\"Spamtrap\" "; - + echo ""; + $rowtext = "\"Add "; + $rowtext .= "\"Blacklist\" "; + $rowtext .= "\"Delete\""; + $rowtext .= "\"Spamtrap\" "; echo $rowtext; - echo "
-
-

" . $rows . " rows returned."; ?> -

- * NOTE: adding an e-mail address to the spamtrap automatically traps any server trying to send e-mail to this address. -

+
+

" . $rows . " rows returned.

"; ?> +

+ * NOTE: adding an e-mail address to the spamtrap automatically traps any server trying to send e-mail to this address. +

+
- - +

-
-Note: Clicking on the action icons will invoke a AJAX query and the page will not refresh. Click refresh in you're browser if you wish to view the changes in status. -
-

Database totals:

- "; - echo "{$blacklist_items} total items in the blacklist.
"; - echo "{$spamdb_grey} total items in the greylist.
"; - echo "{$spamdb_items} total items in the SpamDB.
"; - ?> +
+Note: Clicking on the action icons will invoke a AJAX query and the page will not refresh. Click refresh in your browser if you wish to view the changes in status. +
+

+ Database totals:

+ + "; + echo "{$blacklist_items} total items in the blacklist.
"; + echo "{$spamdb_grey} total items in the greylist.
"; + echo "{$spamdb_items} total items in the SpamDB.
"; + ?> +
+

-- cgit v1.2.3 From 7a9e46eacace6d7d18b6afd4b0661ed54000492c Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 13:11:38 +0200 Subject: Delete spamd_db_ext.php Running exit() is not useful. Delete abandoned unsupported script. --- config/spamd/spamd_db_ext.php | 229 ------------------------------------------ 1 file changed, 229 deletions(-) delete mode 100644 config/spamd/spamd_db_ext.php diff --git a/config/spamd/spamd_db_ext.php b/config/spamd/spamd_db_ext.php deleted file mode 100644 index 010027e3..00000000 --- a/config/spamd/spamd_db_ext.php +++ /dev/null @@ -1,229 +0,0 @@ - $username) { - echo "550. INVALID USERNAME {$username}."; - exit; - } - if($outlook['password'] <> $password) { - echo "550. INVALID PASSWORD {$password}."; - exit; - } -} - -/* handle AJAX operations */ -if($_GET['action'] or $_POST['action']) { - if($_GET['action']) - $action = escapeshellarg(trim($_GET['action'])); - if($_POST['action']) - $action = escapeshellarg(trim($_POST['action'])); - if($_GET['srcip']) - $srcip = escapeshellarg(trim($_GET['srcip'])); - if($_POST['srcip']) - $srcip = escapeshellarg(trim($_POST['srcip'])); - if($_POST['email']) - $email = escapeshellarg(trim($_POST['email'])); - if($_GET['email']) - $email = escapeshellarg(trim($_GET['email'])); - /* execute spamdb command */ - if($action == "whitelist") { - delete_from_spamd_db($srcip); - usleep(100); - exec("/usr/local/sbin/spamdb -a {$srcip}"); - mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - delete_from_blacklist($srcip); - log_error("spamd: {$srcip} has been whitelisted by {$_SERVER['REMOTE_ADDR']} {$loginname}"); - hup_spamd(); - exit; - } else if($action == "delete") { - delete_from_spamd_db($srcip); - usleep(100); - 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_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(); - mwexec("/sbin/pfctl -q -t blacklist -T add -f /var/db/blacklist.txt"); - log_error("spamd: {$srcip} has been blacklisted by {$_SERVER['REMOTE_ADDR']} {$loginname}"); - 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); - log_error("spamd: {$srcip} has been trapped by {$_SERVER['REMOTE_ADDR']} {$loginname}"); - hup_spamd(); - exit; - } - /* signal a reload for real time effect. */ - hup_spamd(); - exit; -} - -/* spam trap e-mail address */ -if($_POST['spamtrapemail'] <> "") { - $spamtrapemail = escapeshellarg($_POST['spamtrapemail']); - exec("/usr/local/sbin/spamdb -d {$spamtrapemail}"); - exec("/usr/local/sbin/spamdb -d -T \"{$spamtrapemail}\""); - exec("/usr/local/sbin/spamdb -d -t \"{$spamtrapemail}\""); - mwexec("/usr/local/sbin/spamdb -T -a \"{$spamtrapemail}\""); - mwexec("killall -HUP spamlogd"); - $savemsg = htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; -} - -if($_GET['getstatus'] <> "") { - $getstatus = escapeshellarg($_GET['getstatus']); - $status = exec("/usr/local/sbin/spamdb | grep \"{$getstatus}\""); - if(stristr($status, "WHITE") == true) { - echo "WHITE"; - } else if(stristr($status, "TRAPPED") == true) { - echo "TRAPPED"; - } else if(stristr($status, "GREY") == true) { - echo "GREY"; - } else if(stristr($status, "SPAMTRAP") == true) { - echo "SPAMTRAP"; - } else { - echo "NOT FOUND"; - } - exit; -} - -/* spam trap e-mail address */ -if($_GET['spamtrapemail'] <> "") { - $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); - $status = exec("spamdb -T -a \"{$spamtrapemail}\""); - mwexec("killall -HUP spamlogd"); - if($status) - echo $status; - else - echo htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; - exit; -} - -/* spam trap e-mail address */ -if($_GET['whitelist'] <> "") { - $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); - $status = exec("spamdb -a \"{$spamtrapemail}\""); - mwexec("killall -HUP spamlogd"); - if($status) - echo $status; - else - echo htmlentities($_POST['spamtrapemail']) . " added to whitelist database."; - exit; -} - -function delete_from_spamd_db($srcip) { - $fd = fopen("/tmp/execcmds", "w"); - fwrite($fd, "#!/bin/sh\n"); - fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip}\n"); - fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip} -T\n"); - fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip} -t\n"); - fwrite($fd, "/usr/local/sbin/spamdb -d \"{$srcip}\" -t\n"); - fwrite($fd, "/usr/local/sbin/spamdb -d \"{$srcip}\" -T\n"); - fclose($fd); - exec("/bin/chmod a+rx /tmp/execcmds"); - system("/bin/sh /tmp/execcmds"); - mwexec("/usr/bin/killall -HUP spamlogd"); - mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); -} - -function basic_auth_prompt(){ - header("WWW-Authenticate: Basic realm=\".\""); - header("HTTP/1.0 401 Unauthorized"); - echo "You must enter valid credentials to access this resource."; - exit; -} - -function add_to_blacklist($srcip) { - $fd = fopen("/var/db/blacklist.txt", "a"); - fwrite($fd, "{$srcip}\n"); - fclose($fd); - mwexec("/sbin/pfctl -q -t spamd -T add -f /var/db/blacklist.txt"); - mwexec("/sbin/pfctl -q -t blacklist -T add -f /var/db/blacklist.txt"); -} - -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($bl <> "") - if(!stristr($bl, $srcip)) - fwrite($fd, "{$bl}\n"); - } - fclose($fd); - mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); - mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); -} - -function delete_from_whitelist($srcip) { - $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"); -} - -function hup_spamd() { - mwexec("killall -HUP spamlogd"); -} - -exit; - -?> -- cgit v1.2.3 From 7ec9e96fc39291487cd143887a612293cf46412c Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 13:12:36 +0200 Subject: Remove reference to abandonded spamd_db_ext.php file --- config/spamd/spamd.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/spamd/spamd.xml b/config/spamd/spamd.xml index 6bd1574c..1b42018a 100644 --- a/config/spamd/spamd.xml +++ b/config/spamd/spamd.xml @@ -115,10 +115,6 @@ /usr/local/www/ https://packages.pfsense.org/packages/config/spamd/spamd_db.php - - /usr/local/www/ - https://packages.pfsense.org/packages/config/spamd/spamd_db_ext.php - /usr/local/bin/ https://packages.pfsense.org/packages/config/spamd/spamd_gather_stats.php -- cgit v1.2.3 From 06fd33487b6bf5b0216dc1aff7db24dbc350a69a Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 13:16:25 +0200 Subject: Delete spamd_outlook.xml Not used anywhere, depending on the abandoned spamd_db_ext.php. --- config/spamd/spamd_outlook.xml | 90 ------------------------------------------ 1 file changed, 90 deletions(-) delete mode 100644 config/spamd/spamd_outlook.xml diff --git a/config/spamd/spamd_outlook.xml b/config/spamd/spamd_outlook.xml deleted file mode 100644 index 5e94701f..00000000 --- a/config/spamd/spamd_outlook.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - . - All rights reserved. - */ -/* ========================================================================== */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ -/* ========================================================================== */ - ]]> - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. - spamdoutlook - 0.1.0 - SpamD Outlook - pkg_edit.php?xml=spamd_outlook.xml&id=0 - - - SpamD External Sources - /pkg.php?xml=spamd.xml - - - SpamD Whitelist - /pkg.php?xml=spamd_whitelist.xml - - - SpamD Settings - /pkg_edit.php?xml=spamd_settings.xml&id=0 - - - SpamD Database - /spamd_db.php - - - - ['installedpackages']['spamd']['config'] - - - - Username - username - Enter the username the outlook clients will use to connect with. - input - - - Password - password - Enter the password the outlook clients will use to connect with. - password - - - - \ No newline at end of file -- cgit v1.2.3 From 77c9bc5520deed96c4b1ec138e472871420859ce Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 13:17:50 +0200 Subject: Remove reference to abandonded spamd_outlook.xml file --- config/spamd/spamd.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/spamd/spamd.xml b/config/spamd/spamd.xml index 1b42018a..ba433bbf 100644 --- a/config/spamd/spamd.xml +++ b/config/spamd/spamd.xml @@ -99,10 +99,6 @@ /usr/local/pkg/ https://packages.pfsense.org/packages/config/spamd/spamd_whitelist.xml - - /usr/local/pkg/ - https://packages.pfsense.org/packages/config/spamd/spamd_outlook.xml - /usr/local/pkg/ https://packages.pfsense.org/packages/config/spamd/spamd.inc -- cgit v1.2.3 From a6ff855e75fa5e5a57d455f7a97f8c41677cc76b Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 13:20:59 +0200 Subject: Delete spamd_gather_stats.php Not used anywhere, useless dead code. --- config/spamd/spamd_gather_stats.php | 85 ------------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 config/spamd/spamd_gather_stats.php diff --git a/config/spamd/spamd_gather_stats.php b/config/spamd/spamd_gather_stats.php deleted file mode 100644 index 2fee6904..00000000 --- a/config/spamd/spamd_gather_stats.php +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/local/bin/php -q - - \ No newline at end of file -- cgit v1.2.3 From fc8132ded92be96b280660cc9f4ab289ec322107 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 13:22:27 +0200 Subject: Delete spamd_exchexp.asp Not used anywhere, useless dead code. --- config/spamd/spamd_exchexp.asp | 50 ------------------------------------------ 1 file changed, 50 deletions(-) delete mode 100644 config/spamd/spamd_exchexp.asp diff --git a/config/spamd/spamd_exchexp.asp b/config/spamd/spamd_exchexp.asp deleted file mode 100644 index 56b0c629..00000000 --- a/config/spamd/spamd_exchexp.asp +++ /dev/null @@ -1,50 +0,0 @@ -<% - -dim server -server = "SERVERNAME" - -Sub ExportUsers(oObject) - Dim oUser - For Each oUser in oObject - Select Case oUser.Class - Case "user" - If oUser.mail <> "" then - - for each email in oUser.proxyAddresses - If (lcase(left(email,4))="smtp") Then - 'userFile.WriteLine Mid(email,6) - document.write Mid(email,6) & vbCrLf - End If - next - End if - Case "organizationalUnit" , "container" - If UsersinOU (oUser) then - ExportUsers(oUser) - End if - End select - Next -End Sub - -Function UsersinOU (oObject) - Dim oUser - UsersinOU = False - for Each oUser in oObject - Select Case oUser.Class - Case "organizationalUnit" , "container" - UsersinOU = UsersinOU(oUser) - Case "user" - UsersinOU = True - - End select - Next -End Function - -Dim rootDSE, domainObject -Set rootDSE=GetObject("LDAP://" & server & "/RootDSE") -domainContainer = rootDSE.Get("defaultNamingContext") -Set domainObject = GetObject("LDAP://" & domainContainer) - -ExportUsers(domainObject) -Set oDomain = Nothing - -%> \ No newline at end of file -- cgit v1.2.3 From e0900b415622cc17e84b1ed2538665d21270d003 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 13:23:07 +0200 Subject: Delete spamd_verify_to_address.php Not used anywhere, useless dead code. --- config/spamd/spamd_verify_to_address.php | 142 ------------------------------- 1 file changed, 142 deletions(-) delete mode 100644 config/spamd/spamd_verify_to_address.php diff --git a/config/spamd/spamd_verify_to_address.php b/config/spamd/spamd_verify_to_address.php deleted file mode 100644 index 504107d3..00000000 --- a/config/spamd/spamd_verify_to_address.php +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/local/bin/php -q - from email addresses */ -for($x=0; isset($current_spamtrap[$x]); $x++) { - $current_spamtrap[$x] = str_replace("<", "", $current_spamtrap[$x]); - $current_spamtrap[$x] = str_replace(">", "", $current_spamtrap[$x]); -} - -/* traverse list and find the dictionary attackers, etc */ -foreach($grey_hosts as $grey) { - if(trim($grey) == "") - continue; - /* clean up and further break down values */ - $grey_lower = strtolower($grey); - $grey_lower = str_replace("<","",$grey_lower); - $grey_lower = str_replace(">","",$grey_lower); - $grey_split = split("\|", $grey_lower); - $email_from = strtolower($grey_split[2]); - $email_to = strtolower($grey_split[3]); - $server_ip = strtolower($grey_split[1]); - if(in_array($server_ip, $current_blacklist)) { - if($debug) - echo "$server_ip already in blacklist.\n"; - continue; - } - if(in_array($email_to, $current_spamtrap)) { - if($email_to) - echo "$email_to already in blacklist.\n"; - continue; - } - if($debug) - echo "Testing $email_from | $email_to \n"; - if (in_array($email_to, $valid_list)) { - if($debug) - echo "$email_to is in the valid list\n"; - } else { - /* spammer picked the wrong person to mess with */ - if($server_ip) { - if($debug) - echo "/usr/local/sbin/spamdb -a $server_ip -t\n"; - exec("/usr/local/sbin/spamdb -d {$server_ip} 2>/dev/null"); - exec("/usr/local/sbin/spamdb -d {$server_ip} -T 2>/dev/null"); - exec("/usr/local/sbin/spamdb -d {$server_ip} -t 2>/dev/null"); - if($debug) - echo "/usr/local/sbin/spamdb -a \"<$email_to>\" -T\n"; - exec("/usr/local/sbin/spamdb -a \"<$email_to>\" -T"); - system("echo $server_ip >> /var/db/blacklist.txt"); - $result = mwexec("/usr/local/sbin/spamdb -a $server_ip -t"); - } else { - if($debug) - echo "Could not locate server ip address."; - } - if($debug) - echo "Script result code: {$result}\n"; - } -} - -mwexec("killall -HUP spamlogd"); - -if($debug) { - echo "\nSearch completed.\n\n"; - echo "Items trapped: "; - system("/usr/local/sbin/spamdb | grep TRAPPED | wc -l"); - echo "Items spamtrapped: "; - system("/usr/local/sbin/spamdb | grep SPAMTRAP | wc -l"); - echo "Items in blacklist.txt: "; - system("/sbin/pfctl -t blacklist -T show | wc -l"); -} - -mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - -?> -- cgit v1.2.3 From f64cc246ea4ce77c8efb64f16a80cac96954280a Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 13:25:36 +0200 Subject: Remove reference to abandonded spamd_gather_stats.php file --- config/spamd/spamd.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/spamd/spamd.xml b/config/spamd/spamd.xml index ba433bbf..b05dd191 100644 --- a/config/spamd/spamd.xml +++ b/config/spamd/spamd.xml @@ -111,10 +111,6 @@ /usr/local/www/ https://packages.pfsense.org/packages/config/spamd/spamd_db.php - - /usr/local/bin/ - https://packages.pfsense.org/packages/config/spamd/spamd_gather_stats.php - Provider Name -- cgit v1.2.3 From 79980dea0595d343cee8cbc41eba9019f81fedcf Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 13:28:36 +0200 Subject: Delete spamd_rules.php Another unused piece of garbage, replaced with spamd_generate_rules(). --- config/spamd/spamd_rules.php | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 config/spamd/spamd_rules.php diff --git a/config/spamd/spamd_rules.php b/config/spamd/spamd_rules.php deleted file mode 100644 index 27ac850a..00000000 --- a/config/spamd/spamd_rules.php +++ /dev/null @@ -1,34 +0,0 @@ - -/* - spamd_rules.inc - part of pfSense (www.pfSense.com) - Copyright (C) 2004 Scott Ullrich (sullrich@gmail.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ -$wanif = get_real_wan_interface(); -$anchor = "natearly"; -$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"; -$label = "spamd"; -add_rule_to_anchor($anchor, $rule, $label); -- cgit v1.2.3 From f87f906d111f162caf2b6d2e64f4114661876529 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 13:30:32 +0200 Subject: Remove reference to abandonded spamd_rules.php file And yet more of dead garbage. --- config/spamd/spamd.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/spamd/spamd.xml b/config/spamd/spamd.xml index b05dd191..de03d224 100644 --- a/config/spamd/spamd.xml +++ b/config/spamd/spamd.xml @@ -91,10 +91,6 @@ providerdescription - - /usr/local/www/ - https://packages.pfsense.org/packages/config/spamd/spamd_rules.php - /usr/local/pkg/ https://packages.pfsense.org/packages/config/spamd/spamd_whitelist.xml -- cgit v1.2.3 From 677367d728c03a28070e29fcc6adac8edca6d636 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 14:19:50 +0200 Subject: spamd - code style cleanup and multiple fixes - Fix copyright header - Remove service and menu tags that are already specified in packages configfile (spamd.xml) - Nuke useless comments - Make descriptions readable - Fix default values handling - Remove completely bogus "Enable RRD graphing" option that had no code attached to it. - Indentation/whitespace fixes --- config/spamd/spamd_settings.xml | 218 +++++++++++++++++++++++----------------- 1 file changed, 124 insertions(+), 94 deletions(-) diff --git a/config/spamd/spamd_settings.xml b/config/spamd/spamd_settings.xml index 225ef4a6..a3387279 100644 --- a/config/spamd/spamd_settings.xml +++ b/config/spamd/spamd_settings.xml @@ -1,62 +1,51 @@ - - + + - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* ====================================================================================== */ + ]]> + spamdsettings - 1.1.1 + 1.1.5 SpamD: Settings pkg_edit.php?xml=spamd_settings.xml&id=0 /usr/local/pkg/spamd.inc - - - SpamD -
Services
- spamd.xml -
- - spamd - spamd.sh - spamd - SpamD External Sources @@ -76,18 +65,12 @@ /spamd_db.php - ['installedpackages']['spamd']['config'] - - Intercept on interfaces + Intercept on Interfaces spamdbinds_array - - - + These are the interfaces SpamD will intercept SMTP connections on. interfaces_selection true loopback @@ -97,71 +80,119 @@ identifier The SMTP version banner that is reported upon initial connection. input - +
- Maximum blacklisted connections + Maximum Blacklisted Connections maxblack - The maximum number of concurrent blacklisted connections to allow in greylisting mode. This value may not be greater than maxcon (see below). The default is maxcon - 100. + + + (Default: 'Max Concurrent Connections' - 100) + ]]> + input + 10 - Max concurrent connections + Max Concurrent Connections maxcon - The maximum number of concurrent connections to allow. The default is 800. + + + (Default: 800) + ]]> + input - 800 + 10 + 800 - Grey listing + Greylisting greylisting - Connections from addresses not blacklisted on the black lists tab will be considered for greylisting. Such connections will not be stuttered at (though see the stutter secs option) or delayed, and will receive the pleasantly innocuous temporary failure. After passtime if the host returns it will be added to the white list. + + + checkbox - yes + passtime,greyexp,whiteexp + on Passtime passtime - Adjust the three time parameters for greylisting. Passtime defaults to 25 (minutes). After passtime minutes if spamd sees a retried attempt to deliver mail for the same tuple, spamd will whitelist the connecting address by adding it as a whitelist entry. + + + (Default: 25 minutes) + ]]> + input - 30 - 25:4:864 + 5 + 25 Grey Expiration greyexp - Adjust the three time parameters for greylisting. Grey expiration defaults to 4. SpamD removes connection entries from the database if delivery has not been retried within greyexp hours from the initial time a connection is seen. + + + (Default: 4 hours) + ]]> + input - 30 - 25:4:864 + 5 + 4 White Exp whiteexp - Adjust the three time parameters for greylisting. White expiration defaults to 864 (hours, approximately 36 days). SpamD removes whitelist entries from the database if no mail delivery activity has been seen from the whitelisted address within whiteexp hours from the initial time an address is whitelisted. + + + (Default: 864 hours - approximately 36 days) + ]]> + input - 30 - 25:4:864 + 5 + 864 Stutter Secs stuttersecs - Stutter at greylisted connections for the specified amount of seconds, after which the connection is not stuttered at. Defaults to 10. + + + (Defaults: 10 seconds) + ]]> + input - 10 + 5 + 10 Delay Secs delaysecs - Delay each character sent to the client by the specified amount of seconds. Defaults to 1. + + + (Default: 1 second) + ]]> + input - 1 + 5 + 1 Window Size window Set the socket receive buffer to this many bytes, adjusting the window size. input - NextMTA nextmta - Automatically sends messages after being processed by SpamD to IP Address. You may enter an alias if you like, simply prepend $ to the alias name. example: $mailservers. Note, if you have postfix package installed enter 127.0.0.1 here. + + + (Example: $mailservers)
+ Note: If you have postfix package installed, enter 127.0.0.1 here.
+ ]]> +
input - 1 + on
- - Enable RRD graphing - enablerrd - Enables the graphing of SpamD connection and disconnection statistics. - checkbox - -
spamd_validate_input($_POST, $input_errors); - + sync_package_spamd(); - \ No newline at end of file + -- cgit v1.2.3 From 5864757af01c62035ebd5b9d6ef8f423eab7d6ea Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 14:23:56 +0200 Subject: spamd - code style cleanup and multiple fixes - Fix copyright header - Remove useless comments - Indentation/whitespace fixes --- config/spamd/spamd_whitelist.xml | 91 ++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 50 deletions(-) diff --git a/config/spamd/spamd_whitelist.xml b/config/spamd/spamd_whitelist.xml index 8a916fb7..7b80d268 100644 --- a/config/spamd/spamd_whitelist.xml +++ b/config/spamd/spamd_whitelist.xml @@ -1,55 +1,50 @@ - - + + - - +. - All rights reserved. - */ -/* ========================================================================== */ + spamd_settings.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2008 Scott Ullrich + Copyright (C) 2015 ESF, LLC + All rights reserved. +*/ +/* ====================================================================================== */ /* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ -/* ========================================================================== */ - ]]> - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* ====================================================================================== */ + ]]> + spamd-whitelist - 0.1.0 + 1.1.5 SpamD: Whitelist /usr/local/pkg/spamd.inc - SpamD Whitelist @@ -69,14 +64,12 @@ SpamD Settings /pkg_edit.php?xml=spamd_settings.xml&id=0 - + SpamD Database /spamd_db.php - ['installedpackages']['spamdwhitelist']['config'] @@ -88,26 +81,24 @@ description - Exempted IP ip - Enter the IP to exempt from blacklisting + Enter the IP to exempt from blacklisting. input Description description - Enter the description for this item + Enter the description for this item. input sync_package_spamd_whitelist(); - + sync_package_spamd_whitelist(); - \ No newline at end of file + -- cgit v1.2.3 From 4db5174b2842821226e4dc91a3c5e9b3c78d0084 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 14:25:26 +0200 Subject: Bump spamd package version --- pkg_config.10.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 8e7c95ba..95e80268 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -438,7 +438,7 @@ Services https://packages.pfsense.org/packages/config/spamd/spamd.xml spamd-4.9.1_2-##ARCH##.pbi - 1.1.4 + 1.1.5 Beta 2.2 mail -- cgit v1.2.3 From 5bac2b3205e6549d85093ee102ce684571ef091f Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 15:45:58 +0200 Subject: spamd - code style cleanup and multiple fixes - Fix input validation for NextMTA and require IPv4, no aliases allowed since it was producing broken firewall rules and is generally pointless for a single IP. --- config/spamd/spamd.inc | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/config/spamd/spamd.inc b/config/spamd/spamd.inc index 98cdc561..f481da54 100644 --- a/config/spamd/spamd.inc +++ b/config/spamd/spamd.inc @@ -103,8 +103,8 @@ function sync_package_spamd() { log_error("[spamd] Looping through spamdsettings"); if ($config['installedpackages']['spamdsettings']['config']) { foreach ($config['installedpackages']['spamdsettings']['config'] as $ss) { - if ($ss['nextmta'] != "") { - $nextmta = $ss['nextmta']; + if ($ss['next_mta'] != "") { + $nextmta = $ss['next_mta']; } if ($ss['greylistingparms'] != "") { $passtime = " -G " . $ss['greylistingparms']; @@ -213,7 +213,7 @@ function spamd_generate_rules($type) { } if ($spamdconfig) { - $nextmta = $spamdconfig['nextmta']; + $nextmta = $spamdconfig['next_mta']; $spamdbinds = explode(',', $spamdconfig['spamdbinds_array']); if (is_array($spamdbinds)) { foreach ($spamdbinds as $interface) { @@ -312,21 +312,10 @@ function custom_php_deinstall_command() { } function spamd_validate_input($post, &$input_errors) { - global $config; - $nextmta = str_replace("$", "", $post['nextmta']); - if (stristr($nextmta, "{")) { - /* item is an alias, make sure the name exists */ - $nextmta = str_replace("$", "", $nextmta); - $found = false; - if ($config['aliases']['alias']) { - foreach ($config['aliases']['alias'] as $alias) { - if ($alias['name'] == $nextmta) { - $found = true; - } - } + if (!empty($post["next_mta"])) { + if (!is_ipaddrv4($post['next_mta'])) { + $input_errors[] = "NextMTA is not a valid IPv4 address"; } - if ($found == false) - $input_errors[] = "Could not locate alias named " . htmlentities($nextmta); } } -- cgit v1.2.3 From 9effc39ed1f07a50909d516cf797d3c7aa10b272 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 15:49:07 +0200 Subject: spamd - code style cleanup and multiple fixes Require IPv4 for NextMTA -- no aliases allowed since it was producing broken firewall rules and is generally pointless for a single IP. Never had a chance of working properly, no configuration upgrade required here. --- config/spamd/spamd_settings.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/config/spamd/spamd_settings.xml b/config/spamd/spamd_settings.xml index a3387279..2793221b 100644 --- a/config/spamd/spamd_settings.xml +++ b/config/spamd/spamd_settings.xml @@ -212,12 +212,11 @@ --> NextMTA - nextmta + next_mta - (Example: $mailservers)
- Note: If you have postfix package installed, enter 127.0.0.1 here.
+ After processing, automatically send messages to specified IP address.
+ Note: If you have postfix package installed, enter 127.0.0.1 here. ]]>
input -- cgit v1.2.3