diff options
author | Fernando Lemos <fernandotcl@pfsense.org> | 2006-06-02 13:45:55 +0000 |
---|---|---|
committer | Fernando Lemos <fernandotcl@pfsense.org> | 2006-06-02 13:45:55 +0000 |
commit | 97b095c2c8b4a5d37bd3f4112dff0b906038edcf (patch) | |
tree | 8cab41852f44f7bf6a10ba7708d26283d2dd3a39 /packages | |
parent | c868bc5be8c9f7cc8b7ca91bbd36990a931d9875 (diff) | |
download | pfsense-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')
-rw-r--r-- | packages/sassassin.inc | 63 | ||||
-rw-r--r-- | packages/sassassin.xml | 117 | ||||
-rw-r--r-- | packages/sassassin_bl.xml | 49 | ||||
-rw-r--r-- | packages/sassassin_wl.xml | 49 |
4 files changed, 278 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.'; +} +?> diff --git a/packages/sassassin.xml b/packages/sassassin.xml new file mode 100644 index 00000000..adc04951 --- /dev/null +++ b/packages/sassassin.xml @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="utf-8"?> +<packagegui> + <include_file>sassassin.inc</include_file> + + <!-- Installation --> + <additional_files_needed> + <item>http://www.pfsense.org/packages/config/sassassin_wl.xml</item> + </additional_files_needed> + <additional_files_needed> + <item>http://www.pfsense.org/packages/config/sassassin_bl.xml</item> + </additional_files_needed> + <additional_files_needed> + <item>http://www.pfsense.org/packages/config/sassassin.inc</item> + </additional_files_needed> + <custom_php_install_command> + sassassin_install_command(); + </custom_php_install_command> + <menu> + <name>Antispam</name> + <tooltiptext>Configure the Antispam service.</tooltiptext> + <section>Services</section> + <url>/pkg_edit.php?xml=sassassin.xml&id=0</url> + </menu> + <service> + <name>SpamAssassin</name> + <description>The SpamAssassin spam detection software.</description> + <rcfile>spamd.sh</rcfile> + <executable>spamd</executable> + </service> + + <!-- Interface --> + <name>spamassassin</name> + <title>Antispam: Configuration</title> + <tabs> + <tab> + <text>Configuration</text> + <url>/pkg_edit.php?xml=sassassin.xml&id=0</url> + <active/> + </tab> + <tab> + <text>Whitelist</text> + <url>/pkg.php?xml=sassassin_wl.xml</url> + </tab> + <tab> + <text>Blacklist</text> + <url>/pkg.php?xml=sassassin_bl.xml</url> + </tab> + </tabs> + <fields> + <field> + <fieldname>enable</fieldname> + <fielddescr>Enable antispam</fielddescr> + <description>Check to enable the antispam protection.</description> + <required/> + <type>checkbox</type> + <enablefields>bayes,bayes_learn,threshold,subject,send_spam</enablefields> + </field> + <field> + <fieldname>bayes</fieldname> + <fielddescr>Bayesian classifier</fielddescr> + <description>Check this to enable the Bayesian classifier.</description> + <default_value>on</default_value> + <required/> + <type>checkbox</type> + </field> + <field> + <fieldname>bayes_learn</fieldname> + <fielddescr>Bayesian auto-learning</fielddescr> + <description>Check this to enable the Bayesian auto-learning system.</description> + <default_value>on</default_value> + <required/> + <type>checkbox</type> + </field> + <field> + <fieldname>threshold</fieldname> + <fielddescr>Spam threshold</fielddescr> + <description>Set the threshold at which a message is considered spam.</description> + <default_value>5.0</default_value> + <required/> + <type>input</type> + </field> + <field> + <fieldname>subject</fieldname> + <fielddescr>Rewrite subject</fielddescr> + <description>This is the string that will be added to the subject of spam emails.</description> + <default_value>*** SPAM ***</default_value> + <type>input</type> + </field> + <field> + <fieldname>send_spam</fieldname> + <fielddescr>How to send spam messages</fielddescr> + <description>Choose between not sending spam messages, sending them as an RFC-822 MIME attachment (recommended) or as plain text.</description> + <type>select</type> + <options> + <option> + <value>donotsave</value> + <name>Do not send</name> + </option> + <option> + <value>attachment</value> + <name>Send as an attachment (recommended)</name> + </option> + <option> + <value>plaintext</value> + <name>Send as plain text</name> + </option> + </options> + <default_value>attachment</default_value> + </field> + </fields> + <custom_php_validation_command> + sassassin_validate_input($_POST, &$input_errors); + </custom_php_validation_command> + <custom_php_resync_config_command> + sassassin_resync(); + </custom_php_resync_config_command> +</packagegui> diff --git a/packages/sassassin_bl.xml b/packages/sassassin_bl.xml new file mode 100644 index 00000000..b03827a0 --- /dev/null +++ b/packages/sassassin_bl.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<packagegui> + <name>sassassinbl</name> + <title>AntiSPAM: Blacklist</title> + <include_file>sassassin.inc</include_file> + <tabs> + <tab> + <text>Configuration</text> + <url>/pkg_edit.php?xml=sassassin.xml&id=0</url> + </tab> + <tab> + <text>Whitelist</text> + <url>/pkg.php?xml=sassassin_wl.xml</url> + </tab> + <tab> + <text>Blacklist</text> + <url>/pkg.php?xml=sassassin_bl.xml</url> + <active/> + </tab> + </tabs> + <adddeleteeditpagefields> + <columnitem> + <fieldname>address</fieldname> + <fielddescr>Address</fielddescr> + </columnitem> + <columnitem> + <fieldname>description</fieldname> + <fielddescr>Description</fielddescr> + </columnitem> + </adddeleteeditpagefields> + <fields> + <field> + <fieldname>address</fieldname> + <fielddescr>Address</fielddescr> + <description>This is the email address that will be added to the blacklist (valid wildcards: *, ?).</description> + <required/> + <type>input</type> + </field> + <field> + <fieldname>description</fieldname> + <fielddescr>Description</fielddescr> + <description>You may enter a description here for your reference (not parsed).</description> + <type>input</type> + </field> + </fields> + <custom_php_resync_config_command> + sassassin_resync(); + </custom_php_resync_config_command> +</packagegui> diff --git a/packages/sassassin_wl.xml b/packages/sassassin_wl.xml new file mode 100644 index 00000000..fef5036e --- /dev/null +++ b/packages/sassassin_wl.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<packagegui> + <name>sassassinwl</name> + <title>AntiSPAM: Whitelist</title> + <include_file>sassassin.inc</include_file> + <tabs> + <tab> + <text>Configuration</text> + <url>/pkg_edit.php?xml=sassassin.xml&id=0</url> + </tab> + <tab> + <text>Whitelist</text> + <url>/pkg.php?xml=sassassin_wl.xml</url> + <active/> + </tab> + <tab> + <text>Blacklist</text> + <url>/pkg.php?xml=sassassin_bl.xml</url> + </tab> + </tabs> + <adddeleteeditpagefields> + <columnitem> + <fieldname>address</fieldname> + <fielddescr>Address</fielddescr> + </columnitem> + <columnitem> + <fieldname>description</fieldname> + <fielddescr>Description</fielddescr> + </columnitem> + </adddeleteeditpagefields> + <fields> + <field> + <fieldname>address</fieldname> + <fielddescr>Address</fielddescr> + <description>This is the email address that will be added to the whitelist (valid wildcards: *, ?).</description> + <required/> + <type>input</type> + </field> + <field> + <fieldname>description</fieldname> + <fielddescr>Description</fielddescr> + <description>You may enter a description here for your reference (not parsed).</description> + <type>input</type> + </field> + </fields> + <custom_php_resync_config_command> + sassassin_resync(); + </custom_php_resync_config_command> +</packagegui> |