aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sassassin.inc
diff options
context:
space:
mode:
authorFernando Lemos <fernandotcl@pfsense.org>2006-06-02 13:45:55 +0000
committerFernando Lemos <fernandotcl@pfsense.org>2006-06-02 13:45:55 +0000
commit97b095c2c8b4a5d37bd3f4112dff0b906038edcf (patch)
tree8cab41852f44f7bf6a10ba7708d26283d2dd3a39 /packages/sassassin.inc
parentc868bc5be8c9f7cc8b7ca91bbd36990a931d9875 (diff)
downloadpfsense-packages-97b095c2c8b4a5d37bd3f4112dff0b906038edcf.tar.gz
pfsense-packages-97b095c2c8b4a5d37bd3f4112dff0b906038edcf.tar.bz2
pfsense-packages-97b095c2c8b4a5d37bd3f4112dff0b906038edcf.zip
This was the first package I wrote, don't know how well it complies to the new pkg_edit.php, but it should do fine. Blacklist + whitelist + simple configuration.
Diffstat (limited to 'packages/sassassin.inc')
-rw-r--r--packages/sassassin.inc63
1 files changed, 63 insertions, 0 deletions
diff --git a/packages/sassassin.inc b/packages/sassassin.inc
new file mode 100644
index 00000000..040f12ab
--- /dev/null
+++ b/packages/sassassin.inc
@@ -0,0 +1,63 @@
+<?php
+require_once('globals.inc');
+require_once('config.inc');
+require_once('service-utils.inc');
+
+function sassassin_install_command() {
+ global $g;
+
+ $oldrc = '/usr/local/etc/rc.d/sa-spamd.sh';
+ if (file_exists($oldrc)) unlink($oldrc);
+
+ $pidfile = "$rundir/spamd.pid";
+ $rcfile = array();
+ $rcfile['file'] = 'spamd.sh';
+ $rcfile['start'] = "mkdir -p $rundir\n\tspamd -u proxy -c -d -r $pidfile";
+ $rcfile['stop'] = "kill `cat $pidfile`";
+ write_rcfile($rcfile);
+}
+
+function sassassin_resync() {
+ global $config;
+
+ $settings = $config['installedpackages']['sassassin']['config'][0];
+
+ $use_bayes = ($settings['bayes'] == 'on' ? 1 : 0);
+ $bayes_auto_learn = ($settings['bayes_learn'] == 'on' ? 1 : 0);
+ $required_score = $settings['threshold'];
+ $rewrite_header = "Subject {$settings['subject']}";
+
+ $report_safe_array = array('donotsend' => 0, 'attachment' => 1, 'plaintext' => 2);
+ $report_safe = $report_safe_array[$settings['send_spam']];
+
+ $local_cf = <<<EOD
+use_bayes $use_bayes
+bayes_auto_learn $bayes_auto_learn
+required_score $required_score
+rewrite_header $rewrite_header
+report_safe $report_safe
+
+EOD;
+
+ foreach (array('whitelist' => 'wl', 'blacklist' => 'bl') as $list => $key) {
+ foreach ($config['installedpackages']["sassassin{$key}"]['config'] as $item) {
+ if (!empty($item))
+ $local_cf .= "{$list}_from {$item['address']}\n";
+ }
+ }
+
+ file_put_contents('/usr/local/etc/mail/spamassassin/local.cf', $local_cf);
+
+ restart_service('spamassassin');
+
+ if (get_pkg_id('p3scan') != -1) {
+ require_once('p3scan.inc');
+ p3scan_resync();
+ }
+}
+
+function sassassin_validate_input($post, $input_errors) {
+ if (!is_numeric($post['threshold']))
+ $input_errors[] = 'The field \'Spam threshold\' should contain a numeric value.';
+}
+?>