aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rwxr-xr-xconfig/freeradius2/freeradius.inc2
-rwxr-xr-xconfig/freeradius2/freeradiusclients.xml2
-rwxr-xr-xconfig/freeradius2/freeradiussettings.xml2
-rw-r--r--config/mailscanner/mailscanner.inc905
-rw-r--r--config/mailscanner/mailscanner.xml346
-rwxr-xr-xconfig/mailscanner/mailscanner_about.php98
-rw-r--r--config/mailscanner/mailscanner_alerts.xml158
-rw-r--r--config/mailscanner/mailscanner_antispam.xml401
-rw-r--r--config/mailscanner/mailscanner_antivirus.xml182
-rw-r--r--config/mailscanner/mailscanner_attachments.xml212
-rw-r--r--config/mailscanner/mailscanner_content.xml228
-rw-r--r--config/mailscanner/mailscanner_report.xml413
-rw-r--r--config/mailscanner/mailscanner_sync.xml132
-rw-r--r--config/postfix/postfix.inc6
-rw-r--r--config/postfix/postfix.php1469
-rw-r--r--config/postfix/postfix_antispam.xml16
-rwxr-xr-xconfig/postfix/postfix_queue.php12
-rwxr-xr-xconfig/postfix/postfix_search.php2
-rw-r--r--config/varnish64/varnish.inc4
19 files changed, 3857 insertions, 733 deletions
diff --git a/config/freeradius2/freeradius.inc b/config/freeradius2/freeradius.inc
index 9db22a44..2408e91c 100755
--- a/config/freeradius2/freeradius.inc
+++ b/config/freeradius2/freeradius.inc
@@ -70,7 +70,7 @@ logdir = \${localstatedir}/log
raddbdir = \${sysconfdir}/raddb
radacctdir = \${logdir}/radacct
confdir = \${raddbdir}
-run_dir = \${localstatedir}/run/radiusd
+run_dir = \${localstatedir}/run
libdir = \${exec_prefix}/lib/freeradius-2.1.12
pidfile = \${run_dir}/radiusd.pid
#user = nobody
diff --git a/config/freeradius2/freeradiusclients.xml b/config/freeradius2/freeradiusclients.xml
index e9417581..ce6abfdb 100755
--- a/config/freeradius2/freeradiusclients.xml
+++ b/config/freeradius2/freeradiusclients.xml
@@ -48,7 +48,7 @@
<name>freeradiusclients</name>
<version>none</version>
<title>FreeRADIUS: Clients</title>
- <include_file>freeradius.inc</include_file>
+ <include_file>/usr/local/pkg/freeradius.inc</include_file>
<tabs>
<tab>
<text>Users</text>
diff --git a/config/freeradius2/freeradiussettings.xml b/config/freeradius2/freeradiussettings.xml
index 4e9a7776..0ea8ae50 100755
--- a/config/freeradius2/freeradiussettings.xml
+++ b/config/freeradius2/freeradiussettings.xml
@@ -49,7 +49,7 @@
<version>none</version>
<title>FreeRADIUS: Settings</title>
<aftersaveredirect>pkg_edit.php?xml=freeradiussettings.xml&amp;id=0</aftersaveredirect>
- <include_file>freeradius.inc</include_file>
+ <include_file>/usr/local/pkg/freeradius.inc</include_file>
<tabs>
<tab>
<text>Users</text>
diff --git a/config/mailscanner/mailscanner.inc b/config/mailscanner/mailscanner.inc
new file mode 100644
index 00000000..fd7b6d16
--- /dev/null
+++ b/config/mailscanner/mailscanner.inc
@@ -0,0 +1,905 @@
+<?php
+/*
+ postfix.inc
+ part of the Postfix package for pfSense
+ Copyright (C) 2011 Marcello Coutinho
+ 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.
+
+*/
+
+require_once("util.inc");
+require("globals.inc");
+#require("guiconfig.inc");
+
+
+function ms_text_area_decode($text){
+ return preg_replace('/\r\n/', "\n",base64_decode($text));
+}
+
+function sync_package_mailscanner() {
+ global $config;
+
+ #assign xml arrays
+ if (is_array($config['installedpackages']['mailscanner']))
+ $mailscanner=$config['installedpackages']['mailscanner']['config'][0];
+ if (is_array($config['installedpackages']['msattachments']))
+ $attachments=$config['installedpackages']['msattachments']['config'][0];
+ if (is_array($config['installedpackages']['msantivirus']))
+ $antivirus=$config['installedpackages']['msantivirus']['config'][0];
+ if (is_array($config['installedpackages']['mscontent']))
+ $content=$config['installedpackages']['mscontent']['config'][0];
+ if (is_array($config['installedpackages']['msreport']))
+ $report=$config['installedpackages']['msreport']['config'][0];
+ if (is_array($config['installedpackages']['msantispam']))
+ $antispam=$config['installedpackages']['msantispam']['config'][0];
+ if (is_array($config['installedpackages']['msalerts']))
+ $alert=$config['installedpackages']['msalerts']['config'][0];
+
+ #General options
+ $info =($mailscanner['orgname']?'%org-name% = '.$mailscanner['orgname']."\n":'%org-name% = Pfsense'."\n");
+ $info .=($mailscanner['longorgname']?'%org-long-name% = '.$mailscanner['longorgname']."\n":'%org-long-name% = Pfsense Inc.'."\n");
+ $info .=($mailscanner['website']?'%web-site% = '.$mailscanner['website']."\n":'%web-site% = www.pfsense.com'."\n");
+ $max_children =($mailscanner['max_children']?$mailscanner['max_children']:'5');
+ $scan_messages=(preg_match('/ScanMessages/',$mailscanner['pim'])?"yes":"no");
+ $reject_message=(preg_match('/RejectMessage/',$mailscanner['pim'])?"yes":"no");
+ $default_rule_multiple=(preg_match('/UseDefaultRulesWithMultipleRecipients/',$mailscanner['advanced'])?"yes":"no");
+ $read_ipaddress=(preg_match('/ReadIPAddressFromReceivedHeader/',$mailscanner['advanced'])?"yes":"no");
+ $spam_score_format=($mailscanner['spam_score_format']?$mailscanner['spam_score_format']:'%d');
+ $cache_timings=($mailscanner['cache_timings']?$mailscanner['cache_timings']:'1800,300,10800,172800,600');
+ $debug_spam=(preg_match('/DebugSpamAssassin/',$mailscanner['advanced'])?"yes":"no");
+ $debug=(preg_match('/DebugMailScanner/',$mailscanner['advanced'])?"yes":"no");
+ $foreground=(preg_match('/RunInForeground/',$mailscanner['advanced'])?"yes":"no");
+ $look_up_last=(preg_match('/AlwaysLookedUpLast,/',$mailscanner['advanced'])?"yes":"no");
+ $look_up_last_batch=(preg_match('/AlwaysLookedUpLastAfterBatch/',$mailscanner['advanced'])?"yes":"no");
+ $deliver_background=(preg_match('/DeliverInBackground/',$mailscanner['advanced'])?"yes":"no");
+ $split_exim_spool=(preg_match('/Split Exim Spool/',$mailscanner['advanced'])?"yes":"no");
+ $syntax_check=(preg_match('/AutomaticSyntaxCheck/',$mailscanner['advanced'])?"yes":"no");
+ #logging
+ $syslog_facility=($mailscanner['syslog_facility']?$mailscanner['syslog_facility']:'mail');
+ $log_speed=(preg_match('/LogSpeed/',$mailscanner['syslog'])?"yes":"no");
+ $log_spam=(preg_match('/LogSpam/',$mailscanner['syslog'])?"yes":"no");
+ $log_non_spam=(preg_match('/LogNonSpam/',$mailscanner['syslog'])?"yes":"no");
+ $log_delivery=(preg_match('/LogDeliveryAndNon-Delivery/',$mailscanner['syslog'])?"yes":"no");
+ $log_filenames=(preg_match('/LogPermittedFilenames/',$mailscanner['syslog'])?"yes":"no");
+ $log_filetypes=(preg_match('/LogPermittedFiletypes/',$mailscanner['syslog'])?"yes":"no");
+ $log_mime=(preg_match('/LogPermittedFileMIME/',$mailscanner['syslog'])?"yes":"no");
+ $log_silent=(preg_match('/LogSilent/',$mailscanner['syslog'])?"yes":"no");
+ $log_dangerous=(preg_match('/LogDangerousHTML/',$mailscanner['syslog'])?"yes":"no");
+ $log_sa_rule_action=(preg_match('/LogSpamAssassinRule/',$mailscanner['syslog'])?"yes":"no");
+
+ #Attachment options
+ $max_size=($attachments['max_sizes']?$attachments['max_sizes']:'-1');
+ $archive_depth=($attachments['archive_depth']?$attachments['archive_depth']:'8');
+ $expand_tnef=(preg_match('/ExpandTNEF/',$attachments['features'])?"yes":"no");
+ $deliver_tnef=(preg_match('/DeliverUnparsableTNEF/',$attachments['features'])?"yes":"no");
+ $find_archive=(preg_match('/FindArchiveByContent/',$attachments['features'])?"yes":"no");
+ $microsoft=(preg_match('/UnpackMicrosoftDocuments/',$attachments['features'])?"yes":"no");
+ $zip_attachments=(preg_match('/ZipAttachments/',$attachments['features'])?"yes":"no");
+ $zip_file=($attachments['attachment_filename']?$attachments['attachment_filename']:'MessageAttachments.zip');
+ $zip_exclude=($attachments['attachment_extension_exclude']?$attachments['attachment_extension_exclude']:".zip .rar .gz .tgz .jpg .jpeg .mpg .mpe .mpeg .mp3 .rpm .htm .html .eml");
+ $unzip_max_per_archive=($attachments['attachment_max_per_archive']?$attachments['attachment_max_per_archive']:"0");
+ $unzip_max=($attachments['attachment_max']?$attachments['attachment_max']:"50k");
+
+ #Antivirus
+ $virus_scanning=(preg_match('/VirusScanning/',$antivirus['features'])?"yes":"no");
+ $deliver_disinfected=(preg_match('/DeliverDisinfectedFiles/',$antivirus['features'])?"yes":"no");
+ $antivirus_timeout=($antivirus['timeout']?$antivirus['timeout']:"300");
+ $silent_viruses=preg_replace("/,/"," ",$antivirus['silent_virus']);
+ $deliver_silent=(preg_match('/StillDeliverSilentViruses/',$antivirus['features'])?"yes":"no");
+ $spam_virus_header=($antivirus['virus_header']?$antivirus['virus_header']:'X-%org-name%-MailScanner-SpamVirus-Report:');
+ $block_encrypted=(preg_match('/BlockEncryptedMessages/',$antivirus['features'])?"yes":"no");
+ $block_unencrypted=(preg_match('/BlockUnencryptedMessages/',$antivirus['features'])?"yes":"no");
+ $allow_password=(preg_match('/AllowPassword-ProtectedArchives/',$antivirus['features'])?"yes":"no");
+ $check_filenames=(preg_match('/CheckFilenamesInPassword-ProtectedArchives/',$antivirus['features'])?"yes":"no");
+ $custom_antivirus_options=ms_text_area_decode($antivirus['custom']);
+
+ #content
+ $dangerous_content=(preg_match('/DangerousContentScanning/',$content['checks'])?"yes":"no");
+ $partial_messages=(preg_match('/AllowPartialMessages/',$content['checks'])?"yes":"no");
+ $external_bodies=(preg_match('/AllowExternalMessageBodies/',$content['checks'])?"yes":"no");
+ $phishing_fraud=(preg_match('/FindPhishingFraud/',$content['checks'])?"yes":"no");
+ $numeric_phishig=(preg_match('/AlsoFindNumericPhishing/',$content['checks'])?"yes":"no");
+ $stricter_phishing_net=(preg_match('/UseStricterPhishingNet/',$content['checks'])?"yes":"no");
+ $highlight_phishing=(preg_match('/HighlightPhishingFraud/',$content['checks'])?"yes":"no");
+ $dangerous_html=(preg_match('/ConvertDangerousHTMLToText/',$content['checks'])?"yes":"no");
+ $html_to_text=(preg_match('/ConvertHTMLToText/',$content['checks'])?"yes":"no");
+
+ #reports and responses
+ $include_scanner_name=(preg_match('/IncludeScannerNameInReports/',$report['features'])?"yes":"no");
+ $hide_incoming_work_dir=(preg_match('/HideIncomingWorkDir/',$report['features'])?"yes":"no");
+ $quarantine_whole_message_as_queue=(preg_match('/QuarantineWholeMessagesAsQueueFiles/',$report['features'])?"yes":"no");
+ $quarantine_whole_message=(preg_match('/QuarantineWholeMessage,/',$report['features'])?"yes":"no");
+ $quarantine_modified_body=(preg_match('/QuarantineModifiedBody/',$report['features'])?"yes":"no");
+ $quarantine_silent_virus=(preg_match('/QuarantineSilentViruses/',$report['features'])?"yes":"no");
+ $quarantine_infections=(preg_match('/QuarantineInfections/',$report['features'])?"yes":"no");
+ $keep_spam_and_mcp=(preg_match('/KeepSpamAndMCPArchiveClean/',$report['features'])?"yes":"no");
+ $report_language=strtolower($report['language']);
+
+ #notifications
+ $notify_sender=(preg_match('/NotifySenders,/',$report['notification'])?"yes":"no");
+ $notify_sender_viruses=(preg_match('/NotifySendersOfViruses/',$report['notification'])?"yes":"no");
+ $notify_sender_fileytypes=(preg_match('/NotifySendersOfFilenames/',$report['notification'])?"yes":"no");
+ $notify_sender_attachments=(preg_match('/NotifySendersSize/',$report['notification'])?"yes":"no");
+ $notify_sender_contents=(preg_match('/NotifySendersOfOtherBlockedContent/',$report['notification'])?"yes":"no");
+
+ #notices do system admin
+ $send_notices=(preg_match('/SendNotices/',$report['system'])?"yes":"no");
+ $notices_include_header=(preg_match('/NoticesIncludeFullHeaders/',$report['system'])?"yes":"no");
+ $hide_incoming_work_dir_notices=(preg_match('/HideIncomingWorkDirinNotices/',$report['system'])?"yes":"no");
+ $notice_from=($report['notice_from']?$report['notice_from']:"MailScanner");
+ $notice_to=($report['notice_to']?$report['notice_to']:"MailScanner");
+ $notice_signature=($report['notice_signature']?$report['notice_signature']:'-- \nMailScanner\nEmail Virus Scanner\nwww.mailscanner.info');
+
+ #antispa- spam assassin
+ $use_sa=(preg_match('/use_sa/',$antispam['safeatures'])?"yes":"no");
+ $sa_auto_whitelist=(preg_match('/sa_auto_whitelist/',$antispam['safeatures'])?"yes":"no");
+ $check_sa_if_on_spam_list=(preg_match('/check_sa_if_on_spam_list/',$antispam['safeatures'])?"yes":"no");
+ $include_sa_bin_attachments=(preg_match('/include_sa_bin_attachments/',$antispam['safeatures'])?"yes":"no");
+ $spam_score=(preg_match('/spam_score/',$antispam['safeatures'])?"yes":"no");
+ $cache_spamassassin_results=(preg_match('/cache_spamassassin_results/',$antispam['safeatures'])?"yes":"no");
+ $wait_during_bayes_rebuild=(preg_match('/wait_during_bayes_rebuild/',$antispam['safeatures'])?"yes":"no");
+ $sa_max=($antispam['sa_max']?$antispam['sa_max']:"40k");
+ $sa_score=($antispam['sa_score']?$antispam['sa_score']:"6");
+ $hi_score=($antispam['hi_score']?$antispam['hi_score']:"20");
+ $rebuild_bayes=($antispam['rebuild_bayes']?$antispam['rebuild_bayes']:"86400");
+ $spam_actions=($antispam['spam_actions']?preg_replace("/,/"," ",$antispam['spam_actions']):"deliver");
+ $hispam_actions=($antispam['hispam_actions']?preg_replace("/,/"," ",$antispam['hispam_actions']):"delete");
+ $use_sa=(preg_match('/use_sa/',$antispam['safeatures'])?"yes":"no");
+ #antispam - mcp
+ $mcp_checks=(preg_match('/mcp_checks/',$antispam['mcp_features'])?"yes":"no");
+ $bounce_mcp=(preg_match('/bounce_mcp/',$antispam['mcp_features'])?"yes":"no");
+ $is_mcp=(preg_match('/is_mcp/',$antispam['mcp_features'])?"yes":"no");
+ $is_not_mcp=(preg_match('/is_not_mcp/',$antispam['mcp_features'])?"yes":"no");
+ $mcp_is_high_score=(preg_match('/mcp_is_high_score/',$antispam['mcp_features'])?"yes":"no");
+ $include_mcp_report=(preg_match('/include_mcp_report/',$antispam['mcp_features'])?"yes":"no");
+ $detailled_mcp_report=(preg_match('/detailled_mcp_report/',$antispam['mcp_features'])?"yes":"no");
+ $score_mcp_report=(preg_match('/score_mcp_report/',$antispam['mcp_features'])?"yes":"no");
+ $log_mcp=(preg_match('/log_mcp/',$antispam['mcp_features'])?"yes":"no");
+ $mcp_score=($antispam['mcp_score']?$antispam['mcp_score']:"1");
+ $hi_mcp_score=($antispam['hi_mcp_score']?$antispam['hi_mcp_score']:"10");
+ $mcp_action=($antispam['mcp_action']?preg_replace("/,/"," ",$antispam['mcp_action']):"deliver");
+ $mcp_hi_action=($antispam['mcp_hi_action']?preg_replace("/,/"," ",$antispam['mcp_hi_action']):"delete");
+ $mcp_max=($antispam['mcp_max']?$antispam['mcp_max']:"200k");
+
+ /*
+Language Strings = %report-dir%/languages.conf
+*/
+ #check files
+ $load_samples=0;
+ $mailscanner_dir="/usr/local/etc/MailScanner";
+
+ if($attachments['filename_rules'] == ""){
+ $config['installedpackages']['msattachments']['config'][0]['filename_rules']=base64_encode(file_get_contents($mailscanner_dir.'/archives.filename.rules.conf.sample'));
+ $load_samples++;
+ }
+ if($attachments['filetype_rules'] == ""){
+ $config['installedpackages']['msattachments']['config'][0]['filetype_rules']=base64_encode(file_get_contents($mailscanner_dir.'/archives.filetype.rules.conf.sample'));
+ $load_samples++;
+ }
+ if($content['phishing_safe'] == ""){
+ $config['installedpackages']['mscontent']['config'][0]['phishing_safe']=base64_encode(file_get_contents($mailscanner_dir.'/phishing.safe.sites.conf.sample'));
+ $load_samples++;
+ }
+ if($content['phishing_bad'] == ""){
+ $config['installedpackages']['mscontent']['config'][0]['phishing_bad']=base64_encode(file_get_contents($mailscanner_dir.'/phishing.bad.sites.conf.sample'));
+ $load_samples++;
+ }
+ if($content['country_domains'] == ""){
+ $config['installedpackages']['mscontent']['config'][0]['country_domains']=base64_encode(file_get_contents($mailscanner_dir.'/country.domains.conf.sample'));
+ $load_samples++;
+ }
+ if($antispam['sa_pref_file'] == ""){
+ $config['installedpackages']['msantispam']['config'][0]['sa_pref_file']=base64_encode(file_get_contents($mailscanner_dir.'/spam.assassin.prefs.conf.sample'));
+ $load_samples++;
+ }
+ if($antispam['rbl_file'] == ""){
+ $config['installedpackages']['msantispam']['config'][0]['rbl_file']=base64_encode(file_get_contents($mailscanner_dir.'/spam.lists.conf.sample'));
+ $load_samples++;
+ }
+ if($antispam['mcp_pref_file'] == ""){
+ $config['installedpackages']['msantispam']['config'][0]['mcp_pref_file']=base64_encode(file_get_contents($mailscanner_dir.'/mcp/mcp.spam.assassin.prefs.conf.sample'));
+ copy($mailscanner_dir.'/mcp/10_example.cf.sample',$mailscanner_dir.'/mcp/10_example.cf');
+ copy($mailscanner_dir.'/mcp/v320.pre.sample',$mailscanner_dir.'/mcp/v320.pre');
+ $load_samples++;
+ }
+ if($antispam['bounce'] == ""){
+ $config['installedpackages']['msantispam']['config'][0]['bounce']=base64_encode(file_get_contents($mailscanner_dir.'/rules/bounce.rules.sample'));
+ $load_samples++;
+ }
+ if($antispam['spam_whitelist'] == ""){
+ $config['installedpackages']['msantispam']['config'][0]['spam_whitelist']=base64_encode(file_get_contents($mailscanner_dir.'/rules/spam.whitelist.rules.sample'));
+ $load_samples++;
+ }
+ if($antispam['max_message_size'] == ""){
+ $config['installedpackages']['msantispam']['config'][0]['max_message_size']=base64_encode(file_get_contents($mailscanner_dir.'/rules/max.message.size.rules.sample'));
+ $load_samples++;
+ }
+
+ $report_dir="/usr/local/share/MailScanner/reports/".strtolower($report['language']);
+ #CHECK REPORT FILES
+ $report_files= array('deletedbadcontent' => 'deleted.content.message.txt',
+ 'deletedbadfilename' => 'deleted.filename.message.txt',
+ 'deletedvirus' =>'deleted.virus.message.txt',
+ 'deletedsize' => 'deleted.size.message.txt',
+ 'storedbadcontent' => 'stored.content.message.txt',
+ 'storedbadfilename' => 'stored.filename.message.txt',
+ 'storedvirus' => 'stored.virus.message.txt',
+ 'storedsize' => 'stored.size.message.txt',
+ 'disinfected' => 'disinfected.report.txt',
+ 'sendercontent' => 'sender.content.report.txt',
+ 'sendererror' => 'sender.error.report.txt',
+ 'senderbadfilename' => 'sender.filename.report.txt',
+ 'sendervirus' => 'sender.virus.report.txt',
+ 'sendersize' => 'sender.size.report.txt',
+ 'senderrbl' => 'sender.spam.rbl.report.txt',
+ 'sendersa' => 'sender.spam.sa.report.txt',
+ 'sendermcp' => 'sender.mcp.report.txt',
+ 'senderspam'=>'sender.spam.report.txt',
+ 'recipientmcp'=>'recipient.mcp.report.txt',
+ 'recipientspam'=>'recipient.spam.report.txt',
+ 'rejection' =>'rejection.report.txt');
+
+ foreach ($report_files as $key_r => $file_r){
+ if ($report[$key_r] == ""){
+ #$input_errors[]= $key;
+ $config['installedpackages']['msreport']['config'][0][$key_r]=base64_encode(file_get_contents($report_dir.'/'.$file_r.'.sample'));
+ file_put_contents($report_dir.'/'.$file_r,ms_text_area_decode($config['installedpackages']['msreport']['config'][0][$key_r]),LOCK_EX);
+ $load_samples++;
+ }
+ #print $key_r ."X $file_r X". base64_encode(file_get_contents($report_dir.'/'.$file_r.'.sample')) ."<br>";
+
+ if ($alert['sig']){
+ if($alert['sig_html'] == ""){
+ $config['installedpackages']['msalerts']['config'][0]['sig_html']=base64_encode(file_get_contents($report_dir.'/inline.sig.html'));
+ $load_samples++;
+ }
+ if($alert['sig_txt'] == ""){
+ $config['installedpackages']['msalerts']['config'][0]['sig_txt']=base64_encode(file_get_contents($report_dir.'/inline.sig.txt'));
+ $load_samples++;
+ }
+ }
+
+ if ($alert['warning']){
+ if($alert['warning_html'] == ""){
+ $config['installedpackages']['msalerts']['config'][0]['warning_html']=base64_encode(file_get_contents($report_dir.'/inline.warning.html'));
+ $load_samples++;
+ }
+ if($alert['warning_txt'] == ""){
+ $config['installedpackages']['msalerts']['config'][0]['warning_txt']=base64_encode(file_get_contents($report_dir.'/inline.warning.txt'));
+ $load_samples++;
+ }
+ }
+
+
+ }
+ #exit;
+ if($load_samples > 0)
+ write_config();
+ /*
+Phishing Safe Sites File = %etc-dir%/phishing.safe.sites.conf
+Phishing Bad Sites File = %etc-dir%/phishing.bad.sites.conf
+Country Sub-Domains List = %etc-dir%/country.domains.conf
+*/
+
+ #create MailScanner.conf$deliver_silent
+ $mc=<<<EOF
+{$info}
+# Configuration directory containing this file
+%etc-dir% = /usr/local/etc/MailScanner
+
+# Set the directory containing all the reports in the required language
+%report-dir% = /usr/local/share/MailScanner/reports/{$report_language}
+
+# Rulesets directory containing your ".rules" files
+%rules-dir% = /usr/local/etc/MailScanner/rules
+
+# Configuration directory containing files related to MCP
+# (Message Content Protection)
+%mcp-dir% = /usr/local/etc/MailScanner/mcp
+
+#
+# System settings
+# ---------------
+#
+Max Children = {$max_children}
+Run As User = postfix
+Run As Group = postfix
+Queue Scan Interval = 6
+Incoming Queue Dir = /var/spool/postfix/hold
+Outgoing Queue Dir = /var/spool/postfix/incoming
+Quarantine Dir = /var/spool/MailScanner/quarantine
+PID file = /var/run/MailScanner.pid
+Restart Every = 14400
+MTA = postfix
+Sendmail = /usr/local/sbin/sendmail
+
+#
+# Incoming Work Dir Settings
+# --------------------------
+#
+Incoming Work User = postix
+Incoming Work Group = postix
+Incoming Work Permissions = 0600
+
+#
+# Quarantine and Archive Settings
+# -------------------------------
+#
+Quarantine User = postifx
+Quarantine Group = postfix
+Quarantine Permissions = 0600
+
+#
+# Processing Incoming Mail
+# ------------------------
+#
+Max Unscanned Bytes Per Scan = 100m
+Max Unsafe Bytes Per Scan = 50m
+Max Unscanned Messages Per Scan = 30
+Max Unsafe Messages Per Scan = 30
+Max Normal Queue Size = 800
+Scan Messages = {$scan_messages}
+Reject Message = {$reject_message}
+Maximum Processing Attempts = 6
+Processing Attempts Database = /var/spool/MailScanner/incoming/Processing.db
+Maximum Attachments Per Message = 200
+Expand TNEF = {$expand_tnef}
+Deliver Unparsable TNEF = {$deliver_tnef}
+Use TNEF Contents = {$attachments['tnef_contents']}
+TNEF Expander = /usr/local/bin/tnef --maxsize=100000000
+TNEF Timeout = 120
+File Command = /usr/bin/file
+File Timeout = 20
+Gunzip Command = /usr/bin/gunzip
+Gunzip Timeout = 50
+Unrar Command = /usr/local/bin/unrar
+Unrar Timeout = 50
+Find UU-Encoded Files = no
+Maximum Message Size = %rules-dir%/max.message.size.rules
+Maximum Attachment Size ={$max_size}
+Minimum Attachment Size = -1
+Maximum Archive Depth = {$archive_depth}
+Find Archives By Content ={$find_archive}
+Unpack Microsoft Documents = {$microsoft}
+Zip Attachments = {$zip_attachments}
+Attachments Zip Filename = {$zip_file}
+Attachments Min Total Size To Zip = 100k
+Attachment Extensions Not To Zip = {$zip_exclude}
+Add Text Of Doc = no
+Antiword = /usr/bin/antiword -f
+Antiword Timeout = 50
+Unzip Maximum Files Per Archive = {$unzip_max_per_archive}
+Unzip Maximum File Size = {$unzip_max}
+Unzip Filenames = *.txt *.ini *.log *.csv
+Unzip MimeType = text/plain
+
+#
+# Virus Scanning and Vulnerability Testing
+# ----------------------------------------
+#
+Virus Scanning = {$virus_scanning}
+Virus Scanners = {$antivirus['virus_scanner']}
+Virus Scanner Timeout = {$antivirus_timeout}
+Deliver Disinfected Files = {$deliver_disinfected}
+Silent Viruses = {$silent_viruses}
+Still Deliver Silent Viruses = {$deliver_silent}
+Non-Forging Viruses = Joke/ OF97/ WM97/ W97M/ eicar
+Spam-Virus Header = {$spam_virus_header}
+Virus Names Which Are Spam = Sane*UNOFFICIAL HTML/* *Phish*
+Block Encrypted Messages = {$block_encrypted}
+Block Unencrypted Messages = {$block_unencrypted}
+Allow Password-Protected Archives = {$allow_password}
+Check Filenames In Password-Protected Archives = {$check_filenames}
+{$custom_antivirus_options}
+
+#
+# Removing/Logging dangerous or potentially offensive content
+# -----------------------------------------------------------
+#
+Dangerous Content Scanning = {$dangerous_content}
+Allow Partial Messages = {$partial_messages}
+Allow External Message Bodies = {$external_bodies}
+Find Phishing Fraud = {$phishing_fraud}
+Also Find Numeric Phishing = {$numeric_phishig}
+Use Stricter Phishing Net = ${stricter_phishing_net}
+Highlight Phishing Fraud = ${highlight_phishing}
+Phishing Safe Sites File = %etc-dir%/phishing.safe.sites.conf
+Phishing Bad Sites File = %etc-dir%/phishing.bad.sites.conf
+Country Sub-Domains List = %etc-dir%/country.domains.conf
+Allow IFrame Tags = {$content['iframe_tags']}
+Allow Form Tags = {$content['form_tags']}
+Allow Script Tags = {$content['script_tags']}
+Allow WebBugs = {$content['web_bugs']}
+Ignored Web Bug Filenames = spacer pixel.gif pixel.png gap shim
+Known Web Bug Servers = msgtag.com
+Web Bug Replacement = http://www.mailscanner.tv/1x1spacer.gif
+Allow Object Codebase Tags = {$content['codebase_tags']}
+Convert Dangerous HTML To Text = {$dangerous_html}
+Convert HTML To Text = {$html_to_text}
+
+#
+# Attachment Filename Checking
+# ----------------------------
+#
+Archives Are = zip rar ole
+Allow Filenames =
+Deny Filenames =
+Filename Rules = %etc-dir%/filename.rules.conf
+Allow Filetypes =
+Allow File MIME Types =
+Deny Filetypes =
+Deny File MIME Types =
+Filetype Rules = %etc-dir%/filetype.rules.conf
+Archives: Allow Filenames =
+Archives: Deny Filenames =
+Archives: Filename Rules = %etc-dir%/archives.filename.rules.conf
+Archives: Allow Filetypes =
+Archives: Allow File MIME Types =
+Archives: Deny Filetypes =
+Archives: Deny File MIME Types =
+Archives: Filetype Rules = %etc-dir%/archives.filetype.rules.conf
+
+#
+# Reports and Responses
+# ---------------------
+#
+Quarantine Infections = {$quarantine_infections}
+Quarantine Silent Viruses = {$quarantine_silent_virus}
+Quarantine Modified Body = {$quarantine_modified_body}
+Quarantine Whole Message = {$quarantine_whole_message}
+Quarantine Whole Messages As Queue Files = {$quarantine_whole_message_as_queue}
+Keep Spam And MCP Archive Clean = {$keep_spam_and_mcp}
+Language Strings = %report-dir%/languages.conf
+Rejection Report = %report-dir%/rejection.report.txt
+Deleted Bad Content Message Report = %report-dir%/deleted.content.message.txt
+Deleted Bad Filename Message Report = %report-dir%/deleted.filename.message.txt
+Deleted Virus Message Report = %report-dir%/deleted.virus.message.txt
+Deleted Size Message Report = %report-dir%/deleted.size.message.txt
+Stored Bad Content Message Report = %report-dir%/stored.content.message.txt
+Stored Bad Filename Message Report = %report-dir%/stored.filename.message.txt
+Stored Virus Message Report = %report-dir%/stored.virus.message.txt
+Stored Size Message Report = %report-dir%/stored.size.message.txt
+Disinfected Report = %report-dir%/disinfected.report.txt
+Inline HTML Signature = %report-dir%/inline.sig.html
+Inline Text Signature = %report-dir%/inline.sig.txt
+Signature Image Filename = %report-dir%/sig.jpg
+Signature Image <img> Filename = signature.jpg
+Inline HTML Warning = %report-dir%/inline.warning.html
+Inline Text Warning = %report-dir%/inline.warning.txt
+Sender Content Report = %report-dir%/sender.content.report.txt
+Sender Error Report = %report-dir%/sender.error.report.txt
+Sender Bad Filename Report = %report-dir%/sender.filename.report.txt
+Sender Virus Report = %report-dir%/sender.virus.report.txt
+Sender Size Report = %report-dir%/sender.size.report.txt
+Hide Incoming Work Dir = {$hide_incoming_work_dir}
+Include Scanner Name In Reports = {$include_scanner_name}
+#
+# Changes to Message Headers
+# --------------------------
+#
+Mail Header = X-%org-name%-MailScanner:
+Spam Header = X-%org-name%-MailScanner-SpamCheck:
+Spam Score Header = X-%org-name%-MailScanner-SpamScore:
+Information Header = X-%org-name%-MailScanner-Information:
+Add Envelope From Header = yes
+Add Envelope To Header = no
+Envelope From Header = X-%org-name%-MailScanner-From:
+Envelope To Header = X-%org-name%-MailScanner-To:
+ID Header = X-%org-name%-MailScanner-ID:
+IP Protocol Version Header = # X-%org-name%-MailScanner-IP-Protocol:
+Spam Score Character = s
+SpamScore Number Instead Of Stars = no
+Minimum Stars If On Spam List = 0
+Clean Header Value = Found to be clean
+Infected Header Value = Found to be infected
+Disinfected Header Value = Disinfected
+Information Header Value = Please contact the ISP for more information
+Detailed Spam Report = yes
+Include Scores In SpamAssassin Report = yes
+Always Include SpamAssassin Report = no
+Multiple Headers = append
+Place New Headers At Top Of Message = no
+Hostname = the %org-name% ($HOSTNAME) MailScanner
+Sign Messages Already Processed = no
+Sign Clean Messages = yes
+Attach Image To Signature = no
+Attach Image To HTML Message Only = yes
+Allow Multiple HTML Signatures = no
+Dont Sign HTML If Headers Exist = # In-Reply-To: References:
+Mark Infected Messages = yes
+Mark Unscanned Messages = yes
+Unscanned Header Value = Not scanned: please contact your Internet E-Mail Service Provider for details
+Remove These Headers = X-Mozilla-Status: X-Mozilla-Status2:
+Deliver Cleaned Messages = yes
+
+#
+# Notifications back to the senders of blocked messages
+# -----------------------------------------------------
+#
+Notify Senders = {$notify_sender}
+Notify Senders Of Viruses = {$notify_sender_viruses}
+Notify Senders Of Blocked Filenames Or Filetypes = {$notify_sender_fileytypes}
+Notify Senders Of Blocked Size Attachments = {$notify_sender_attachments}
+Notify Senders Of Other Blocked Content = {$notify_sender_contents}
+Never Notify Senders Of Precedence = list bulk
+
+#
+# Changes to the Subject: line
+# ----------------------------
+#
+Scanned Modify Subject = no # end
+Scanned Subject Text = [Scanned]
+Virus Modify Subject = start
+Virus Subject Text = [Virus?]
+Filename Modify Subject = start
+Filename Subject Text = [Filename?]
+Content Modify Subject = start
+Size Modify Subject = start
+Size Subject Text = [Size]
+Disarmed Modify Subject = start
+Disarmed Subject Text = [Disarmed]
+Phishing Modify Subject = no
+Phishing Subject Text = [Fraude?]
+Spam Modify Subject = start
+Spam Subject Text = [Spam?]
+High Scoring Spam Modify Subject = start
+High Scoring Spam Subject Text = [Spam?]
+
+#
+# Changes to the Message Body
+# ---------------------------
+#
+Warning Is Attachment = yes
+Attachment Warning Filename = %org-name%-Attachment-Warning.txt
+Attachment Encoding Charset = ISO-8859-1
+
+#
+# Mail Archiving and Monitoring
+# -----------------------------
+#
+Archive Mail =
+Missing Mail Archive Is = directory
+
+#
+# Notices to System Administrators
+# --------------------------------
+#
+Send Notices = {$send_notices}
+Notices Include Full Headers = {$notices_include_header}
+Hide Incoming Work Dir in Notices = {$hide_incoming_work_dir_notices}
+Notice Signature = {$notice_signature}
+Notices From = ${$notice_from}
+Notices To = ${$notice_to}
+Local Postmaster = postmaster
+
+#
+# Spam Detection and Virus Scanner Definitions
+# --------------------------------------------
+#
+Spam List Definitions = %etc-dir%/spam.lists.conf
+Virus Scanner Definitions = %etc-dir%/virus.scanners.conf
+
+#
+# Spam Detection and Spam Lists (DNS blocklists)
+# ----------------------------------------------
+#
+
+Spam Checks = yes
+Spam List = # spamhaus-ZEN # You can un-comment this to enable them
+Spam Domain List =
+Spam Lists To Be Spam = 1
+Spam Lists To Reach High Score = 3
+Spam List Timeout = 10
+Max Spam List Timeouts = 7
+Spam List Timeouts History = 10
+Is Definitely Not Spam = %rules-dir%/spam.whitelist.rules
+Is Definitely Spam = no
+Definite Spam Is High Scoring = no
+Ignore Spam Whitelist If Recipients Exceed = 20
+Max Spam Check Size = 200k
+
+#
+# Watermarking
+# ------------
+#
+Use Watermarking = no
+Add Watermark = yes
+Check Watermarks With No Sender = yes
+Treat Invalid Watermarks With No Sender as Spam = nothing
+Check Watermarks To Skip Spam Checks = yes
+Watermark Secret = %org-name%-Secret
+Watermark Lifetime = 604800
+Watermark Header = X-%org-name%-MailScanner-Watermark:
+
+#
+# SpamAssassin
+# ------------
+#
+
+Use SpamAssassin = {$use_sa}
+Max SpamAssassin Size = {$sa_max}
+Required SpamAssassin Score = {$sa_score}
+High SpamAssassin Score = {$hi_score}
+SpamAssassin Auto Whitelist = {$sa_auto_whitelist}
+SpamAssassin Timeout = 75
+Max SpamAssassin Timeouts = 10
+SpamAssassin Timeouts History = 30
+Check SpamAssassin If On Spam List = {$check_sa_if_on_spam_list}
+Include Binary Attachments In SpamAssassin = {$include_sa_bin_attachments}
+Spam Score = {$spam_score}
+Cache SpamAssassin Results = {$cache_spamassassin_results}
+SpamAssassin Cache Database File = /var/spool/MailScanner/incoming/SpamAssassin.cache.db
+Rebuild Bayes Every = {$rebuild_bayes}
+Wait During Bayes Rebuild = {$wait_during_bayes_rebuild}
+
+#
+# Custom Spam Scanner Plugin
+# --------------------------
+#
+Use Custom Spam Scanner = no
+Max Custom Spam Scanner Size = 20k
+Custom Spam Scanner Timeout = 20
+Max Custom Spam Scanner Timeouts = 10
+Custom Spam Scanner Timeout History = 20
+
+#
+# What to do with spam
+# --------------------
+#
+
+Spam Actions = {$spam_actions} header "X-Spam-Status: Yes"
+High Scoring Spam Actions = {$hispam_actions} header "X-Spam-Status: Yes"
+Non Spam Actions = deliver header "X-Spam-Status: No"
+SpamAssassin Rule Actions =
+Sender Spam Report = %report-dir%/sender.spam.report.txt
+Sender Spam List Report = %report-dir%/sender.spam.rbl.report.txt
+Sender SpamAssassin Report = %report-dir%/sender.spam.sa.report.txt
+Inline Spam Warning = %report-dir%/inline.spam.warning.txt
+Recipient Spam Report = %report-dir%/recipient.spam.report.txt
+Enable Spam Bounce = %rules-dir%/bounce.rules
+
+#
+# Logging
+# -------
+#
+Syslog Facility = {$syslog_facility}
+Log Speed = {$log_speed}
+Log Spam = {$log_spam}
+Log Non Spam = {$log_non_spam}
+Log Delivery And Non-Delivery = {$log_delivery}
+Log Permitted Filenames = {$log_filenames}
+Log Permitted Filetypes = {$log_filetypes}
+Log Permitted File MIME Types = {$log_mime}
+Log Silent Viruses = {$log_silent}
+Log Dangerous HTML Tags = {$log_dangerous}
+Log SpamAssassin Rule Actions = {$log_sa_rule_action}
+
+#
+# Advanced SpamAssassin Settings
+# ------------------------------
+#
+SpamAssassin Temporary Dir = /var/spool/MailScanner/incoming/SpamAssassin-Temp
+SpamAssassin User State Dir =
+SpamAssassin Install Prefix =
+SpamAssassin Site Rules Dir = /usr/local/etc/mail/spamassassin
+SpamAssassin Local Rules Dir =
+SpamAssassin Local State Dir = # /var/lib/spamassassin
+SpamAssassin Default Rules Dir =
+
+#
+# MCP (Message Content Protection)
+# -----------------------------
+#
+
+MCP Checks = {$mcp_checks}
+First Check = spam
+MCP Required SpamAssassin Score = {$mcp_score}
+MCP High SpamAssassin Score = {$hi_mcp_score}
+MCP Error Score = 1
+MCP Header = X-%org-name%-MailScanner-MCPCheck:
+Non MCP Actions = deliver
+MCP Actions = {$mcp_action}
+High Scoring MCP Actions = {$mcp_hi_action}
+Bounce MCP As Attachment = {$bounce_mcp}
+MCP Modify Subject = start
+MCP Subject Text = [MCP?]
+High Scoring MCP Modify Subject = start
+High Scoring MCP Subject Text = [MCP?]
+
+Is Definitely MCP = {$is_mcp}
+Is Definitely Not MCP = {$is_not_mcp}
+Definite MCP Is High Scoring = {$mcp_is_high_score}
+Always Include MCP Report = {$include_mcp_report}
+Detailed MCP Report = {$detailled_mcp_report}
+Include Scores In MCP Report = {$score_mcp_report}
+Log MCP = {$log_mcp}
+
+MCP Max SpamAssassin Timeouts = 20
+MCP Max SpamAssassin Size = {$mcp_max}
+MCP SpamAssassin Timeout = 10
+
+MCP SpamAssassin Prefs File = %mcp-dir%/mcp.spam.assassin.prefs.conf
+MCP SpamAssassin User State Dir =
+MCP SpamAssassin Local Rules Dir = %mcp-dir%
+MCP SpamAssassin Default Rules Dir = %mcp-dir%
+MCP SpamAssassin Install Prefix = %mcp-dir%
+Recipient MCP Report = %report-dir%/recipient.mcp.report.txt
+Sender MCP Report = %report-dir%/sender.mcp.report.txt
+
+#
+# Advanced Settings
+# -----------------
+#
+Use Default Rules With Multiple Recipients = {$default_rule_multiple}
+Read IP Address From Received Header = {$read_ipaddress}
+Spam Score Number Format = {$spam_score_format}
+MailScanner Version Number = 4.79.11
+SpamAssassin Cache Timings = {$cache_timings}
+Debug = {$debug}
+Debug SpamAssassin = {$debug_spam}
+Run In Foreground = {$foreground}
+Always Looked Up Last = {$look_up_last}
+Always Looked Up Last After Batch = {$look_up_last_batch}
+Deliver In Background = {$deliver_background}
+Delivery Method = {$mailscanner['deliver_method']}
+Split Exim Spool = {$split_exim_spool}
+Lockfile Dir = /var/spool/MailScanner/incoming/Locks
+Custom Functions Dir = /usr/local/lib/MailScanner/MailScanner/CustomFunctions
+Lock Type =
+Syslog Socket Type =
+Automatic Syntax Check = {$syntax_check}
+Minimum Code Status = {$mailscanner['minimum_code']}
+include /usr/local/etc/MailScanner/conf.d/*
+
+
+
+EOF;
+ #write files
+ conf_mount_rw();
+ $mlang=strtolower($report['language']);
+ $mfiles[]="/usr/local/etc/MailScanner/virus.scanners.conf";
+ $mfiles[]="/usr/local/share/MailScanner/reports/{$mlang}/inline.spam.warning.txt";
+ $mfiles[]="/usr/local/share/MailScanner/reports/{$mlang}/languages.conf";
+
+ foreach ($mfiles as $mfile)
+ if (! file_exists ($mfile))
+ copy($mfile.".sample",$mfile);
+ if (!is_dir("/var/spool/MailScanner/incoming")){
+ mkdir("/var/spool/MailScanner/incoming", 0755,true);
+ chown ('/var/spool/MailScanner/incoming','postfix');
+ }
+ if (!is_dir("/var/spool/MailScanner/quarantine")){
+ mkdir("/var/spool/MailScanner/quarantine", 0755,true);
+ chown ('/var/spool/MailScanner/quarantine','postfix');
+ }
+ chown ('/var/spool/postfix','postfix');
+
+ file_put_contents($mailscanner_dir."/MailScanner.conf", $mc, LOCK_EX);
+ file_put_contents($mailscanner_dir."/filename.rules.conf",ms_text_area_decode($config['installedpackages']['msattachments']['config'][0]['filename_rules']),LOCK_EX);
+ file_put_contents($mailscanner_dir."/filetype.rules.conf",ms_text_area_decode($config['installedpackages']['msattachments']['config'][0]['filetype_rules']),LOCK_EX);
+ file_put_contents($mailscanner_dir."/archives.filename.rules.conf",ms_text_area_decode($config['installedpackages']['msattachments']['config'][0]['filename_rules']),LOCK_EX);
+ file_put_contents($mailscanner_dir."/archives.filetype.rules.conf",ms_text_area_decode($config['installedpackages']['msattachments']['config'][0]['filetype_rules']),LOCK_EX);
+ file_put_contents($mailscanner_dir."/phishing.safe.sites.conf",ms_text_area_decode($config['installedpackages']['mscontent']['config'][0]['phishing_safe']),LOCK_EX);
+ file_put_contents($mailscanner_dir."/phishing.bad.sites.conf",ms_text_area_decode($config['installedpackages']['mscontent']['config'][0]['phishing_bad']),LOCK_EX);
+ file_put_contents($mailscanner_dir."/country.domains.conf",ms_text_area_decode($config['installedpackages']['mscontent']['config'][0]['country_domains']),LOCK_EX);
+ file_put_contents($mailscanner_dir.'/spam.assassin.prefs.conf',ms_text_area_decode($config['installedpackages']['msantispam']['config'][0]['sa_pref_file']),LOCK_EX);
+ file_put_contents($mailscanner_dir.'/spam.lists.conf',ms_text_area_decode($config['installedpackages']['msantispam']['config'][0]['rbl_file']),LOCK_EX);
+ file_put_contents($mailscanner_dir.'/mcp/mcp.spam.assassin.prefs.conf',ms_text_area_decode($config['installedpackages']['msantispam']['config'][0]['mcp_pref_file']),LOCK_EX);
+ file_put_contents($mailscanner_dir.'/rules/bounce.rules',ms_text_area_decode($config['installedpackages']['msantispam']['config'][0]['bounce']),LOCK_EX);
+ file_put_contents($mailscanner_dir.'/rules/max.message.size.rules',ms_text_area_decode($config['installedpackages']['msantispam']['config'][0]['max_message_size']),LOCK_EX);
+ file_put_contents($mailscanner_dir.'/rules/spam.whitelist.rules',ms_text_area_decode($config['installedpackages']['msantispam']['config'][0]['spam_whitelist']),LOCK_EX);
+
+ foreach ($report_files as $key_r => $file_r)
+ file_put_contents($report_dir.'/'.$file_r,ms_text_area_decode($config['installedpackages']['msreport']['config'][0][$key_r]),LOCK_EX);
+
+ if ($alert['sig']){
+ $sig_html=ms_text_area_decode($config['installedpackages']['msalerts']['config'][0]['sig_html']);
+ $sig_txt=ms_text_area_decode($config['installedpackages']['msalerts']['config'][0]['sig_txt']);}
+ else{
+ $sig_html="";
+ $sig_txt="";}
+ file_put_contents($report_dir.'/inline.sig.txt',$sig_txt,LOCK_EX);
+ file_put_contents($report_dir.'/inline.sig.html',$sig_html,LOCK_EX);
+
+ if ($alert['warning']){
+ $warning_html=ms_text_area_decode($config['installedpackages']['msalerts']['config'][0]['warning_html']);
+ $warning_txt=ms_text_area_decode($config['installedpackages']['msalerts']['config'][0]['warning_txt']);}
+ else{
+ $warning_html="";
+ $warning_txt="";}
+ file_put_contents($report_dir.'/inline.warning.txt',$warning_txt,LOCK_EX);
+ file_put_contents($report_dir.'/inline.warning.html',$warning_html,LOCK_EX);
+
+ #check virus_scanner options
+ $libexec_dir="/usr/local/libexec/MailScanner/";
+ if ($virus_scanning == "yes"){
+ if ($antivirus['virus_scanner'] =="none"){
+ unlink_if_exists($libexec_dir.'clamav-autoupdate');
+ unlink_if_exists($libexec_dir.'clamav-wrapper');
+ }
+ else{
+ copy($libexec_dir.'clamav-autoupdate.sample',$libexec_dir.'clamav-autoupdate');
+ chmod ($libexec_dir.'clamav-autoupdate',0755);
+ copy($libexec_dir.'clamav-wrapper.sample',$libexec_dir.'clamav-wrapper');
+ chmod ($libexec_dir.'clamav-autoupdate',0755);
+ if (!file_exists('/var/db/clamav/main.cvd')){
+ log_error('No clamav database found, running freshclam in background.');
+ mwexec_bg('/usr/local/bin/freshclam');
+ }
+ }
+ }
+ else{
+ unlink_if_exists($libexec_dir.'clamav-autoupdate');
+ unlink_if_exists($libexec_dir.'clamav-wrapper');
+ }
+
+ $script='/usr/local/etc/rc.d/mailscanner';
+ $script_file=file_get_contents($script);
+ if (preg_match('/NO/',$script_file)){
+ $script_file=preg_replace("/NO/","YES",$script_file);
+ file_put_contents($script, $script_file, LOCK_EX);
+ }
+ if($config['installedpackages']['mailscanner']['config'][0]['enable']){
+ log_error("Reload mailscanner");
+ chmod ($script,0755);
+ mwexec_bg("$script fastrestart");
+ }
+ else{
+ log_error("Stopping mailscanner if running");
+ mwexec("$script stop");
+ chmod ($script,0444);
+ }
+ conf_mount_ro();
+
+}
+
+function mailscanner_validate_input($post, &$input_errors) {
+ foreach ($post as $key => $value) {
+ if (empty($value))
+ continue;
+ if (substr($key, 0, 6) == "domain" && is_numeric(substr($key, 6))) {
+ if (!is_domain($value))
+ $input_errors[] = "{$value} is not a valid domain name.";
+ } else if (substr($key, 0, 12) == "mailserverip" && is_numeric(substr($key, 12))) {
+ if (empty($post['domain' . substr($key, 12)]))
+ $input_errors[] = "Domain for {$value} cannot be blank.";
+ if (!is_ipaddr($value) && !is_hostname($value))
+ $input_errors[] = "{$value} is not a valid IP address or host name.";
+ }
+ }
+}
+
+function mailscanner_php_install_command() {
+ sync_package_mailscanner();
+}
+
+function mailscanner_php_deinstall_command() {
+ mwexec("/usr/local/etc/rc.d/mailscanner.sh stop");
+ sleep(1);
+ conf_mount_rw();
+ unlink_if_exists("/usr/local/etc/rc.d/mailscanner.sh");
+ conf_mount_ro();
+}
+
+?> \ No newline at end of file
diff --git a/config/mailscanner/mailscanner.xml b/config/mailscanner/mailscanner.xml
new file mode 100644
index 00000000..71bb06f3
--- /dev/null
+++ b/config/mailscanner/mailscanner.xml
@@ -0,0 +1,346 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ mailscanner.xml
+ part of the mailscaner package for pfSense
+ Copyright (C) 2011 Marcello Coutinho
+ 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.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>mailscanner</name>
+ <version>1.1</version>
+ <title>Services: MailScanner</title>
+ <include_file>/usr/local/pkg/mailscanner.inc</include_file>
+ <menu>
+ <name>Mailscanner</name>
+ <tooltiptext>Configure MailScanner service</tooltiptext>
+ <section>Services</section>
+ <url>pkg_edit.php?xml=mailscanner.xml&amp;id=0</url>
+ </menu>
+ <service>
+ <name>mailscanner</name>
+ <rcfile>mailscanner</rcfile>
+ <executable>MailScanner</executable>
+ <description>MailScanner</description>
+ </service>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/mailscanner/mailscanner.inc</item>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/mailscanner/mailscanner.xml</item>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/mailscanner/mailscanner_report.xml</item>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/mailscanner/mailscanner_antispam.xml</item>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/mailscanner/mailscanner_alerts.xml</item>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/mailscanner/mailscanner_antivirus.xml</item>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/mailscanner/mailscanner_attachments.xml</item>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/mailscanner/mailscanner_content.xml</item>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/mailscanner/mailscanner_sync.xml</item>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/mailscanner/mailscanner_about.php</item>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
+
+<tabs>
+ <tab>
+ <text>General</text>
+ <url>/pkg_edit.php?xml=mailscanner.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Attachments</text>
+ <url>/pkg_edit.php?xml=mailscanner_attachments.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Antivirus</text>
+ <url>/pkg_edit.php?xml=mailscanner_antivirus.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Content</text>
+ <url>/pkg_edit.php?xml=mailscanner_content.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>AntiSpam</text>
+ <url>/pkg_edit.php?xml=mailscanner_antispam.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Alerts</text>
+ <url>/pkg_edit.php?xml=mailscanner_alerts.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Reporting</text>
+ <url>/pkg_edit.php?xml=mailscanner_report.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=mailscanner_sync.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>About</text>
+ <url>/mailscanner_about.php</url>
+ </tab>
+</tabs>
+
+ <fields>
+ <field>
+ <name>System Settings</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Enable Mailscanner</fielddescr>
+ <fieldname>enable</fieldname>
+ <description>Enable mailscanner daemon.</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Org name</fielddescr>
+ <fieldname>orgname</fieldname>
+ <type>input</type>
+ <description><![CDATA[orgname,long org name<br>Hint: Company]]>
+ </description>
+ <size>30</size>
+ </field>
+ <field>
+ <fielddescr>Long Org name</fielddescr>
+ <fieldname>longorgname</fieldname>
+ <type>input</type>
+ <description><![CDATA[orgname,long org name<br>Hint: My company inc.]]>
+ </description>
+ <size>30</size>
+ </field>
+ <field>
+ <fielddescr>web-site</fielddescr>
+ <fieldname>website</fieldname>
+ <type>input</type>
+ <description><![CDATA[Organization web site<br>Hint: www.company.com]]>
+ </description>
+ <size>30</size>
+ </field>
+
+ <field>
+ <fielddescr>Max Children</fielddescr>
+ <fieldname>max_children</fieldname>
+ <type>input</type>
+ <description><![CDATA[How many MailScanner processes do you want to run at a time?<br>
+ If you are running on a small system with limited RAM, you should note that each child takes just over 20MB.<br>
+ As a rough guide, try 5 children per CPU. But read the notes above.]]>
+ </description>
+ <size>05</size>
+ </field>
+ <field>
+ <fielddescr>Processing Incoming email</fielddescr>
+ <fieldname>pim</fieldname>
+ <description>
+ <![CDATA[Select MailScanner Processing Incoming Email. Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Scan Messages (yes)</name><value>ScanMessages</value></option>
+ <option><name>Reject Message (no)</name><value>RejectMessage</value></option>
+ </options>
+ <size>03</size>
+ <multiple/>
+ </field>
+ <field>
+ <name>Logging</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Syslog Facility</fielddescr>
+ <fieldname>syslog_facility</fieldname>
+ <description><![CDATA[Syslog Facility info.<br>
+ <strong>Default is mail]]></description>
+ <type>input</type>
+ <size>20</size>
+ </field>
+ <field>
+ <fielddescr>Logging</fielddescr>
+ <fieldname>syslog</fieldname>
+ <description>
+ <![CDATA[Select virus scanner tests to enable. Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Log Speed (no)</name><value>LogSpeed</value></option>
+ <option><name>Log Spam (no)</name><value>LogSpam</value></option>
+ <option><name>Log Non Spam (no)</name><value>LogNonSpam</value></option>
+ <option><name>Log Delivery And Non-Delivery (no)</name><value>LogDeliveryAndNon-Delivery</value></option>
+ <option><name>Log Permitted Filenames (no)</name><value>LogPermittedFilenames</value></option>
+ <option><name>Log Permitted Filetypes (no)</name><value>LogPermittedFiletypes</value></option>
+ <option><name>Log Permitted File MIME Types (no)</name><value>LogPermittedFileMIMETypes</value></option>
+ <option><name>Log Silent Viruses (no)</name><value>LogSilentViruses</value></option>
+ <option><name>Log Dangerous HTML Tags (no)</name><value>LogDangerousHTMLTags</value></option>
+ <option><name>Log SpamAssassin Rule Actions (yes)</name><value>LogSpamAssassinRuleActions</value></option>
+ </options>
+ <size>11</size>
+ <multiple/>
+ </field>
+
+ <field>
+ <name>Advanced Settings</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Advanced features</fielddescr>
+ <fieldname>advanced</fieldname>
+ <description>
+ <![CDATA[Select mailscanner attachments tests to enable. Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Use Default Rules With Multiple Recipients (no)</name><value>UseDefaultRulesWithMultipleRecipients</value></option>
+ <option><name>Read IP Address From Received Header (no)</name><value>ReadIPAddressFromReceivedHeader</value></option>
+ <option><name>Debug (no)</name><value>DebugMailScanner</value></option>
+ <option><name>Debug SpamAssassin (no)</name><value>DebugSpamAssassin</value></option>
+ <option><name>Run In Foreground (no)</name><value>RunInForeground</value></option>
+ <option><name>Always Looked Up Last (no)</name><value>AlwaysLookedUpLast</value></option>
+ <option><name>Run In Foreground (no)</name><value>RunInForeground</value></option>
+ <option><name>Always Looked Up Last (no)</name><value>AlwaysLookedUpLast</value></option>
+ <option><name>Always Looked Up Last After Batch (no)</name><value>AlwaysLookedUpLastAfterBatch</value></option>
+ <option><name>Deliver In Background (yes)</name><value>DeliverInBackground</value></option>
+ <option><name>Split Exim Spool (no)</name><value>Split Exim Spool</value></option>
+ <option><name>Automatic Syntax Check (yes)</name><value>AutomaticSyntaxCheck</value></option>
+ </options>
+ <size>13</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>Deliver Method</fielddescr>
+ <fieldname>deliver_method</fieldname>
+ <description>
+ <![CDATA[Attempt immediate delivery of messages, or just place them in the outgoing queue for the MTA to deliver when it wants to?]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>batch (default)</name><value>batch</value></option>
+ <option><name>queue</name><value>queue</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Minimum Code Status </fielddescr>
+ <fieldname>minimum_code</fieldname>
+ <description>
+ <![CDATA[Minimum acceptable code stability status -- if we come across code that's not at least as stable as this, we barf.]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>batch (default)</name><value>batch</value></option>
+ <option><name>none - there may not even be any code</name><value>none</value></option>
+ <option><name>unsupported - code may be completely untested, a contributed dirty hack anything, really.</name><value>unsupported</value></option>
+ <option><name>alpha - code is pretty well untested. Don't assume it will work</name><value>alpha</value></option>
+ <option><name>beta - code is tested a bit. It should work.</name><value>beta</value></option>
+ <option><name>supported - code *should* be reliable</name><value>supported</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Spam Score Number Format</fielddescr>
+ <fieldname>spam_score_format</fieldname>
+ <type>input</type>
+ <description><![CDATA[When putting the value of the spam score of a message into the headers, how do you want to format it.<br>
+ If you don't know how to use sprintf() or printf() in C, please *do not modify* this value.<br>
+ A few examples for you:<br>
+ %d ==> 12<br>
+ %5.2f ==> 12.34<br>
+ %05.1f ==> 012.3<br>
+ Default %d]]>
+ </description>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>SpamAssassin Cache Timings</fielddescr>
+ <fieldname>cache_timings</fieldname>
+ <type>input</type>
+ <description><![CDATA[Do not change this unless you absolutely have to, these numbers have been carefully calculated.<br>
+ They affect the length of time that different types of message are stored in the SpamAssassin cache which can be configured earlier in this file (look for "Cache").<br>
+ The numbers are all set in seconds. They are:<br>
+ 1. Non-Spam cache lifetime = 30 minutes<br>
+ 2. Spam (low scoring) cache lifetime = 5 minutes<br>
+ 3. High-Scoring spam cache lifetime = 3 hours<br>
+ 4. Viruses cache lifetime = 2 days<br>
+ 5. How often to check the cache for expired messages = 10 minutes<br>
+ Default: = 1800,300,10800,172800,600 ]]>
+ </description>
+ <size>30</size>
+ </field>
+
+ </fields>
+ <custom_php_install_command>
+ mailscanner_php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ mailscanner_php_deinstall_command();
+ </custom_php_deinstall_command>
+ <custom_php_validation_command>
+ mailscanner_validate_input($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_mailscanner();
+ </custom_php_resync_config_command>
+</packagegui>
diff --git a/config/mailscanner/mailscanner_about.php b/config/mailscanner/mailscanner_about.php
new file mode 100755
index 00000000..db499a4d
--- /dev/null
+++ b/config/mailscanner/mailscanner_about.php
@@ -0,0 +1,98 @@
+<?php
+/*
+ mailscanner_about.php
+ part of pfSense (http://www.pfsense.com/)
+ Copyright (C) 2011 Marcello Coutinho <marcellocoutinho@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.
+*/
+
+require("guiconfig.inc");
+
+$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
+if(strstr($pfSversion, "1.2"))
+ $one_two = true;
+
+$pgtitle = "About: Mailscanner Package";
+include("head.inc");
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if($one_two): ?>
+<p class="pgtitle"><?=$pgtitle?></font></p>
+<?php endif; ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+
+<div id="mainlevel">
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+ <?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("General"), false, "/pkg_edit.php?xml=mailscanner.xml&id=0");
+ $tab_array[] = array(gettext("Attachments"), false, "/pkg_edit.php?xml=mailscanner_attachments.xml&id=0");
+ $tab_array[] = array(gettext("Antivirus"), false, "/pkg_edit.php?xml=mailscanner_antivirus.xml&id=0");
+ $tab_array[] = array(gettext("Content"), false, "/pkg_edit.php?xml=mailscanner_content.xml&id=0");
+ $tab_array[] = array(gettext("AntiSpam"), false, "/pkg_edit.php?xml=mailscanner_antispam.xml&id=0");
+ $tab_array[] = array(gettext("Alerts"), false, "/pkg_edit.php?xml=mailscanner_alerts.xml&id=0");
+ $tab_array[] = array(gettext("Reporting"), false, "/pkg_edit.php?xml=mailscanner_report.xml&id=0");
+ $tab_array[] = array(gettext("XMLRPC Sync"), false, "/pkg_edit.php?xml=mailscanner_sync.xml&id=0");
+ $tab_array[] = array(gettext("About"), true, "/mailscanner_about.php");
+ display_top_tabs($tab_array);
+?>
+ </td></tr>
+ <tr>
+
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">
+ <tr><td></td></tr>
+ <tr>
+ <td colspan="2" valign="top" class="listtopic"><?=gettext("About Mailscanner package"); ?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Credits ");?></td>
+ <td width="78%" class="vtable"><?=gettext("Package Created by <a target=_new href='http://forum.pfsense.org/index.php?action=profile;u=4710'>Marcello Coutinho</a><br><br>");?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Donatios ");?></td>
+ <td width="78%" class="vtable"><?=gettext("If you like this package, please <a target=_new href='http://www.pfsense.org/index.php?option=com_content&task=view&id=47&Itemid=77'>donate to pfSense project</a>.<br><br>
+ If you want that your donation goes to this package developer, make a note on donation forwarding it to me.<br><br>");?></td>
+ </tr>
+ </table>
+
+ </div>
+ </td>
+ </tr>
+
+
+ </table>
+ <br>
+ <div id="search_results"></div>
+</div>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/mailscanner/mailscanner_alerts.xml b/config/mailscanner/mailscanner_alerts.xml
new file mode 100644
index 00000000..5704f3ff
--- /dev/null
+++ b/config/mailscanner/mailscanner_alerts.xml
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ mailscanner_alerts.xml
+ part of the mailscaner package for pfSense
+ Copyright (C) 2011 Marcello Coutinho
+ 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.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>msalerts</name>
+ <version>1.1</version>
+ <title>Services: MailScanner</title>
+ <include_file>/usr/local/pkg/mailscanner.inc</include_file>
+<tabs>
+ <tab>
+ <text>General</text>
+ <url>/pkg_edit.php?xml=mailscanner.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Attachments</text>
+ <url>/pkg_edit.php?xml=mailscanner_attachments.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Antivirus</text>
+ <url>/pkg_edit.php?xml=mailscanner_antivirus.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Content</text>
+ <url>/pkg_edit.php?xml=mailscanner_content.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>AntiSpam</text>
+ <url>/pkg_edit.php?xml=mailscanner_antispam.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Alerts</text>
+ <url>/pkg_edit.php?xml=mailscanner_alerts.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Reporting</text>
+ <url>/pkg_edit.php?xml=mailscanner_report.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=mailscanner_sync.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>About</text>
+ <url>/mailscanner_about.php</url>
+ </tab>
+
+</tabs>
+<fields>
+ <field>
+ <name>Inline message signature</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Enable signature</fielddescr>
+ <fieldname>sig</fieldname>
+ <description>Enable inline message signature.</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Html signature</fielddescr>
+ <fieldname>sig_html</fieldname>
+ <description><![CDATA[Enter signature here.<br>Leave this field blank to load sample file when signature is enabled.]]></description>
+ <type>textarea</type>
+ <cols>75</cols>
+ <rows>4</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>TXT signature</fielddescr>
+ <fieldname>sig_txt</fieldname>
+ <description><![CDATA[Enter signature here.<br>Leave this field blank to load sample file when warning is enabled.]]></description>
+ <type>textarea</type>
+ <cols>75</cols>
+ <rows>4</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <name>Inline message warning</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Enable warning</fielddescr>
+ <fieldname>warning</fieldname>
+ <description>Enable inline message warning.</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Html warning</fielddescr>
+ <fieldname>warning_html</fieldname>
+ <description><![CDATA[Enter warning here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>75</cols>
+ <rows>4</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>TXT warning</fielddescr>
+ <fieldname>warning_txt</fieldname>
+ <description><![CDATA[Enter warning here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>75</cols>
+ <rows>4</rows>
+ <encoding>base64</encoding>
+ </field>
+</fields>
+ <custom_php_install_command>
+ mailscanner_php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ mailscanner_php_deinstall_command();
+ </custom_php_deinstall_command>
+ <custom_php_validation_command>
+ mailscanner_validate_input($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_mailscanner();
+ </custom_php_resync_config_command>
+</packagegui>
diff --git a/config/mailscanner/mailscanner_antispam.xml b/config/mailscanner/mailscanner_antispam.xml
new file mode 100644
index 00000000..5ce3f015
--- /dev/null
+++ b/config/mailscanner/mailscanner_antispam.xml
@@ -0,0 +1,401 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ mailscanner_antispam.xml
+ part of the mailscanner package for pfSense
+ Copyright (C) 2011 Marcello Coutinho
+ 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.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>msantispam</name>
+ <version>1.1</version>
+ <title>Services: MailScanner</title>
+ <include_file>/usr/local/pkg/mailscanner.inc</include_file>
+<tabs>
+ <tab>
+ <text>General</text>
+ <url>/pkg_edit.php?xml=mailscanner.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Attachments</text>
+ <url>/pkg_edit.php?xml=mailscanner_attachments.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Antivirus</text>
+ <url>/pkg_edit.php?xml=mailscanner_antivirus.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Content</text>
+ <url>/pkg_edit.php?xml=mailscanner_content.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>AntiSpam</text>
+ <url>/pkg_edit.php?xml=mailscanner_antispam.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Alerts</text>
+ <url>/pkg_edit.php?xml=mailscanner_alerts.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Reporting</text>
+ <url>/pkg_edit.php?xml=mailscanner_report.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=mailscanner_sync.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>About</text>
+ <url>/mailscanner_about.php</url>
+ </tab>
+
+
+</tabs>
+
+ <fields>
+ <field>
+ <name>RBL Checks</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Features</fielddescr>
+ <fieldname>rblfeatures</fieldname>
+ <description>
+ <![CDATA[Select RBL features to enable. Mailscanner default options are in (&nbsp;).<br>
+ <strong>Note: RBL checks are recommended in postfix postscreen daemon.<br>
+ It's not recommended to run it twice.</strong>]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Spam Checks (yes)</name><value>spam_checks</value></option>
+ <option><name>Is Definitely Spam (no)</name><value>is_definitely_spam</value></option>
+ <option><name>Definite Spam Is High Scoring (no)</name><value>is_definitely_hi_spam</value></option>
+ </options>
+ <size>04</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>Spam Lists do be spam</fielddescr>
+ <fieldname>spam_lists</fieldname>
+ <type>input</type>
+ <description><![CDATA[How many RBL lists ip must be included to be spam.Default is:<strong>1</strong>]]>
+ </description>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>Hi Spam Lists do be spam</fielddescr>
+ <fieldname>hi_spam_lists</fieldname>
+ <type>input</type>
+ <description><![CDATA[How many RBL lists ip must be included to be Hi spam.Default is <strong>3</strong>]]>
+ </description>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>Spam Lists Timeout</fielddescr>
+ <fieldname>rbl_timeout</fieldname>
+ <type>input</type>
+ <description><![CDATA[List check timeout.<strong>10</strong>]]>
+ </description>
+ <size>5</size>
+ </field>
+
+ <field>
+ <name>Spam Assassin</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Features</fielddescr>
+ <fieldname>safeatures</fieldname>
+ <description>
+ <![CDATA[Select Spamassassin features to enable. Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Use SpamAssassin (yes)</name><value>use_sa</value></option>
+ <option><name>SpamAssassin Auto Whitelist (yes)</name><value>sa_auto_whitelist</value></option>
+ <option><name>Check SpamAssassin If On Spam List (yes)</name><value>check_sa_if_on_spam_list</value></option>
+ <option><name>Include Binary Attachments In SpamAssassin (no)</name><value>include_sa_bin_attachments</value></option>
+ <option><name>Spam Score (yes)</name><value>spam_score</value></option>
+ <option><name>Cache SpamAssassin Results (yes)</name><value>cache_spamassassin_results</value></option>
+ <option><name>Wait During Bayes Rebuild (no)</name><value>wait_during_bayes_rebuild</value></option>
+ </options>
+ <size>08</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>Max SpamAssassin Size</fielddescr>
+ <fieldname>sa_max</fieldname>
+ <type>input</type>
+ <description><![CDATA[Max Spam Assassin Size. Default is <strong>40k</strong>]]>
+ </description>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>Required SpamAssassin Score</fielddescr>
+ <fieldname>sa_score</fieldname>
+ <type>input</type>
+ <description><![CDATA[If a message achieves a SpamAssassin score higher than this value, it is spam. Default is <strong>6</strong>]]>
+ </description>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>Spam Actions</fielddescr>
+ <fieldname>spam_actions</fieldname>
+ <description>
+ <![CDATA[This is a list of actions to take when a message is spam. It can be any combination. Default is <strong>Deliver</strong>]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Deliver</name><value>deliver</value></option>
+ <option><name>Delete</name><value>delete</value></option>
+ <option><name>store</name><value>store</value></option>
+ <option><name>bounce</name><value>bounce</value></option>
+ <option><name>Strip HTML</name><value>strip_html</value></option>
+ <option><name>attachment</name><value>attachment</value></option>
+ <option><name>Notify</name><value>notify</value></option>
+ </options>
+ <size>08</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>Required SpamAssassin HI Score</fielddescr>
+ <fieldname>hi_score</fieldname>
+ <type>input</type>
+ <description><![CDATA[If a message achieves a SpamAssassin score higher than this value,then the "High Scoring Spam Actions" are used.<br>
+ You may want to use this to deliver moderate scores, while deleting very high scoring messsages. Default is <strong>20</strong>]]>
+ </description>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>HI Spam Actions</fielddescr>
+ <fieldname>hispam_actions</fieldname>
+ <description>
+ <![CDATA[This is a list of actions to take when a message is spam. It can be any combination. Default is <strong>Delete</strong>]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Deliver</name><value>deliver</value></option>
+ <option><name>Delete</name><value>delete</value></option>
+ <option><name>store</name><value>store</value></option>
+ <option><name>bounce</name><value>bounce</value></option>
+ <option><name>Strip HTML</name><value>strip_html</value></option>
+ <option><name>attachment</name><value>attachment</value></option>
+ <option><name>Notify</name><value>notify</value></option>
+ </options>
+ <size>08</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>Rebuild bayes every</fielddescr>
+ <fieldname>rebuild_bayes</fieldname>
+ <type>input</type>
+ <description><![CDATA[If you are using the Bayesian statistics engine on a busy server, you may well need to force a Bayesian database rebuild and expiry at regular intervals.<br>
+ This is measures in seconds.Default is <strong>86400</strong>]]>
+ </description>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>custom SpamAssassin Options</fielddescr>
+ <fieldname>sa_custom</fieldname>
+ <description><![CDATA[These options will be include in Mailscanner.conf file.]]></description>
+ <type>textarea</type>
+ <cols>50</cols>
+ <rows>4</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <name>MCP (Message Content Protection)</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>MCP Features</fielddescr>
+ <fieldname>mcp_features</fieldname>
+ <type>select</type>
+ <options>
+ <option><name>MCP Checks (no)</name><value>mcp_checks</value></option>
+ <option><name>Bounce MCP As Attachment (no)</name><value>bounce_mcp</value></option>
+ <option><name>Is Definitely MCP (no)</name><value>is_mcp</value></option>
+ <option><name>Is Definitely NOT MCP (no)</name><value>is_not_mcp</value></option>
+ <option><name>Definite MCP Is High Scoring (no)</name><value>mcp_is_high_score</value></option>
+ <option><name>Always Include MCP Report (no)</name><value>include_mcp_report</value></option>
+ <option><name>Detailed MCP Report (yes)</name><value>detailled_mcp_report</value></option>
+ <option><name>Include Scores In MCP Report (no)</name><value>score_mcp_report</value></option>
+ <option><name>Log MCP (no)</name><value>log_mcp</value></option>
+ </options>
+ <multiple/>
+ <size>10</size>
+ <description><![CDATA[Select Spamassassin features to enable. Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ </field>
+ <field>
+ <fielddescr>MCP Required SpamAssassin Score</fielddescr>
+ <fieldname>mcp_score</fieldname>
+ <type>input</type>
+ <description><![CDATA[If a message achieves a MCP score higher than this value, it fails MCP check. Default is <strong>1</strong>]]>
+ </description>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>MCP Actions</fielddescr>
+ <fieldname>mcp_actions</fieldname>
+ <description>
+ <![CDATA[Choose actions to take when a message is fails on mcp check. Default is <strong>Deliver</strong>]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Deliver</name><value>deliver</value></option>
+ <option><name>Delete</name><value>delete</value></option>
+ <option><name>store</name><value>store</value></option>
+ <option><name>bounce</name><value>bounce</value></option>
+ <option><name>Strip HTML</name><value>strip_html</value></option>
+ <option><name>attachment</name><value>attachment</value></option>
+ <option><name>Notify</name><value>Notify</value></option>
+ </options>
+ <size>08</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>MCP Hi SpamAssassin Score</fielddescr>
+ <fieldname>mcp_hi_score</fieldname>
+ <type>input</type>
+ <description><![CDATA[If a message achieves a MCP score higher than this value, it fails MCP check as HI MCP. Default is <strong>10</strong>]]>
+ </description>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>MCP Hi Actions</fielddescr>
+ <fieldname>mcp_hi_actions</fieldname>
+ <description>
+ <![CDATA[Choose actions to take when a message is fails on Hi mcp check. Default is <strong>Delete</strong>]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Deliver</name><value>deliver</value></option>
+ <option><name>Delete</name><value>delete</value></option>
+ <option><name>store</name><value>store</value></option>
+ <option><name>bounce</name><value>bounce</value></option>
+ <option><name>Strip HTML</name><value>strip_html</value></option>
+ <option><name>attachment</name><value>attachment</value></option>
+ <option><name>Notify</name><value>Notify</value></option>
+ </options>
+ <size>08</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>MCP Max SpamAssassin Size</fielddescr>
+ <fieldname>mcp_max</fieldname>
+ <type>input</type>
+ <description><![CDATA[Max MCP Spam Assassin Size. Default is <strong>200k</strong>]]>
+ </description>
+ <size>5</size>
+ </field>
+ <field>
+ <name>Antispam Files</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>spam.assassin.prefs.conf</fielddescr>
+ <fieldname>sa_pref_file</fieldname>
+ <description><![CDATA[Edit spam.assassin.prefs.conf. Leave Blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>80</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>spam.lists.conf</fielddescr>
+ <fieldname>rbl_file</fieldname>
+ <description><![CDATA[Edit spam.lists.conf. Leave Blank to load sample file.<br>
+ <strong>Use this list only when not using postscreen RBL checks(postfix-forwareder package).</strong>]]></description>
+ <type>textarea</type>
+ <cols>80</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>bounce.rules</fielddescr>
+ <fieldname>bounce</fieldname>
+ <description><![CDATA[Edit spam.assassin.prefs.conf. Leave Blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>80</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>max.message.size.rules</fielddescr>
+ <fieldname>max_message_size</fieldname>
+ <description><![CDATA[Edit spam.assassin.prefs.conf. Leave Blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>80</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>spam.whitelist.rules</fielddescr>
+ <fieldname>spam_whitelist</fieldname>
+ <description><![CDATA[Edit spam.assassin.prefs.conf. Leave Blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>80</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+
+ <field>
+ <fielddescr>mcp.spam.assassin.prefs.conf</fielddescr>
+ <fieldname>mcp_pref_file</fieldname>
+ <description><![CDATA[Edit mcp.spam.assassin.prefs.conf. Leave Blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>80</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+
+ </fields>
+ <custom_php_install_command>
+ mailscanner_php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ mailscanner_php_deinstall_command();
+ </custom_php_deinstall_command>
+ <custom_php_validation_command>
+ mailscanner_validate_input($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_mailscanner();
+ </custom_php_resync_config_command>
+</packagegui>
diff --git a/config/mailscanner/mailscanner_antivirus.xml b/config/mailscanner/mailscanner_antivirus.xml
new file mode 100644
index 00000000..7d3d1d7c
--- /dev/null
+++ b/config/mailscanner/mailscanner_antivirus.xml
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ mailscanner_antivirus.xml
+ part of the mailscaner package for pfSense
+ Copyright (C) 2011 Marcello Coutinho
+ 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.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>msantivirus</name>
+ <version>1.1</version>
+ <title>Services: MailScanner</title>
+ <include_file>/usr/local/pkg/mailscanner.inc</include_file>
+<tabs>
+ <tab>
+ <text>General</text>
+ <url>/pkg_edit.php?xml=mailscanner.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Attachments</text>
+ <url>/pkg_edit.php?xml=mailscanner_attachments.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Antivirus</text>
+ <url>/pkg_edit.php?xml=mailscanner_antivirus.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Content</text>
+ <url>/pkg_edit.php?xml=mailscanner_content.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>AntiSpam</text>
+ <url>/pkg_edit.php?xml=mailscanner_antispam.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Alerts</text>
+ <url>/pkg_edit.php?xml=mailscanner_alerts.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Reporting</text>
+ <url>/pkg_edit.php?xml=mailscanner_report.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=mailscanner_sync.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>About</text>
+ <url>/mailscanner_about.php</url>
+ </tab>
+</tabs>
+ <fields>
+ <field>
+ <name>Antivirus</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Virus scanner features</fielddescr>
+ <fieldname>features</fieldname>
+ <description>
+ <![CDATA[Select virus scanner tests to enable. Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Virus Scanning (yes)</name><value>VirusScanning</value></option>
+ <option><name>Deliver Disinfected Files (no)</name><value>DeliverDisinfectedFiles</value></option>
+ <option><name>Still Deliver Silent Viruses (no)</name><value>StillDeliverSilentViruses</value></option>
+ <option><name>Block Encrypted Messages (no)</name><value>BlockEncryptedMessagese</value></option>
+ <option><name>Block Unencrypted Messages (no)</name><value>BlockUnencryptedMessages</value></option>
+ <option><name>Allow Password-Protected Archives (no)</name><value>AllowPassword-ProtectedArchive</value></option>
+ <option><name>Check Filenames In Password-Protected Archives (yes)</name><value>CheckFilenamesInPassword-ProtectedArchives</value></option>
+ </options>
+ <size>08</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>Virus scanner</fielddescr>
+ <fieldname>virus_scanner</fieldname>
+ <type>select</type>
+ <options>
+ <option><name>auto</name><value>auto</value></option>
+ <option><name>clamav</name><value>clamav</value></option>
+ <option><name>none</name><value>none</value></option>
+ </options>
+ <description><![CDATA[Do you want to scan email for viruses?]]>
+ </description>
+ </field>
+
+ <field>
+ <fielddescr>Virus Scanner Timeout</fielddescr>
+ <fieldname>timeout</fieldname>
+ <description><![CDATA[The maximum length of time the commercial virus scanner is allowed to run for 1 batch of messages (in seconds).<br>
+ <strong>Default is 300.</strong>]]></description>
+ <type>input</type>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>Silent Virus</fielddescr>
+ <fieldname>silent_virus</fieldname>
+ <description>
+ <![CDATA[Strings listed here will be searched for in the output of the virus scanners.<br>It is used to list which viruses should be handled differently from other viruses.<br>
+ Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>HTML-Iframe (yes)</name><value>HTML-Iframe</value></option>
+ <option><name>HTML-Codebase (no)</name><value>HTML-Codebase</value></option>
+ <option><name>HTML-Script (no)</name><value>HTML-Script</value></option>
+ <option><name>HTML-Form (no)</name><value>HTML-Form</value></option>
+ <option><name>Zip-Password (no)</name><value>Zip-Password</value></option>
+ <option><name>All-viruses (yes)</name><value>All-viruses</value></option>
+ </options>
+ <size>07</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>Spam-Virus Header</fielddescr>
+ <fieldname>virus_header</fieldname>
+ <description><![CDATA[Some virus scanners now use their signatures to detect spam as well as viruses. These "viruses" are called "spam-viruses".<br>
+ When they are found the following header will be added to your message before it is passed to SpamAssassin, listing all the "spam-viruses" that were found as a comma-separated list.<br>
+ <strong>Default is X-%org-name%-MailScanner-SpamVirus-Report:</strong>]]></description>
+ <type>input</type>
+ <size>30</size>
+ </field>
+ <field>
+ <fielddescr>Custom antivirus options</fielddescr>
+ <fieldname>custom</fieldname>
+ <description><![CDATA[Paste your custom mailscanner antivirus settings here.]]></description>
+ <type>textarea</type>
+ <cols>60</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ </fields>
+ <custom_php_install_command>
+ mailscanner_php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ mailscanner_php_deinstall_command();
+ </custom_php_deinstall_command>
+ <custom_php_validation_command>
+ mailscanner_validate_input($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_mailscanner();
+ </custom_php_resync_config_command>
+</packagegui>
diff --git a/config/mailscanner/mailscanner_attachments.xml b/config/mailscanner/mailscanner_attachments.xml
new file mode 100644
index 00000000..31bf98f4
--- /dev/null
+++ b/config/mailscanner/mailscanner_attachments.xml
@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ mailscanner_attachments.xml
+ part of the mailscaner package for pfSense
+ Copyright (C) 2011 Marcello Coutinho
+ 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.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>msattachments</name>
+ <version>1.1</version>
+ <title>Services: MailScanner</title>
+ <include_file>/usr/local/pkg/mailscanner.inc</include_file>
+<tabs>
+ <tab>
+ <text>General</text>
+ <url>/pkg_edit.php?xml=mailscanner.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Attachments</text>
+ <url>/pkg_edit.php?xml=mailscanner_attachments.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Antivirus</text>
+ <url>/pkg_edit.php?xml=mailscanner_antivirus.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Content</text>
+ <url>/pkg_edit.php?xml=mailscanner_content.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>AntiSpam</text>
+ <url>/pkg_edit.php?xml=mailscanner_antispam.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Alerts</text>
+ <url>/pkg_edit.php?xml=mailscanner_alerts.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Reporting</text>
+ <url>/pkg_edit.php?xml=mailscanner_report.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=mailscanner_sync.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>About</text>
+ <url>/mailscanner_about.php</url>
+ </tab>
+</tabs>
+<fields>
+ <field>
+ <name>Attachments</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Attachments features</fielddescr>
+ <fieldname>features</fieldname>
+ <description>
+ <![CDATA[Select mailscanner attachments tests to enable. Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Expand TNEF (yes)</name><value>ExpandTNEF</value></option>
+ <option><name>Deliver Unparsable TNEF (no)</name><value>DeliverUnparsableTNEF</value></option>
+ <option><name>Find Archive By Content (yes)</name><value>FindArchiveByContent</value></option>
+ <option><name>Unpack Microsoft Documents (yes)</name><value>UnpackMicrosoftDocuments</value></option>
+ <option><name>Zip Attachments (no)</name><value>ZipAttachments</value></option>
+ </options>
+ <size>06</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>TNEF Contents</fielddescr>
+ <fieldname>tnef_contents</fieldname>
+ <type>select</type>
+ <options>
+ <option><name>replace</name><value>replace</value></option>
+ <option><name>no</name><value>no</value></option>
+ <option><name>add</name><value>add</value></option>
+ </options>
+ <description><![CDATA[When the TNEF (winmail.dat) attachments are expanded, should the attachments contained in there be added to the list of attachments in the message?<br>
+ If you set this to "add" or "replace" then recipients of messages sent in "Outlook Rich Text Format" (TNEF) will be able to read the attachments if they are not using Microsoft Outlook.]]>
+ </description>
+ </field>
+ <field>
+ <fielddescr>Maximum Attachment size</fielddescr>
+ <fieldname>max_sizes</fieldname>
+ <description><![CDATA[The maximum size, in bytes, of any attachment in a message. If this is set to zero, effectively no attachments are allowed.<br>
+ If this is set less than zero, then no size checking is done.<br>
+ You might want to set this quite small for large mailing lists so they don't get deluged by large attachments.<br>
+ <strong>Default is -1.</strong>]]></description>
+ <type>input</type>
+ <size>10</size>
+ </field>
+ <field>
+ <fielddescr>Maximum Archive depth</fielddescr>
+ <fieldname>archive_depth</fieldname>
+ <description><![CDATA[The maximum depth to which zip archives, rar archives and Microsoft Office documents will be unpacked, to allow for checking filenames and filetypes
+ within zip and rar archives and embedded within Office documents.<br>
+ <strong>Default is 8.</strong>]]></description>
+ <type>input</type>
+ <size>10</size>
+ </field>
+
+ <field>
+ <fielddescr>Attachment Zip filename</fielddescr>
+ <fieldname>attachment_filename</fieldname>
+ <description><![CDATA[If the attachments are to be compressed into a single zip file,this is the filename of the zip file.<br>
+ <strong>Default is MessageAttachments.zip</strong>]]></description>
+ <type>input</type>
+ <size>20</size>
+ </field>
+ <field>
+ <fielddescr>Attachment extension exclude</fielddescr>
+ <fieldname>attachment_extension_exclude</fieldname>
+ <description><![CDATA[This is the maximum number of files in each archive. If an archive contains more files than this, we do not try to unpack it at all.<br>
+ Set this value to 0 to disable this feature.]]></description>
+ <type>input</type>
+ <size>40</size>
+ </field>
+ <field>
+ <fielddescr>Unzip Maximum files per Archive</fielddescr>
+ <fieldname>attachment_max_per_archive</fieldname>
+ <description><![CDATA[The maximum unpacked size of each file in an archive. Bigger than this, and the file will not be unpacked.<br>
+ Setting this value to 0 will disable this feature completely.<br>
+ <strong>Default is 0.</strong>]]></description>
+ <type>input</type>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>Unzip Maximum file size</fielddescr>
+ <fieldname>attachment_max</fieldname>
+ <description><![CDATA[The maximum unpacked size of each file in an archive. Bigger than this, and the file will not be unpacked.<br>
+ Setting this value to 0 will disable this feature completely.<br>
+ <strong>Default is 50k.</strong>]]></description>
+ <type>input</type>
+ <size>5</size>
+ </field>
+ <field>
+ <name>Fileset rules</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>filename.rules.conf</fielddescr>
+ <fieldname>filename_rules</fieldname>
+ <description><![CDATA[Edit archives.filename.rules.conf file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>85</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>filetypes.rules.conf</fielddescr>
+ <fieldname>filetype_rules</fieldname>
+ <description><![CDATA[Edit archives.filetype.rules.conf file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>85</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+
+ </fields>
+ <custom_php_install_command>
+ mailscanner_php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ mailscanner_php_deinstall_command();
+ </custom_php_deinstall_command>
+ <custom_php_validation_command>
+ mailscanner_validate_input($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_mailscanner();
+ </custom_php_resync_config_command>
+</packagegui>
diff --git a/config/mailscanner/mailscanner_content.xml b/config/mailscanner/mailscanner_content.xml
new file mode 100644
index 00000000..d36bf8b3
--- /dev/null
+++ b/config/mailscanner/mailscanner_content.xml
@@ -0,0 +1,228 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ mailscanner_contents.xml
+ part of the mailscaner package for pfSense
+ Copyright (C) 2011 Marcello Coutinho
+ 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.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>mscontent</name>
+ <version>1.1</version>
+ <title>Services: MailScanner</title>
+ <include_file>/usr/local/pkg/mailscanner.inc</include_file>
+<tabs>
+ <tab>
+ <text>General</text>
+ <url>/pkg_edit.php?xml=mailscanner.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Attachments</text>
+ <url>/pkg_edit.php?xml=mailscanner_attachments.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Antivirus</text>
+ <url>/pkg_edit.php?xml=mailscanner_antivirus.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Content</text>
+ <url>/pkg_edit.php?xml=mailscanner_content.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>AntiSpam</text>
+ <url>/pkg_edit.php?xml=mailscanner_antispam.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Alerts</text>
+ <url>/pkg_edit.php?xml=mailscanner_alerts.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Reporting</text>
+ <url>/pkg_edit.php?xml=mailscanner_report.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=mailscanner_sync.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>About</text>
+ <url>/mailscanner_about.php</url>
+ </tab>
+</tabs>
+ <fields>
+ <field>
+ <name>Removing/Logging dangerous or potentially offensive content</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Contents</fielddescr>
+ <fieldname>checks</fieldname>
+ <description>
+ <![CDATA[Strings listed here will be searched for in the output of the virus scanners.<br>It is used to list which viruses should be handled differently from other viruses.<br>
+ Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Dangerous Content Scanning (yes)</name><value>DangerousContentScanning</value></option>
+ <option><name>Allow Partial Messages (no)</name><value>AllowPartialMessages</value></option>
+ <option><name>Allow External Message Bodies (no)</name><value>AllowExternalMessageBodies</value></option>
+ <option><name>Find Phishing Fraud (yes)</name><value>FindPhishingFraud</value></option>
+ <option><name>Also Find Numeric Phishing (yes)</name><value>AlsoFindNumericPhishing</value></option>
+ <option><name>Use Stricter Phishing Net (yes)</name><value>UseStricterPhishingNet</value></option>
+ <option><name>Highlight Phishing Fraud (yes)</name><value>HighlightPhishingFraud</value></option>
+ <option><name>Convert Dangerous HTML To Text (no)</name><value>ConvertDangerousHTMLToText</value></option>
+ <option><name>Convert HTML To Text (no)</name><value>ConvertHTMLToText</value></option>
+
+
+ </options>
+ <size>10</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>Allow IFrame Tags</fielddescr>
+ <fieldname>iframe_tags</fieldname>
+ <type>select</type>
+ <options>
+ <option><name>disarm</name><value>disarm</value></option>
+ <option><name>yes</name><value>yes</value></option>
+ <option><name>no</name><value>no</value></option>
+ </options>
+ <description><![CDATA[Do you want to allow 'IFrame' tags in email messages?<br>
+ This is not a good idea as it allows various Microsoft Outlook security vulnerabilities to remain unprotected, but if you have a load of mailing lists sending them,
+# then you will want to allow them to keep your users happy.]]>
+ </description>
+ </field>
+ <field>
+ <fielddescr>Allow Form Tags</fielddescr>
+ <fieldname>form_tags</fieldname>
+ <type>select</type>
+ <options>
+ <option><name>disarm</name><value>disarm</value></option>
+ <option><name>yes</name><value>yes</value></option>
+ <option><name>no</name><value>no</value></option>
+ </options>
+ <description><![CDATA[Do you want to allow 'Form' tags in email messages?<br>
+ This is a bad idea as these are used as scams to pursuade people to part with credit card information and other personal data.]]>
+ </description>
+ </field>
+ <field>
+ <fielddescr>Allow Script Tags</fielddescr>
+ <fieldname>script_tags</fieldname>
+ <type>select</type>
+ <options>
+ <option><name>disarm</name><value>disarm</value></option>
+ <option><name>yes</name><value>yes</value></option>
+ <option><name>no</name><value>no</value></option>
+ </options>
+ <description><![CDATA[Do you want to allow 'Script' tags in email messages?<br>
+ This is a bad idea as these are used to exploit vulnerabilities in email applications and web browsers.]]>
+ </description>
+ </field>
+ <field>
+ <fielddescr>Allow web bugs</fielddescr>
+ <fieldname>web_bugs</fieldname>
+ <type>select</type>
+ <options>
+ <option><name>disarm</name><value>disarm</value></option>
+ <option><name>yes</name><value>yes</value></option>
+ <option><name>no</name><value>no</value></option>
+ </options>
+ <description><![CDATA[Do you want to allow 'Img' tags with very small images in email messages?<br>
+ This is a bad idea as these are used as 'web bugs' to find out if a message has been read.<br>
+ It is not dangerous, it is just used to make you give away information.]]>
+ </description>
+ </field>
+ <field>
+ <fielddescr>Allow Object Codebase Tags</fielddescr>
+ <fieldname>codebase_tags</fieldname>
+ <type>select</type>
+ <options>
+ <option><name>disarm</name><value>disarm</value></option>
+ <option><name>yes</name><value>yes</value></option>
+ <option><name>no</name><value>no</value></option>
+ </options>
+ <description><![CDATA[Do you want to allow <strong>'Object Codebase=...' or 'Object Data=...'</strong> tags in email messages?<br>
+ This is a bad idea as it leaves you unprotected against various Microsoft-specific security vulnerabilities.<br>
+ But if your users demandit, you can do it.]]>
+ </description>
+ </field>
+ <field>
+ <name>Phishing files</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>phishing.safe.sites.conf</fielddescr>
+ <fieldname>phishing_safe</fieldname>
+ <description><![CDATA[edit phishing.safe.sites.conf file here.<br>If you leave this field blank, it will load sample file.]]></description>
+ <type>textarea</type>
+ <cols>70</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>phishing.bad.sites.conf</fielddescr>
+ <fieldname>phishing_bad</fieldname>
+ <description><![CDATA[edit phishing.bad.sites.conf file here.<br>If you leave this field blank, it will load sample file.]]></description>
+ <type>textarea</type>
+ <cols>70</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>country.domains.conf</fielddescr>
+ <fieldname>country_domains</fieldname>
+ <description><![CDATA[edit country.domains.conf file here.<br>If you leave this field blank, it will load sample file.]]></description>
+ <type>textarea</type>
+ <cols>70</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ </fields>
+ <custom_php_install_command>
+ mailscanner_php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ mailscanner_php_deinstall_command();
+ </custom_php_deinstall_command>
+ <custom_php_validation_command>
+ mailscanner_validate_input($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_mailscanner();
+ </custom_php_resync_config_command>
+</packagegui>
diff --git a/config/mailscanner/mailscanner_report.xml b/config/mailscanner/mailscanner_report.xml
new file mode 100644
index 00000000..65f182fc
--- /dev/null
+++ b/config/mailscanner/mailscanner_report.xml
@@ -0,0 +1,413 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ mailscanner_report.xml
+ part of the mailscaner package for pfSense
+ Copyright (C) 2011 Marcello Coutinho
+ 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.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>>msreport</name>
+ <version>1.1</version>
+ <title>Services: MailScanner</title>
+ <include_file>/usr/local/pkg/mailscanner.inc</include_file>
+<tabs>
+ <tab>
+ <text>General</text>
+ <url>/pkg_edit.php?xml=mailscanner.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Attachments</text>
+ <url>/pkg_edit.php?xml=mailscanner_attachments.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Antivirus</text>
+ <url>/pkg_edit.php?xml=mailscanner_antivirus.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Content</text>
+ <url>/pkg_edit.php?xml=mailscanner_content.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>AntiSpam</text>
+ <url>/pkg_edit.php?xml=mailscanner_antispam.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Alerts</text>
+ <url>/pkg_edit.php?xml=mailscanner_alerts.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Reporting</text>
+ <url>/pkg_edit.php?xml=mailscanner_report.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=mailscanner_sync.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>About</text>
+ <url>/mailscanner_about.php</url>
+ </tab>
+</tabs>
+ <fields>
+ <field>
+ <name>Reports and Responses</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Reports</fielddescr>
+ <fieldname>features</fieldname>
+ <description>
+ <![CDATA[Select virus scanner tests to enable. Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Quarantine Infections (no)</name><value>QuarantineInfections</value></option>
+ <option><name>Quarantine Silent Viruses (no)</name><value>QuarantineSilentViruses</value></option>
+ <option><name>Quarantine Modified Body (no)</name><value>QuarantineModifiedBody</value></option>
+ <option><name>Quarantine Whole Message (no)</name><value>QuarantineWholeMessage</value></option>
+ <option><name>Quarantine Whole Messages As Queue Files (no)</name><value>QuarantineWholeMessagesAsQueueFiles</value></option>
+ <option><name>Keep Spam And MCP Archive Clean (no)</name><value>KeepSpamAndMCPArchiveClean</value></option>
+ <option><name>Hide Incoming Work Dir (yes)</name><value>HideIncomingWorkDir</value></option>
+ <option><name>Include Scanner Name In Reports (yes)</name><value>IncludeScannerNameInReports</value></option>
+
+ </options>
+ <size>09</size>
+ <multiple/>
+ </field>
+ <field>
+ <name>Notifications to Sender</name>
+ <type>listtopic</type>
+ </field>
+
+ <field>
+ <fielddescr>Notificatios</fielddescr>
+ <fieldname>notification</fieldname>
+ <description>
+ <![CDATA[Select virus scanner tests to enable. Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Notify Senders (no)</name><value>NotifySenders</value></option>
+ <option><name>Notify Senders of Viruses (no)</name><value>NotifySendersofVirusese</value></option>
+ <option><name>Notify Senders of Blocked Filenames or Filetypes (yes)</name><value>NotifySendersofBlockedFilenamesorFiletypes</value></option>
+ <option><name>Notify Senders of Blocked Size Attachments (no)</name><value>NotifySendersofBlockedSizeAttachments</value></option>
+ <option><name>Notify Senders of Blocked Content (yes)</name><value>NotifySendersofBlockedContent</value></option>
+ </options>
+ <size>06</size>
+ <multiple/>
+ </field>
+ <field>
+ <name>Notices to System Administrators</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>System Notificatios</fielddescr>
+ <fieldname>system</fieldname>
+ <description>
+ <![CDATA[Select what to send to System Administrators. Mailscanner default options are in (&nbsp;).]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>Send Notices (no)</name><value>SendNotices</value></option>
+ <option><name>Notices Include Full Headers (yes)</name><value>NoticesIncludeFullHeaders</value></option>
+ <option><name>Hide Incoming Work Dir in Notices (no)</name><value>HideIncomingWorkDirinNotices</value></option>
+ </options>
+ <size>04</size>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>Notice Signature</fielddescr>
+ <fieldname>notice_signature</fieldname>
+ <description><![CDATA[What signature to add to the bottom of the notices.<br>
+ To insert a line-break in there, use the sequence "\n".ssed to SpamAssassin, listing all the "spam-viruses" that were found as a comma-separated list.<br>
+ <strong>Default is -- \nMailScanner\nEmail Virus Scanner\nwww.mailscanner.info</strong>]]></description>
+ <type>input</type>
+ <size>30</size>
+ </field>
+ <field>
+ <fielddescr>Notice from</fielddescr>
+ <fieldname>notice_from</fieldname>
+ <description><![CDATA[The visible part of the email address used in the "From:" line of the notices. The <user@domain> part of the email address is set to the "Local Postmaster" setting.<br>
+ <strong>Default is MailScanner]]></description>
+ <type>input</type>
+ <size>20</size>
+ </field>
+ <field>
+ <fielddescr>Notice to</fielddescr>
+ <fieldname>notice_to</fieldname>
+ <description><![CDATA[Where to send the notices.<br>
+ <strong>Default is Postmaster]]></description>
+ <type>input</type>
+ <size>20</size>
+ </field>
+ <field>
+ <name>Message Reports</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Language</fielddescr>
+ <fieldname>language</fieldname>
+ <description>
+ <![CDATA[Select report language.]]>
+ </description>
+ <type>select</type>
+ <options>
+ <option><name>EN (Default)</name><value>en</value></option>
+ <option><name>CA</name><value>ca</value></option>
+ <option><name>CY+EN</name><value>cy+en</value></option>
+ <option><name>CZ</name><value>cz</value></option>
+ <option><name>DE</name><value>de</value></option>
+ <option><name>DK</name><value>dk</value></option>
+ <option><name>ES</name><value>es</value></option>
+ <option><name>FR</name><value>fr</value></option>
+ <option><name>HU</name><value>hu</value></option>
+ <option><name>IT</name><value>it</value></option>
+ <option><name>NL</name><value>nl</value></option>
+ <option><name>PT_BR</name><value>pt_br</value></option>
+ <option><name>RO</name><value>ro</value></option>
+ <option><name>SE</name><value>se</value></option>
+ <option><name>SK</name><value>sk</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Deleted Bad Content</fielddescr>
+ <fieldname>deletedbadcontent</fieldname>
+ <description><![CDATA[Edit deleted.content.message.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Deleted Bad Filename</fielddescr>
+ <fieldname>deletedbadfilename</fieldname>
+ <description><![CDATA[Edit deleted.filename.message.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Deleted Virus</fielddescr>
+ <fieldname>deletedvirus</fieldname>
+ <description><![CDATA[Edit deleted.virus.message.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Deleted Size</fielddescr>
+ <fieldname>deletedsize</fieldname>
+ <description><![CDATA[Edit deleted.size.message.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Stored Bad Content</fielddescr>
+ <fieldname>storedbadcontent</fieldname>
+ <description><![CDATA[Edit stored.content.message.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Stored Bad Filename</fielddescr>
+ <fieldname>storedbadfilename</fieldname>
+ <description><![CDATA[Edit stored.filename.message.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Stored Virus</fielddescr>
+ <fieldname>storedvirus</fieldname>
+ <description><![CDATA[Edit stored.virus.message.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Disinfected Report</fielddescr>
+ <fieldname>disinfected</fieldname>
+ <description><![CDATA[Edit stored.size.message.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Stored Size</fielddescr>
+ <fieldname>storedsize</fieldname>
+ <description><![CDATA[Edit disinfected.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Sender content</fielddescr>
+ <fieldname>sendercontent</fieldname>
+ <description><![CDATA[Edit sender.content.message.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Sender Error</fielddescr>
+ <fieldname>sendererror</fieldname>
+ <description><![CDATA[Edit sender.error.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Sender Bad Filename</fielddescr>
+ <fieldname>senderbadfilename</fieldname>
+ <description><![CDATA[Edit sender.filename.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Sender Virus Report</fielddescr>
+ <fieldname>sendervirus</fieldname>
+ <description><![CDATA[Edit sender.virus.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Sender Size Report</fielddescr>
+ <fieldname>sendersize</fieldname>
+ <description><![CDATA[Edit sender.size.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Sender Spam report</fielddescr>
+ <fieldname>senderspam</fieldname>
+ <description><![CDATA[Edit sender.spam.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Sender SPam RBL report</fielddescr>
+ <fieldname>senderrbl</fieldname>
+ <description><![CDATA[Edit sender.spam.rbl.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Sender Spam SA report</fielddescr>
+ <fieldname>sendersa</fieldname>
+ <description><![CDATA[Edit sender.spam.sa.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Sender Spam MCP report</fielddescr>
+ <fieldname>sendermcp</fieldname>
+ <description><![CDATA[Edit sender.mcp.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+
+ <field>
+ <fielddescr>Recipients Spam report</fielddescr>
+ <fieldname>recipientspam</fieldname>
+ <description><![CDATA[Edit recipient.spam.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Recipients MCP report</fielddescr>
+ <fieldname>recipientmcp</fieldname>
+ <description><![CDATA[Edit recipient.mcp.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Rejection Report</fielddescr>
+ <fieldname>rejection</fieldname>
+ <description><![CDATA[Edit rejection.report.txt file here.<br>Leave this field blank to load sample file.]]></description>
+ <type>textarea</type>
+ <cols>90</cols>
+ <rows>15</rows>
+ <encoding>base64</encoding>
+ </field>
+
+
+ </fields>
+ <custom_php_install_command>
+ mailscanner_php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ mailscanner_php_deinstall_command();
+ </custom_php_deinstall_command>
+ <custom_php_validation_command>
+ mailscanner_validate_input($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_mailscanner();
+ </custom_php_resync_config_command>
+</packagegui>
diff --git a/config/mailscanner/mailscanner_sync.xml b/config/mailscanner/mailscanner_sync.xml
new file mode 100644
index 00000000..8dc51e42
--- /dev/null
+++ b/config/mailscanner/mailscanner_sync.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ postfix_sync.xml
+ part of the Postfix package for pfSense
+ Copyright (C) 2011 Marcello Coutinho
+ 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.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>mailscanner_sync</name>
+ <version>1.0</version>
+ <title>Services: MailScanner</title>
+ <include_file>/usr/local/pkg/mailscanner.inc</include_file>
+<tabs>
+ <tab>
+ <text>General</text>
+ <url>/pkg_edit.php?xml=mailscanner.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Attachments</text>
+ <url>/pkg_edit.php?xml=mailscanner_attachments.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Antivirus</text>
+ <url>/pkg_edit.php?xml=mailscanner_antivirus.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Content</text>
+ <url>/pkg_edit.php?xml=mailscanner_content.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>AntiSpam</text>
+ <url>/pkg_edit.php?xml=mailscanner_antispam.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Alerts</text>
+ <url>/pkg_edit.php?xml=mailscanner_alerts.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Reporting</text>
+ <url>/pkg_edit.php?xml=mailscanner_report.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=mailscanner_sync.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>About</text>
+ <url>/mailscanner_about.php</url>
+ </tab>
+</tabs>
+ <fields>
+ <field>
+ <name>mailscanner XMLRPC Sync</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Automatically sync mailscanner configuration changes</fielddescr>
+ <fieldname>synconchanges</fieldname>
+ <description>pfSense will automatically sync changes to the hosts defined below.</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Remote Server</fielddescr>
+ <fieldname>none</fieldname>
+ <type>rowhelper</type>
+ <rowhelper>
+ <rowhelperfield>
+ <fielddescr>IP Address</fielddescr>
+ <fieldname>ipaddress</fieldname>
+ <description>IP Address of remote server</description>
+ <type>input</type>
+ <size>20</size>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>Password</fielddescr>
+ <fieldname>password</fieldname>
+ <description>Password for remote server.</description>
+ <type>password</type>
+ <size>20</size>
+ </rowhelperfield>
+ </rowhelper>
+ </field>
+ </fields>
+ <custom_php_install_command>
+ mailscanner_php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ mailscanner_php_deinstall_command();
+ </custom_php_deinstall_command>
+ <custom_php_validation_command>
+ mailscanner_validate_input($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_mailscanner();
+ </custom_php_resync_config_command>
+</packagegui>
diff --git a/config/postfix/postfix.inc b/config/postfix/postfix.inc
index d009e72a..5a802054 100644
--- a/config/postfix/postfix.inc
+++ b/config/postfix/postfix.inc
@@ -391,8 +391,10 @@ EOF;
if($antispam['antispam_enabled']){
switch ($antispam['antispam_software']){
case "mailscanner":
- $header_check .= (!preg_match('@/ HOLD@',$header_check)?"\n/^Received:/ HOLD\n":"\n");
- $postfix_main_antispam = "#Saving all mail after header/body/rbl/spf checks to mailscanner\n\n";
+ if ($antispam['hold_mode']=='auto'){
+ $header_check .= "\n/^Received:/ HOLD\n";
+ $postfix_main_antispam = "#Saving all mail after header/body/rbl/spf checks to mailscanner\n\n";
+ }
break;
case "policyd2":
if ($antispam['antispam_location']){
diff --git a/config/postfix/postfix.php b/config/postfix/postfix.php
index 842d5658..9f15973c 100644
--- a/config/postfix/postfix.php
+++ b/config/postfix/postfix.php
@@ -1,727 +1,744 @@
-<?php
-/*
- postfix.php
- part of pfSense (http://www.pfsense.com/)
- Copyright (C) 2011 Marcello Coutinho <marcellocoutinho@gmail.com>
- based on varnish_view_config.
- 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.
-*/
-require_once("/etc/inc/util.inc");
-require_once("/etc/inc/functions.inc");
-require_once("/etc/inc/pkg-utils.inc");
-require_once("/etc/inc/globals.inc");
-require_once("/usr/local/pkg/postfix.inc");
-
-function get_remote_log(){
- global $config,$g,$postfix_dir;
- $curr_time = time();
- $log_time=date('YmdHis',$curr_time);
- #get protocol
- if($config['system']['webgui']['protocol'] != "")
- $synchronizetoip = $config['system']['webgui']['protocol']. "://";
- #get port
- $port = $config['system']['webgui']['port'];
- #if port is empty lets rely on the protocol selection
- if($port == "")
- $port =($config['system']['webgui']['protocol'] == "http"?"80":"443");
- $synchronizetoip .= $sync_to_ip;
- if (is_array($config['installedpackages']['postfixsync']))
- foreach($config['installedpackages']['postfixsync']['config'][0]['row'] as $sh){
- $sync_to_ip = $sh['ipaddress'];
- $sync_type = $sh['sync_type'];
- $password = $sh['password'];
- $file= '/var/db/postfix/'.$server.'.sql';
- #get remote data
- if ($sync_type=='fetch'){
- $url= $synchronizetoip . $sync_to_ip;
- print "$sync_to_ip $url, $port\n";
- $method = 'pfsense.exec_php';
- $execcmd = "require_once('/usr/local/www/postfix.php');\n";
- $execcmd .= '$toreturn=get_sql('.$log_time.');';
- /* assemble xmlrpc payload */
- $params = array(XML_RPC_encode($password),
- XML_RPC_encode($execcmd));
- log_error("postfix get sql data from {$sync_to_ip}.");
- $msg = new XML_RPC_Message($method, $params);
- $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
- $cli->setCredentials('admin', $password);
- #$cli->setDebug(1);
- $resp = $cli->send($msg, "250");
- $a=$resp->value();
- $errors=0;
- #var_dump($sql);
- foreach($a as $b)
- foreach ($b as $c)
- foreach ($c as $d)
- foreach ($d as $e){
- $update=unserialize($e['string']);
- print $update['day']."\n";
- if ($update['day'] != ""){
- create_db($update['day'].".db");
- if ($debug=true)
- print $update['day'] ." writing from remote system to db...";
- $dbhandle = sqlite_open($postfix_dir.'/'.$update['day'].".db", 0666, $error);
- #file_put_contents("/tmp/".$key.'-'.$update['day'].".sql",gzuncompress(base64_decode($update['sql'])), LOCK_EX);
- $ok = sqlite_exec($dbhandle, gzuncompress(base64_decode($update['sql'])), $error);
- if (!$ok){
- $errors++;
- die ("Cannot execute query. $error\n".$update['sql']."\n");
- }
- else{
- if ($debug=true)
- print "ok\n";
- }
- sqlite_close($dbhandle);
- }
- }
- if ($errors ==0){
- $method = 'pfsense.exec_php';
- $execcmd = "require_once('/usr/local/www/postfix.php');\n";
- $execcmd .= 'flush_sql('.$log_time.');';
- /* assemble xmlrpc payload */
- $params = array(XML_RPC_encode($password),
- XML_RPC_encode($execcmd));
- log_error("postfix flush sql buffer file from {$sync_to_ip}.");
- $msg = new XML_RPC_Message($method, $params);
- $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
- $cli->setCredentials('admin', $password);
- #$cli->setDebug(1);
- $resp = $cli->send($msg, "250");
- }
- }
- }
-}
-function get_sql($log_time){
- global $config,$xmlrpc_g;
- $server=$_SERVER['REMOTE_ADDR'];
-
- if (is_array($config['installedpackages']['postfixsync']))
- foreach($config['installedpackages']['postfixsync']['config'][0]['row'] as $sh){
- $sync_to_ip = $sh['ipaddress'];
- $sync_type = $sh['sync_type'];
- $password = $sh['password'];
- $file= '/var/db/postfix/'.$server.'.sql';
- if ($sync_to_ip==$server && $sync_type=='share' && file_exists($file)){
- rename($file,$file.".$log_time");
- return (file($file.".$log_time"));
- }
- }
- return "";
-}
-
-function flush_sql($log_time){
- if (preg_match("/\d+\.\d+\.\d+\.\d+/",$_SERVER['REMOTE_ADDR']))
- unlink_if_exists('/var/db/postfix/'.$_SERVER['REMOTE_ADDR'].".sql.$log_time");
-}
-
-function grep_log(){
- global $postfix_dir,$postfix_arg,$config,$g;
-
- $total_lines=0;
- $days=array();
- $grep="postfix.\(cleanup\|smtp\|error\|qmgr\)";
- $curr_time = time();
- $log_time=strtotime($postfix_arg['time'],$curr_time);
- $m=date('M',strtotime($postfix_arg['time'],$curr_time));
- $j=substr(" ".date('j',strtotime($postfix_arg['time'],$curr_time)),-3);
- # file grep loop
- foreach ($postfix_arg['grep'] as $hour){
- print "/usr/bin/grep '^".$m.$j." ".$hour.".*".$grep."' /var/log/maillog\n";
- $lists=array();
- exec("/usr/bin/grep " . escapeshellarg('^'.$m.$j." ".$hour.".*".$grep)." /var/log/maillog", $lists);
- foreach ($lists as $line){
- #check where is first mail record
- if (preg_match("/ delay=(\d+)/",$line,$delay)){
- $day=date("Y-m-d",strtotime("-".$delay[1]." second",$log_time));
- if (! in_array($day,$days)){
- $days[]=$day;
- create_db($day.".db");
- print "Found logs to $day.db\n";
- $stm_queue[$day]="BEGIN;\n";
- $stm_noqueue[$day]="BEGIN;\n";
- }
- }
- else{
- $day=date("Y-m-d",strtotime($postfix_arg['time'],$curr_time));
- if (! in_array($day,$days)){
- $days[]=$day;
- create_db($day.".db");
- print "Found logs to $day.db\n";
- $stm_queue[$day]="BEGIN;\n";
- $stm_noqueue[$day]="BEGIN;\n";
- }
- }
- $status=array();
- $total_lines++;
- #Nov 8 09:31:50 srvch011 postfix/smtpd[43585]: 19C281F59C8: client=pm03-974.auinmem.br[177.70.0.3]
- if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+(\w+): client=(.*)/",$line,$email)){
- $values="'".$email[3]."','".$email[1]."','".$email[2]."','".$email[4]."'";
- if(${$email[3]}!=$email[3])
- $stm_queue[$day].='insert or ignore into mail_from(sid,date,server,client) values ('.$values.');'."\n";
- ${$email[3]}=$email[3];
- }
- #Nov 14 09:29:32 srvch011 postfix/error[58443]: 2B8EB1F5A5A: to=<hildae.sva@pi.email.com>, relay=none, delay=0.66, delays=0.63/0/0/0.02, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=mail.pi.trf1.gov.br type=A: Host not found, try again)
- #Nov 3 21:45:32 srvch011 postfix/smtp[18041]: 4CE321F4887: to=<viinil@vitive.com.br>, relay=smtpe1.eom[81.00.20.9]:25, delay=1.9, delays=0.06/0.01/0.68/1.2, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 2C33E2382C8)
- #Nov 16 00:00:14 srvch011 postfix/smtp[7363]: 7AEB91F797D: to=<alessandra.bueno@mg.trf1.gov.br>, relay=mail.mg.trf1.gov.br[172.25.3.5]:25, delay=39, delays=35/1.1/0.04/2.7, dsn=5.7.1, status=bounced (host mail.mg.trf1.gov.br[172.25.3.5] said: 550 5.7.1 Unable to relay for alessandra.bueno@mg.trf1.gov.br (in reply to RCPT TO command))
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.\w+\W\d+\W+(\w+): to=\<(.*)\>, relay=(.*), delay=([0-9,.]+), .* dsn=([0-9,.]+), status=(\w+) (.*)/",$line,$email)){
- $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[8]."');\n";
- $stm_queue[$day].= "insert or ignore into mail_to (from_id,too,status,status_info,relay,delay,dsn) values ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($email[4])."',(select id from mail_status where info='".$email[8]."'),'".preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[9])."','".$email[5]."','".$email[6]."','".$email[7]."');\n";
- $stm_queue[$day].= "update or ignore mail_to set status=(select id from mail_status where info='".$email[8]."'), status_info='".preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[9])."', dsn='".$email[7]."', delay='".$email[6]."', relay='".$email[5]."', too='".strtolower($email[4])."' where from_id in (select id from mail_from where sid='".$email[3]."' and server='".$email[2]."');\n";
- }
- #Nov 13 01:48:44 srvch011 postfix/cleanup[16914]: D995B1F570B: message-id=<61.40.11745.10E3FBE4@ofertas6>
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.cleanup\W\d+\W+(\w+): message-id=\<(.*)\>/",$line,$email)){
- $stm_queue[$day].="update mail_from set msgid='".$email[4]."' where sid='".$email[3]."';\n";
- }
- #Nov 14 02:40:05 srvch011 postfix/qmgr[46834]: BC5931F4F13: from=<ceag@mx.crmcom.br>, size=32727, nrcpt=1 (queue active)
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.qmgr\W\d+\W+(\w+): from=\<(.*)\>\W+size=(\d+)/",$line,$email)){
- $stm_queue[$day].= "update mail_from set fromm='".strtolower($email[4])."', size='".$email[5]."' where sid='".$email[3]."';\n";
- }
- #Nov 13 00:09:07 srvch011 postfix/bounce[56376]: 9145C1F67F7: sender non-delivery notification: D5BD31F6865
- #else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.bounce\W\d+\W+(\w+): sender non-delivery notification: (\w+)/",$line,$email)){
- # $stm_queue[$day].= "update mail_queue set bounce='".$email[4]."' where sid='".$email[3]."';\n";
- #}
- #Nov 14 01:41:44 srvch011 postfix/smtpd[15259]: warning: 1EF3F1F573A: queue file size limit exceeded
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+warning: (\w+): queue file size limit exceeded/",$line,$email)){
- $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[8]."');\n";
- $stm_queue[$day].= "update mail_to set status=(select id from mail_status where info='reject'), status_info='queue file size limit exceeded' where from_id in (select id from mail_from where sid='".$email[3]."' and server='".$email[2]."');\n";
- }
-
- #Nov 9 02:14:57 srvch011 postfix/cleanup[6856]: 617A51F5AC5: warning: header Subject: Mapeamento de Processos from lxalpha.12b.com.br[66.109.29.225]; from=<apache@lxalpha.12b.com.br> to=<ritiele.faria@mail.test.com> proto=ESMTP helo=<lxalpha.12b.com.br>
- #Nov 8 09:31:50 srvch011 postfix/cleanup[11471]: 19C281F59C8: reject: header From: "Giuliana Flores - Parceiro do Grupo Virtual" <publicidade@parceiro-grupovirtual.com.br> from pm03-974.auinmeio.com.br[177.70.232.225]; from=<publicidade@parceiro-grupovirtual.com.br> to=<jorge.lustosa@mail.test.com> proto=ESMTP helo=<pm03-974.auinmeio.com.br>: 5.7.1 [SN007]
- #Nov 13 00:03:24 srvch011 postfix/cleanup[4192]: 8A5B31F52D2: reject: body http://platform.roastcrack.info/mj0ie6p-48qtiyq from move2.igloojack.info[173.239.63.16]; from=<ljmd6u8lrxke4@move2.igloojack.info> to=<edileva@aasdf..br> proto=SMTP helo=<move2.igloojack.info>: 5.7.1 [BD040]
- #Nov 14 01:41:35 srvch011 postfix/cleanup[58446]: 1EF3F1F573A: warning: header Subject: =?windows-1252?Q?IMOVEL_Voc=EA_=E9_um_Cliente_especial_da_=93CENTURY21=22?=??=?windows-1252?Q?Veja_o_que_tenho_para_voc=EA?= from mail-yw0-f51.google.com[209.85.213.51]; from=<sergioalexandre6308@gmail.com> to=<sinza@tr.br> proto=ESMTP helo=<mail-yw0-f51.google.com>
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.cleanup\W\d+\W+(\w+): (\w+): (.*) from ([a-z,A-Z,0-9,.,-]+)\W([0-9,.]+)\W+from=\<(.*)\> to=\<(.*)\>.*helo=\W([a-z,A-Z,0-9,.,-]+)(.*)/",$line,$email)){
- $status['date']=$email[1];
- $status['server']=$email[2];
- $status['sid']=$email[3];
- $status['remote_hostname']=$email[6];
- $status['remote_ip']=$email[7];
- $status['from']=$email[8];
- $status['to']=$email[9];
- $status['helo']=$email[10];
- $status['status']=$email[4];
- $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[4]."');\n";
- if ($email[4] =="warning"){
- $stm_queue[$day].= "insert or ignore into mail_status (info) values ('incoming');\n";
- #print "$line\n";
- $status['status_info']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[11]);
- $status['subject']=preg_replace("/header Subject: /","",$email[5]);
- $status['subject']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$status['subject']);
- $stm_queue[$day].="update mail_from set subject='".$status['subject']."', fromm='".strtolower($status['from'])."',helo='".$status['helo']."' where sid='".$status['sid']."';\n";
- $stm_queue[$day].="insert or ignore into mail_to (from_id,too,status,status_info) VALUES ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($status['to'])."',(select id from mail_status where info='incoming'),'".$status['status_info']."');\n";
- $stm_queue[$day].="update or ignore mail_to set status=(select id from mail_status where info='incoming'), status_info='".$status['status_info']."', too='".strtolower($status['to'])."' where from_id in (select id from mail_from where sid='".$status['sid']."' and server='".$email[2]."');\n";
- }
- else{
- $stm_queue[$day].="update mail_from set fromm='".strtolower($status['from'])."',helo='".$status['helo']."' where sid='".$status['sid']."';\n";
- $status['status_info']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[5].$email[11]);
- $stm_queue[$day].="insert or ignore into mail_to (from_id,too,status,status_info) VALUES ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($status['to'])."',(select id from mail_status where info='".$email[4]."'),'".$status['status_info']."');\n";
- $stm_queue[$day].="update or ignore mail_to set status=(select id from mail_status where info='".$email[4]."'), status_info='".$status['status_info']."', too='".strtolower($status['to'])."' where from_id in (select id from mail_from where sid='".$status['sid']."' and server='".$email[2]."');\n";
- }
- }
- #Nov 9 02:14:34 srvch011 postfix/smtpd[38129]: NOQUEUE: reject: RCPT from unknown[201.36.0.7]: 450 4.7.1 Client host rejected: cannot find your hostname, [201.36.98.7]; from=<maladireta@esadcos.com.br> to=<sexec.09vara@go.domain.test.com> proto=ESMTP helo=<capri0.wb.com.br>
- else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+NOQUEUE:\s+(\w+): (.*); from=\<(.*)\> to=\<(.*)\>.*helo=\<(.*)\>/",$line,$email)){
- $status['date']=$email[1];
- $status['server']=$email[2];
- $status['status']=$email[3];
- $status['status_info']=$email[4];
- $status['from']=$email[5];
- $status['to']=$email[6];
- $status['helo']=$email[7];
- $values="'".$status['date']."','".$status['status']."','".$status['status_info']."','".strtolower($status['from'])."','".strtolower($status['to'])."','".$status['helo']."','".$status['server']."'";
- $stm_noqueue[$day].='insert or ignore into mail_noqueue(date,status,status_info,fromm,too,helo,server) values ('.$values.');'."\n";
- }
- if ($total_lines%1500 == 0){
- #save log in database
- write_db($stm_noqueue,"noqueue",$days);
- write_db($stm_queue,"from",$days);
- foreach ($days as $d){
- $stm_noqueue[$d]="BEGIN;\n";
- $stm_queue[$d]="BEGIN;\n";
- }
- }
- if ($total_lines%1500 == 0)
- print "$line\n";
- }
- #save log in database
- write_db($stm_noqueue,"noqueue",$days);
- write_db($stm_queue,"from",$days);
- foreach ($days as $d){
- $stm_noqueue[$d]="BEGIN;\n";
- $stm_queue[$d]="BEGIN;\n";
- }
- }
-
- $config=parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']);
- print count($config['installedpackages']);
- #start db replication if configured
- if ($config['installedpackages']['postfixsync']['config'][0]['rsync'])
- foreach ($config['installedpackages']['postfixsync']['config'] as $rs )
- foreach($rs['row'] as $sh){
- $sync_to_ip = $sh['ipaddress'];
- $sync_type = $sh['sync_type'];
- $password = $sh['password'];
- print "checking replication to $sync_to_ip...";
- if ($password && $sync_to_ip && preg_match("/(both|database)/",$sync_type))
- postfix_do_xmlrpc_sync($sync_to_ip, $password,$sync_type);
- print "ok\n";
- }
-
-}
-
-function write_db($stm,$table,$days){
- global $postfix_dir,$config,$g;
- conf_mount_rw();
- $do_sync=array();
- print "writing to database...";
- foreach ($days as $day)
- if (strlen($stm[$day]) > 10){
- if ($config['installedpackages']['postfixsync']['config'][0])
- foreach ($config['installedpackages']['postfixsync']['config'] as $rs )
- foreach($rs['row'] as $sh){
- $sync_to_ip = $sh['ipaddress'];
- $sync_type = $sh['sync_type'];
- $password = $sh['password'];
- $sql_file='/var/db/postfix/'.$sync_to_ip.'.sql';
- ${$sync_to_ip}="";
- if (file_exists($sql_file))
- ${$sync_to_ip}=file_get_contents($sql_file);
- if ($sync_to_ip && $sync_type=="share"){
- ${$sync_to_ip}.=serialize(array('day'=> $day,'sql'=> base64_encode(gzcompress($stm[$day]."COMMIT;",9))))."\n";
- if (! in_array($sync_to_ip,$do_sync))
- $do_sync[]=$sync_to_ip;
- }
- }
- #write local db file
- create_db($day.".db");
- if ($debug=true)
- print " writing to local db $day...";
- $dbhandle = sqlite_open($postfix_dir.$day.".db", 0666, $error);
- if (!$dbhandle) die ($error);
- #file_put_contents("/tmp/".$key.'-'.$update['day'].".sql",gzuncompress(base64_decode($update['sql'])), LOCK_EX);
- $ok = sqlite_exec($dbhandle, $stm[$day]."COMMIT;", $error);
- if (!$ok){
- if ($debug=true)
- print ("Cannot execute query. $error\n".$stm[$day]."COMMIT;\n");
- }
- else{
- if ($debug=true)
- print "ok\n";
- }
- sqlite_close($dbhandle);
- }
- #write update sql files
- if (count ($do_sync) > 0 ){
-
- foreach($do_sync as $ip)
- file_put_contents('/var/db/postfix/'.$ip.'.sql',${$ip},LOCK_EX);
- conf_mount_ro();
- }
- #write local file
-
-}
-
-function create_db($postfix_db){
- global $postfix_dir,$postfix_arg;
- if (! is_dir($postfix_dir))
- mkdir($postfix_dir,0775);
- $new_db=(file_exists($postfix_dir.$postfix_db)?1:0);
-$stm = <<<EOF
- CREATE TABLE "mail_from"(
- "id" INTEGER PRIMARY KEY,
- "sid" VARCHAR(11) NOT NULL,
- "client" TEXT NOT NULL,
- "msgid" TEXT,
- "fromm" TEXT,
- "size" INTEGER,
- "subject" TEXT,
- "date" TEXT NOT NULL,
- "server" TEXT,
- "helo" TEXT
-);
- CREATE TABLE "mail_to"(
- "id" INTEGER PRIMARY KEY,
- "from_id" INTEGER NOT NULL,
- "too" TEXT,
- "status" INTEGER,
- "status_info" TEXT,
- "smtp" TEXT,
- "delay" TEXT,
- "relay" TEXT,
- "dsn" TEXT,
- "server" TEXT,
- "bounce" TEXT,
- FOREIGN KEY (status) REFERENCES mail_status(id),
- FOREIGN KEY (from_id) REFERENCES mail_from(id)
-);
-
-
-CREATE TABLE "mail_status"(
- "id" INTEGER PRIMARY KEY,
- "info" varchar(35) NOT NULL
-);
-
-CREATE TABLE "mail_noqueue"(
- "id" INTEGER PRIMARY KEY,
- "date" TEXT NOT NULL,
- "server" TEXT NOT NULL,
- "status" TEXT NOT NULL,
- "status_info" INTEGER NOT NULL,
- "fromm" TEXT NOT NULL,
- "too" TEXT NOT NULL,
- "helo" TEXT NOT NULL
-);
-
-CREATE TABLE "db_version"(
- "value" varchar(10),
- "info" TEXT
-);
-
-insert or ignore into db_version ('value') VALUES ('2.3.1');
-
-CREATE INDEX "noqueue_unique" on mail_noqueue (date ASC, fromm ASC, too ASC);
-CREATE INDEX "noqueue_helo" on mail_noqueue (helo ASC);
-CREATE INDEX "noqueue_too" on mail_noqueue (too ASC);
-CREATE INDEX "noqueue_fromm" on mail_noqueue (fromm ASC);
-CREATE INDEX "noqueue_info" on mail_noqueue (status_info ASC);
-CREATE INDEX "noqueue_status" on mail_noqueue (status ASC);
-CREATE INDEX "noqueue_server" on mail_noqueue (server ASC);
-CREATE INDEX "noqueue_date" on mail_noqueue (date ASC);
-
-CREATE UNIQUE INDEX "status_info" on mail_status (info ASC);
-
-CREATE UNIQUE INDEX "from_sid_server" on mail_from (sid ASC,server ASC);
-CREATE INDEX "from_client" on mail_from (client ASC);
-CREATE INDEX "from_helo" on mail_from (helo ASC);
-CREATE INDEX "from_server" on mail_from (server ASC);
-CREATE INDEX "from_subject" on mail_from (subject ASC);
-CREATE INDEX "from_msgid" on mail_from (msgid ASC);
-CREATE INDEX "from_fromm" on mail_from (fromm ASC);
-CREATE INDEX "from_date" on mail_from (date ASC);
-
-CREATE UNIQUE INDEX "mail_to_unique" on mail_to (from_id ASC, too ASC);
-CREATE INDEX "to_bounce" on mail_to (bounce ASC);
-CREATE INDEX "to_relay" on mail_to (relay ASC);
-CREATE INDEX "to_smtp" on mail_to (smtp ASC);
-CREATE INDEX "to_info" on mail_to (status_info ASC);
-CREATE INDEX "to_status" on mail_to (status ASC);
-CREATE INDEX "to_too" on mail_to (too ASC);
-
-EOF;
-#test file version
-print "checking". $postfix_dir.$postfix_db."\n";
-$dbhandle = sqlite_open($postfix_dir.$postfix_db, 0666, $error);
-if (!$dbhandle) die ($error);
-$ok = sqlite_exec($dbhandle,"select value from db_version", $error);
-sqlite_close($dbhandle);
-if (!$ok){
- print "delete previous table version\n";
- if (file_exists($postfix_dir.$postfix_db))
- unlink($postfix_dir.$postfix_db);
- $new_db=0;
-}
-if ($new_db==0){
- $dbhandle = sqlite_open($postfix_dir.$postfix_db, 0666, $error);
- $ok = sqlite_exec($dbhandle, $stm, $error);
- if (!$ok)
- print ("Cannot execute query. $error\n");
- $ok = sqlite_exec($dbhandle, $stm2, $error);
- if (!$ok)
- print ("Cannot execute query. $error\n");
- sqlite_close($dbhandle);
- }
-}
-
-$postfix_dir="/var/db/postfix/";
-$curr_time = time();
-#console script call
-if ($argv[1]!=""){
-switch ($argv[1]){
- case "01min":
- $postfix_arg=array( 'grep' => array(date("H:i",strtotime('-1 min',$curr_time))),
- 'time' => '-1 min');
- break;
- case "10min":
- $postfix_arg=array( 'grep' => array(substr(date("H:i",strtotime('-10 min',$curr_time)),0,-1)),
- 'time' => '-10 min');
- break;
- case "01hour":
- $postfix_arg=array( 'grep' => array(date("H:",strtotime('-01 hour',$curr_time))),
- 'time' => '-01 hour');
- break;
- case "04hour":
- $postfix_arg=array( 'grep' => array(date("H:",strtotime('-04 hour',$curr_time)),date("H:",strtotime('-03 hour',$curr_time)),
- date("H:",strtotime('-02 hour',$curr_time)),date("H:",strtotime('-01 hour',$curr_time))),
- 'time' => '-04 hour');
- break;
- case "24hours":
- $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
- '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
- 'time' => '-01 day');
- break;
- case "02days":
- $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
- '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
- 'time' => '-02 day');
- break;
- case "03days":
- $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
- '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
- 'time' => '-03 day');
- break;
-
- default:
- die ("invalid parameters\n");
-}
-# get remote log from remote server
-get_remote_log();
-# get local log from logfile
-grep_log();
-}
-
-#http client call
-if ($_REQUEST['files']!= ""){
- #do search
- if($_REQUEST['queue']=="QUEUE"){
- $stm="select * from mail_from, mail_to ,mail_status where mail_from.id=mail_to.from_id and mail_to.status=mail_status.id ";
- $last_next=" and ";
- }
- else{
- $stm="select * from mail_noqueue";
- $last_next=" where ";
- }
- $limit_prefix=(preg_match("/\d+/",$_REQUEST['limit'])?"limit ":"");
- $limit=(preg_match("/\d+/",$_REQUEST['limit'])?$_REQUEST['limit']:"");
- $files= explode(",", $_REQUEST['files']);
- $stm_fetch=array();
- $total_result=0;
- foreach ($files as $postfix_db)
- if (file_exists($postfix_dir.'/'.$postfix_db)){
- $dbhandle = sqlite_open($postfix_dir.'/'.$postfix_db, 0666, $error);
- if ($_REQUEST['from']!= ""){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if (preg_match('/\*/',$_REQUEST['from']))
- $stm .=$next."fromm like '".preg_replace('/\*/','%',$_REQUEST['from'])."'";
- else
- $stm .=$next."fromm in('".$_REQUEST['from']."')";
- }
- if ($_REQUEST['to']!= ""){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if (preg_match('/\*/',$_REQUEST['to']))
- $stm .=$next."too like '".preg_replace('/\*/','%',$_REQUEST['to'])."'";
- else
- $stm .=$next."too in('".$_REQUEST['to']."')";
- }
- if ($_REQUEST['sid']!= "" && $_REQUEST['queue']=="QUEUE"){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- $stm .=$next."sid in('".$_REQUEST['sid']."')";
- }
- if ($_REQUEST['relay']!= "" && $_REQUEST['queue']=="QUEUE"){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if (preg_match('/\*/',$_REQUEST['subject']))
- $stm .=$next."relay like '".preg_replace('/\*/','%',$_REQUEST['relay'])."'";
- else
- $stm .=$next."relay = '".$_REQUEST['relay']."'";
- }
- if ($_REQUEST['subject']!= "" && $_REQUEST['queue']=="QUEUE"){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if (preg_match('/\*/',$_REQUEST['subject']))
- $stm .=$next."subject like '".preg_replace('/\*/','%',$_REQUEST['subject'])."'";
- else
- $stm .=$next."subject = '".$_REQUEST['subject']."'";
- }
- if ($_REQUEST['msgid']!= "" && $_REQUEST['queue']=="QUEUE"){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if (preg_match('/\*/',$_REQUEST['msgid']))
- $stm .=$next."msgid like '".preg_replace('/\*/','%',$_REQUEST['msgid'])."'";
- else
- $stm .=$next."msgid = '".$_REQUEST['msgid']."'";
- }
- if ($_REQUEST['server']!= "" ){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- if( $_REQUEST['queue']=="QUEUE")
- $stm .=$next."mail_from.server = '".$_REQUEST['server']."'";
- else
- $stm .=$next."server = '".$_REQUEST['server']."'";
- }
-
- if ($_REQUEST['status']!= ""){
- $next=($last_next==" and "?" and ":" where ");
- $last_next=" and ";
- $stm .=$next."mail_status.info = '".$_REQUEST['status']."'";
- }
- #print "<pre>".$stm;
- #$stm = "select * from mail_to,mail_status where mail_to.status=mail_status.id";
- $result = sqlite_query($dbhandle, $stm." order by date desc $limit_prefix $limit ");
- #$result = sqlite_query($dbhandle, $stm." $limit_prefix $limit ");
- if (preg_match("/\d+/",$_REQUEST['limit'])){
- for ($i = 1; $i <= $limit; $i++) {
- $row = sqlite_fetch_array($result, SQLITE_ASSOC);
- if (is_array($row))
- $stm_fetch[]=$row;
- }
- }
- else{
- $stm_fetch = sqlite_fetch_all($result, SQLITE_ASSOC);
- }
- sqlite_close($dbhandle);
- }
- $fields= explode(",", $_REQUEST['fields']);
- if ($_REQUEST['sbutton']=='export'){
- print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
- print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
- print '<tr>';
- $header="";
- foreach ($stm_fetch as $mail){
- foreach ($mail as $key => $data){
- if (!preg_match("/$key/",$header))
- $header .= $key.",";
- $export.=preg_replace('/,/',"",$mail[$key]).",";
- }
- $export.= "\n";
- }
- print '<td class="tabcont"><textarea id="varnishlogs" rows="50" cols="100%">';
- print "This export is in csv format, paste it without this line on any software that handles csv files.\n\n".$header."\n".$export;
- print "</textarea></td></tr></table>";
- }
- else{
- if ($_REQUEST['queue']=="NOQUEUE"){
- print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
- print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
- print '<tr>';
- if(in_array("date",$fields))
- print '<td class="listlr"><strong>date</strong></td>';
- if(in_array("server",$fields))
- print '<td class="listlr"><strong>server</strong></td>';
- if(in_array("from",$fields))
- print '<td class="listlr"><strong>From</strong></td>';
- if(in_array("to",$fields))
- print '<td class="listlr"><strong>to</strong></td>';
- if(in_array("helo",$fields))
- print '<td class="listlr"><strong>Helo</strong></td>';
- if(in_array("status",$fields))
- print '<td class="listlr"><strong>Status</strong></td>';
- if(in_array("status_info",$fields))
- print '<td class="listlr"><strong>Status Info</strong></td>';
- print '</tr>';
- foreach ($stm_fetch as $mail){
- print '<tr>';
- if(in_array("date",$fields))
- print '<td class="listlr">'.$mail['date'].'</td>';
- if(in_array("server",$fields))
- print '<td class="listlr">'.$mail['server'].'</td>';
- if(in_array("from",$fields))
- print '<td class="listlr">'.$mail['fromm'].'</td>';
- if(in_array("to",$fields))
- print '<td class="listlr">'.$mail['too'].'</td>';
- if(in_array("helo",$fields))
- print '<td class="listlr">'.$mail['helo'].'</td>';
- if(in_array("status",$fields))
- print '<td class="listlr">'.$mail['status'].'</td>';
- if(in_array("status_info",$fields))
- print '<td class="listlr">'.$mail['status_info'].'</td>';
- print '</tr>';
- $total_result++;
- }
- }
- else{
- print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
- print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
- print '<tr>';
- if(in_array("date",$fields))
- print '<td class="listlr" ><strong>Date</strong></td>';
- if(in_array("server",$fields))
- print '<td class="listlr" ><strong>Server</strong></td>';
- if(in_array("from",$fields))
- print '<td class="listlr" ><strong>From</strong></td>';
- if(in_array("to",$fields))
- print '<td class="listlr" ><strong>to</strong></td>';
- if(in_array("subject",$fields))
- print '<td class="listlr" ><strong>Subject</strong></td>';
- if(in_array("delay",$fields))
- print '<td class="listlr" ><strong>Delay</strong></td>';
- if(in_array("status",$fields))
- print '<td class="listlr" ><strong>Status</strong></td>';
- if(in_array("status_info",$fields))
- print '<td class="listlr" ><strong>Status Info</strong></td>';
- if(in_array("size",$fields))
- print '<td class="listlr" ><strong>Size</strong></td>';
- if(in_array("helo",$fields))
- print '<td class="listlr" ><strong>Helo</strong></td>';
- if(in_array("sid",$fields))
- print '<td class="listlr" ><strong>SID</strong></td>';
- if(in_array("msgid",$fields))
- print '<td class="listlr" ><strong>MSGID</strong></td>';
- if(in_array("bounce",$fields))
- print '<td class="listlr" ><strong>Bounce</strong></td>';
- if(in_array("relay",$fields))
- print '<td class="listlr" ><strong>Relay</strong></td>';
- print '</tr>';
- foreach ($stm_fetch as $mail){
- if(in_array("date",$fields))
- print '<td class="listlr">'.$mail['mail_from.date'].'</td>';
- if(in_array("server",$fields))
- print '<td class="listlr">'.$mail['mail_from.server'].'</td>';
- if(in_array("from",$fields))
- print '<td class="listlr">'.$mail['mail_from.fromm'].'</td>';
- if(in_array("to",$fields))
- print '<td class="listlr">'.$mail['mail_to.too'].'</td>';
- if(in_array("subject",$fields))
- print '<td class="listlr">'.$mail['mail_from.subject'].'</td>';
- if(in_array("delay",$fields))
- print '<td class="listlr">'.$mail['mail_to.delay'].'</td>';
- if(in_array("status",$fields))
- print '<td class="listlr">'.$mail['mail_status.info'].'</td>';
- if(in_array("status_info",$fields))
- print '<td class="listlr">'.$mail['mail_to.status_info'].'</td>';
- if(in_array("size",$fields))
- print '<td class="listlr">'.$mail['mail_from.size'].'</td>';
- if(in_array("helo",$fields))
- print '<td class="listlr">'.$mail['mail_from.helo'].'</td>';
- if(in_array("sid",$fields))
- print '<td class="listlr">'.$mail['mail_from.sid'].'</td>';
- if(in_array("msgid",$fields))
- print '<td class="listlr">'.$mail['mail_from.msgid'].'</td>';
- if(in_array("bounce",$fields))
- print '<td class="listlr">'.$mail['mail_to.bounce'].'</td>';
- if(in_array("relay",$fields))
- print '<td class="listlr">'.$mail['mail_to.relay'].'</td>';
- print '</tr>';
- $total_result++;
- }
- }
- print '<tr>';
- print '<td ><strong>Total:</strong></td>';
- print '<td ><strong>'.$total_result.'</strong></td>';
- print '</tr>';
- print '</table>';
- }
-}
+<?php
+/*
+ postfix.php
+ part of pfSense (http://www.pfsense.com/)
+ Copyright (C) 2011 Marcello Coutinho <marcellocoutinho@gmail.com>
+ based on varnish_view_config.
+ 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.
+*/
+require_once("/etc/inc/util.inc");
+require_once("/etc/inc/functions.inc");
+require_once("/etc/inc/pkg-utils.inc");
+require_once("/etc/inc/globals.inc");
+require_once("/usr/local/pkg/postfix.inc");
+
+function get_remote_log(){
+ global $config,$g,$postfix_dir;
+ $curr_time = time();
+ $log_time=date('YmdHis',$curr_time);
+ #get protocol
+ if($config['system']['webgui']['protocol'] != "")
+ $synchronizetoip = $config['system']['webgui']['protocol']. "://";
+ #get port
+ $port = $config['system']['webgui']['port'];
+ #if port is empty lets rely on the protocol selection
+ if($port == "")
+ $port =($config['system']['webgui']['protocol'] == "http"?"80":"443");
+ $synchronizetoip .= $sync_to_ip;
+ if (is_array($config['installedpackages']['postfixsync']))
+ foreach($config['installedpackages']['postfixsync']['config'][0]['row'] as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $sync_type = $sh['sync_type'];
+ $password = $sh['password'];
+ $file= '/var/db/postfix/'.$server.'.sql';
+ #get remote data
+ if ($sync_type=='fetch'){
+ $url= $synchronizetoip . $sync_to_ip;
+ print "$sync_to_ip $url, $port\n";
+ $method = 'pfsense.exec_php';
+ $execcmd = "require_once('/usr/local/www/postfix.php');\n";
+ $execcmd .= '$toreturn=get_sql('.$log_time.');';
+ /* assemble xmlrpc payload */
+ $params = array(XML_RPC_encode($password),
+ XML_RPC_encode($execcmd));
+ log_error("postfix get sql data from {$sync_to_ip}.");
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials('admin', $password);
+ #$cli->setDebug(1);
+ $resp = $cli->send($msg, "250");
+ $a=$resp->value();
+ $errors=0;
+ #var_dump($sql);
+ foreach($a as $b)
+ foreach ($b as $c)
+ foreach ($c as $d)
+ foreach ($d as $e){
+ $update=unserialize($e['string']);
+ print $update['day']."\n";
+ if ($update['day'] != ""){
+ create_db($update['day'].".db");
+ if ($debug=true)
+ print $update['day'] ." writing from remote system to db...";
+ $dbhandle = sqlite_open($postfix_dir.'/'.$update['day'].".db", 0666, $error);
+ #file_put_contents("/tmp/".$key.'-'.$update['day'].".sql",gzuncompress(base64_decode($update['sql'])), LOCK_EX);
+ $ok = sqlite_exec($dbhandle, gzuncompress(base64_decode($update['sql'])), $error);
+ if (!$ok){
+ $errors++;
+ die ("Cannot execute query. $error\n".$update['sql']."\n");
+ }
+ else{
+ if ($debug=true)
+ print "ok\n";
+ }
+ sqlite_close($dbhandle);
+ }
+ }
+ if ($errors ==0){
+ $method = 'pfsense.exec_php';
+ $execcmd = "require_once('/usr/local/www/postfix.php');\n";
+ $execcmd .= 'flush_sql('.$log_time.');';
+ /* assemble xmlrpc payload */
+ $params = array(XML_RPC_encode($password),
+ XML_RPC_encode($execcmd));
+ log_error("postfix flush sql buffer file from {$sync_to_ip}.");
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials('admin', $password);
+ #$cli->setDebug(1);
+ $resp = $cli->send($msg, "250");
+ }
+ }
+ }
+}
+function get_sql($log_time){
+ global $config,$xmlrpc_g;
+ $server=$_SERVER['REMOTE_ADDR'];
+
+ if (is_array($config['installedpackages']['postfixsync']))
+ foreach($config['installedpackages']['postfixsync']['config'][0]['row'] as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $sync_type = $sh['sync_type'];
+ $password = $sh['password'];
+ $file= '/var/db/postfix/'.$server.'.sql';
+ if ($sync_to_ip==$server && $sync_type=='share' && file_exists($file)){
+ rename($file,$file.".$log_time");
+ return (file($file.".$log_time"));
+ }
+ }
+ return "";
+}
+
+function flush_sql($log_time){
+ if (preg_match("/\d+\.\d+\.\d+\.\d+/",$_SERVER['REMOTE_ADDR']))
+ unlink_if_exists('/var/db/postfix/'.$_SERVER['REMOTE_ADDR'].".sql.$log_time");
+}
+
+function grep_log(){
+ global $postfix_dir,$postfix_arg,$config,$g;
+
+ $total_lines=0;
+ $days=array();
+ $grep="\(MailScanner\|postfix.cleanup\|postfix.smtp\|postfix.error\|postfix.qmgr\)";
+ $curr_time = time();
+ $log_time=strtotime($postfix_arg['time'],$curr_time);
+ $m=date('M',strtotime($postfix_arg['time'],$curr_time));
+ $j=substr(" ".date('j',strtotime($postfix_arg['time'],$curr_time)),-3);
+ # file grep loop
+ foreach ($postfix_arg['grep'] as $hour){
+ print "/usr/bin/grep '^".$m.$j." ".$hour.".*".$grep."' /var/log/maillog\n";
+ $lists=array();
+ exec("/usr/bin/grep " . escapeshellarg('^'.$m.$j." ".$hour.".*".$grep)." /var/log/maillog", $lists);
+ foreach ($lists as $line){
+ #check where is first mail record
+ if (preg_match("/ delay=(\d+)/",$line,$delay)){
+ $day=date("Y-m-d",strtotime("-".$delay[1]." second",$log_time));
+ if (! in_array($day,$days)){
+ $days[]=$day;
+ create_db($day.".db");
+ print "Found logs to $day.db\n";
+ $stm_queue[$day]="BEGIN;\n";
+ $stm_noqueue[$day]="BEGIN;\n";
+ }
+ }
+ else{
+ $day=date("Y-m-d",strtotime($postfix_arg['time'],$curr_time));
+ if (! in_array($day,$days)){
+ $days[]=$day;
+ create_db($day.".db");
+ print "Found logs to $day.db\n";
+ $stm_queue[$day]="BEGIN;\n";
+ $stm_noqueue[$day]="BEGIN;\n";
+ }
+ }
+ $status=array();
+ $total_lines++;
+ #Nov 8 09:31:50 srvch011 postfix/smtpd[43585]: 19C281F59C8: client=pm03-974.auinmem.br[177.70.0.3]
+ if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+(\w+): client=(.*)/",$line,$email)){
+ $values="'".$email[3]."','".$email[1]."','".$email[2]."','".$email[4]."'";
+ if(${$email[3]}!=$email[3])
+ $stm_queue[$day].='insert or ignore into mail_from(sid,date,server,client) values ('.$values.');'."\n";
+ ${$email[3]}=$email[3];
+ }
+ #Dec 2 22:21:18 pfsense MailScanner[60670]: Requeue: 8DC3BBDEAF.A29D3 to 5AD9ABDEB5
+ else if (preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) MailScanner.*Requeue: (\w+)\W\w+ to (\w+)/",$line,$email)){
+ $stm_queue[$day].= "update or ignore mail_from set sid='".$email[4]."' where sid='".$email[3]."';\n";
+ }
+ #Dec 5 14:06:10 srvchunk01 MailScanner[19589]: Message 775201F44B1.AED2C from 209.185.111.50 (marcellocoutinho@mailtest.com) to sede.mail.test.com is spam, SpamAssassin (not cached, escore=99.202, requerido 6, autolearn=spam, DKIM_SIGNED 0.10, DKIM_VALID -0.10, DKIM_VALID_AU -0.10, FREEMAIL_FROM 0.00, HTML_MESSAGE 0.00, RCVD_IN_DNSWL_LOW -0.70, WORM_TEST2 100.00)
+ else if (preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) MailScanner\W\d+\W+\w+\s+(\w+).* is spam, (.*)/",$line,$email)){
+ $stm_queue[$day].= "insert or ignore into mail_status (info) values ('spam');\n";
+ print "\n#######################################\nSPAM:".$email[4].$email[3].$email[2]."\n#######################################\n";
+ $stm_queue[$day].= "update or ignore mail_to set status=(select id from mail_status where info='spam'), status_info='".preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[4])."' where from_id in (select id from mail_from where sid='".$email[3]."' and server='".$email[2]."');\n";
+ }
+ #Nov 14 09:29:32 srvch011 postfix/error[58443]: 2B8EB1F5A5A: to=<hildae.sva@pi.email.com>, relay=none, delay=0.66, delays=0.63/0/0/0.02, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=mail.pi.test.com type=A: Host not found, try again)
+ #Nov 3 21:45:32 srvch011 postfix/smtp[18041]: 4CE321F4887: to=<viinil@vitive.com.br>, relay=smtpe1.eom[81.00.20.9]:25, delay=1.9, delays=0.06/0.01/0.68/1.2, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 2C33E2382C8)
+ #Nov 16 00:00:14 srvch011 postfix/smtp[7363]: 7AEB91F797D: to=<alessandra.bueno@mg.test.com>, relay=mail.mg.test.com[172.25.3.5]:25, delay=39, delays=35/1.1/0.04/2.7, dsn=5.7.1, status=bounced (host mail.mg.test.com[172.25.3.5] said: 550 5.7.1 Unable to relay for alessandra.bueno@mg.test.com (in reply to RCPT TO command))
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.\w+\W\d+\W+(\w+): to=\<(.*)\>, relay=(.*), delay=([0-9,.]+), .* dsn=([0-9,.]+), status=(\w+) (.*)/",$line,$email)){
+ $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[8]."');\n";
+ $stm_queue[$day].= "insert or ignore into mail_to (from_id,too,status,status_info,relay,delay,dsn) values ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($email[4])."',(select id from mail_status where info='".$email[8]."'),'".preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[9])."','".$email[5]."','".$email[6]."','".$email[7]."');\n";
+ $stm_queue[$day].= "update or ignore mail_to set status=(select id from mail_status where info='".$email[8]."'), status_info='".preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[9])."', dsn='".$email[7]."', delay='".$email[6]."', relay='".$email[5]."', too='".strtolower($email[4])."' where from_id in (select id from mail_from where sid='".$email[3]."' and server='".$email[2]."');\n";
+ }
+ #Nov 13 01:48:44 srvch011 postfix/cleanup[16914]: D995B1F570B: message-id=<61.40.11745.10E3FBE4@ofertas6>
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.cleanup\W\d+\W+(\w+): message-id=\<(.*)\>/",$line,$email)){
+ $stm_queue[$day].="update mail_from set msgid='".$email[4]."' where sid='".$email[3]."';\n";
+ }
+ #Nov 14 02:40:05 srvch011 postfix/qmgr[46834]: BC5931F4F13: from=<ceag@mx.crmcom.br>, size=32727, nrcpt=1 (queue active)
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.qmgr\W\d+\W+(\w+): from=\<(.*)\>\W+size=(\d+)/",$line,$email)){
+ $stm_queue[$day].= "update mail_from set fromm='".strtolower($email[4])."', size='".$email[5]."' where sid='".$email[3]."';\n";
+ }
+ #Nov 13 00:09:07 srvch011 postfix/bounce[56376]: 9145C1F67F7: sender non-delivery notification: D5BD31F6865
+ #else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.bounce\W\d+\W+(\w+): sender non-delivery notification: (\w+)/",$line,$email)){
+ # $stm_queue[$day].= "update mail_queue set bounce='".$email[4]."' where sid='".$email[3]."';\n";
+ #}
+ #Nov 14 01:41:44 srvch011 postfix/smtpd[15259]: warning: 1EF3F1F573A: queue file size limit exceeded
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+warning: (\w+): queue file size limit exceeded/",$line,$email)){
+ $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[8]."');\n";
+ $stm_queue[$day].= "update mail_to set status=(select id from mail_status where info='reject'), status_info='queue file size limit exceeded' where from_id in (select id from mail_from where sid='".$email[3]."' and server='".$email[2]."');\n";
+ }
+
+ #Nov 9 02:14:57 srvch011 postfix/cleanup[6856]: 617A51F5AC5: warning: header Subject: Mapeamento de Processos from lxalpha.12b.com.br[66.109.29.225]; from=<apache@lxalpha.12b.com.br> to=<ritiele.faria@mail.test.com> proto=ESMTP helo=<lxalpha.12b.com.br>
+ #Nov 8 09:31:50 srvch011 postfix/cleanup[11471]: 19C281F59C8: reject: header From: "Giuliana Flores - Parceiro do Grupo Virtual" <publicidade@parceiro-grupovirtual.com.br> from pm03-974.auinmeio.com.br[177.70.232.225]; from=<publicidade@parceiro-grupovirtual.com.br> to=<jorge.lustosa@mail.test.com> proto=ESMTP helo=<pm03-974.auinmeio.com.br>: 5.7.1 [SN007]
+ #Nov 13 00:03:24 srvch011 postfix/cleanup[4192]: 8A5B31F52D2: reject: body http://platform.roastcrack.info/mj0ie6p-48qtiyq from move2.igloojack.info[173.239.63.16]; from=<ljmd6u8lrxke4@move2.igloojack.info> to=<edileva@aasdf..br> proto=SMTP helo=<move2.igloojack.info>: 5.7.1 [BD040]
+ #Nov 14 01:41:35 srvch011 postfix/cleanup[58446]: 1EF3F1F573A: warning: header Subject: =?windows-1252?Q?IMOVEL_Voc=EA_=E9_um_Cliente_especial_da_=93CENTURY21=22?=??=?windows-1252?Q?Veja_o_que_tenho_para_voc=EA?= from mail-yw0-f51.google.com[209.85.213.51]; from=<sergioalexandre6308@gmail.com> to=<sinza@tr.br> proto=ESMTP helo=<mail-yw0-f51.google.com>
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.cleanup\W\d+\W+(\w+): (\w+): (.*) from ([a-z,A-Z,0-9,.,-]+)\W([0-9,.]+)\W+from=\<(.*)\> to=\<(.*)\>.*helo=\W([a-z,A-Z,0-9,.,-]+)(.*)/",$line,$email)){
+ $status['date']=$email[1];
+ $status['server']=$email[2];
+ $status['sid']=$email[3];
+ $status['remote_hostname']=$email[6];
+ $status['remote_ip']=$email[7];
+ $status['from']=$email[8];
+ $status['to']=$email[9];
+ $status['helo']=$email[10];
+ $status['status']=$email[4];
+ $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$email[4]."');\n";
+ if ($email[4] =="warning"){
+ if (${$status['sid']}=='hold'){
+ $status['status']='hold';
+ }
+ else{
+ $status['status']='incoming';
+ $stm_queue[$day].= "insert or ignore into mail_status (info) values ('".$status['status']."');\n";
+ }
+ #print "$line\n";
+ $status['status_info']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[11]);
+ $status['subject']=preg_replace("/header Subject: /","",$email[5]);
+ $status['subject']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$status['subject']);
+ $stm_queue[$day].="update mail_from set subject='".$status['subject']."', fromm='".strtolower($status['from'])."',helo='".$status['helo']."' where sid='".$status['sid']."';\n";
+ $stm_queue[$day].="insert or ignore into mail_to (from_id,too,status,status_info) VALUES ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($status['to'])."',(select id from mail_status where info='".$status['status']."'),'".$status['status_info']."');\n";
+ $stm_queue[$day].="update or ignore mail_to set status=(select id from mail_status where info='".$status['status']."'), status_info='".$status['status_info']."', too='".strtolower($status['to'])."' where from_id in (select id from mail_from where sid='".$status['sid']."' and server='".$email[2]."');\n";
+ }
+ else{
+ ${$status['sid']}=$status['status'];
+ $stm_queue[$day].="update mail_from set fromm='".strtolower($status['from'])."',helo='".$status['helo']."' where sid='".$status['sid']."';\n";
+ $status['status_info']=preg_replace("/(\<|\>|\s+|\'|\")/"," ",$email[5].$email[11]);
+ $stm_queue[$day].="insert or ignore into mail_to (from_id,too,status,status_info) VALUES ((select id from mail_from where sid='".$email[3]."' and server='".$email[2]."'),'".strtolower($status['to'])."',(select id from mail_status where info='".$email[4]."'),'".$status['status_info']."');\n";
+ $stm_queue[$day].="update or ignore mail_to set status=(select id from mail_status where info='".$email[4]."'), status_info='".$status['status_info']."', too='".strtolower($status['to'])."' where from_id in (select id from mail_from where sid='".$status['sid']."' and server='".$email[2]."');\n";
+ }
+ }
+ #Nov 9 02:14:34 srvch011 postfix/smtpd[38129]: NOQUEUE: reject: RCPT from unknown[201.36.0.7]: 450 4.7.1 Client host rejected: cannot find your hostname, [201.36.98.7]; from=<maladireta@esadcos.com.br> to=<sexec.09vara@go.domain.test.com> proto=ESMTP helo=<capri0.wb.com.br>
+ else if(preg_match("/(\w+\s+\d+\s+[0-9,:]+) (\w+) postfix.smtpd\W\d+\W+NOQUEUE:\s+(\w+): (.*); from=\<(.*)\> to=\<(.*)\>.*helo=\<(.*)\>/",$line,$email)){
+ $status['date']=$email[1];
+ $status['server']=$email[2];
+ $status['status']=$email[3];
+ $status['status_info']=$email[4];
+ $status['from']=$email[5];
+ $status['to']=$email[6];
+ $status['helo']=$email[7];
+ $values="'".$status['date']."','".$status['status']."','".$status['status_info']."','".strtolower($status['from'])."','".strtolower($status['to'])."','".$status['helo']."','".$status['server']."'";
+ $stm_noqueue[$day].='insert or ignore into mail_noqueue(date,status,status_info,fromm,too,helo,server) values ('.$values.');'."\n";
+ }
+ if ($total_lines%1500 == 0){
+ #save log in database
+ write_db($stm_noqueue,"noqueue",$days);
+ write_db($stm_queue,"from",$days);
+ foreach ($days as $d){
+ $stm_noqueue[$d]="BEGIN;\n";
+ $stm_queue[$d]="BEGIN;\n";
+ }
+ }
+ if ($total_lines%1500 == 0)
+ print "$line\n";
+ }
+ #save log in database
+ write_db($stm_noqueue,"noqueue",$days);
+ write_db($stm_queue,"from",$days);
+ foreach ($days as $d){
+ $stm_noqueue[$d]="BEGIN;\n";
+ $stm_queue[$d]="BEGIN;\n";
+ }
+ }
+
+ $config=parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']);
+ print count($config['installedpackages']);
+ #start db replication if configured
+ if ($config['installedpackages']['postfixsync']['config'][0]['rsync'])
+ foreach ($config['installedpackages']['postfixsync']['config'] as $rs )
+ foreach($rs['row'] as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $sync_type = $sh['sync_type'];
+ $password = $sh['password'];
+ print "checking replication to $sync_to_ip...";
+ if ($password && $sync_to_ip && preg_match("/(both|database)/",$sync_type))
+ postfix_do_xmlrpc_sync($sync_to_ip, $password,$sync_type);
+ print "ok\n";
+ }
+
+}
+
+function write_db($stm,$table,$days){
+ global $postfix_dir,$config,$g;
+ conf_mount_rw();
+ $do_sync=array();
+ print "writing to database...";
+ foreach ($days as $day)
+ if (strlen($stm[$day]) > 10){
+ if ($config['installedpackages']['postfixsync']['config'][0])
+ foreach ($config['installedpackages']['postfixsync']['config'] as $rs )
+ foreach($rs['row'] as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $sync_type = $sh['sync_type'];
+ $password = $sh['password'];
+ $sql_file='/var/db/postfix/'.$sync_to_ip.'.sql';
+ ${$sync_to_ip}="";
+ if (file_exists($sql_file))
+ ${$sync_to_ip}=file_get_contents($sql_file);
+ if ($sync_to_ip && $sync_type=="share"){
+ ${$sync_to_ip}.=serialize(array('day'=> $day,'sql'=> base64_encode(gzcompress($stm[$day]."COMMIT;",9))))."\n";
+ if (! in_array($sync_to_ip,$do_sync))
+ $do_sync[]=$sync_to_ip;
+ }
+ }
+ #write local db file
+ create_db($day.".db");
+ if ($debug=true)
+ print " writing to local db $day...";
+ $dbhandle = sqlite_open($postfix_dir.$day.".db", 0666, $error);
+ if (!$dbhandle) die ($error);
+ #file_put_contents("/tmp/".$key.'-'.$update['day'].".sql",gzuncompress(base64_decode($update['sql'])), LOCK_EX);
+ $ok = sqlite_exec($dbhandle, $stm[$day]."COMMIT;", $error);
+ if (!$ok){
+ if ($debug=true)
+ print ("Cannot execute query. $error\n".$stm[$day]."COMMIT;\n");
+ }
+ else{
+ if ($debug=true)
+ print "ok\n";
+ }
+ sqlite_close($dbhandle);
+ }
+ #write update sql files
+ if (count ($do_sync) > 0 ){
+
+ foreach($do_sync as $ip)
+ file_put_contents('/var/db/postfix/'.$ip.'.sql',${$ip},LOCK_EX);
+ conf_mount_ro();
+ }
+ #write local file
+
+}
+
+function create_db($postfix_db){
+ global $postfix_dir,$postfix_arg;
+ if (! is_dir($postfix_dir))
+ mkdir($postfix_dir,0775);
+ $new_db=(file_exists($postfix_dir.$postfix_db)?1:0);
+$stm = <<<EOF
+ CREATE TABLE "mail_from"(
+ "id" INTEGER PRIMARY KEY,
+ "sid" VARCHAR(11) NOT NULL,
+ "client" TEXT NOT NULL,
+ "msgid" TEXT,
+ "fromm" TEXT,
+ "size" INTEGER,
+ "subject" TEXT,
+ "date" TEXT NOT NULL,
+ "server" TEXT,
+ "helo" TEXT
+);
+ CREATE TABLE "mail_to"(
+ "id" INTEGER PRIMARY KEY,
+ "from_id" INTEGER NOT NULL,
+ "too" TEXT,
+ "status" INTEGER,
+ "status_info" TEXT,
+ "smtp" TEXT,
+ "delay" TEXT,
+ "relay" TEXT,
+ "dsn" TEXT,
+ "server" TEXT,
+ "bounce" TEXT,
+ FOREIGN KEY (status) REFERENCES mail_status(id),
+ FOREIGN KEY (from_id) REFERENCES mail_from(id)
+);
+
+
+CREATE TABLE "mail_status"(
+ "id" INTEGER PRIMARY KEY,
+ "info" varchar(35) NOT NULL
+);
+
+CREATE TABLE "mail_noqueue"(
+ "id" INTEGER PRIMARY KEY,
+ "date" TEXT NOT NULL,
+ "server" TEXT NOT NULL,
+ "status" TEXT NOT NULL,
+ "status_info" INTEGER NOT NULL,
+ "fromm" TEXT NOT NULL,
+ "too" TEXT NOT NULL,
+ "helo" TEXT NOT NULL
+);
+
+CREATE TABLE "db_version"(
+ "value" varchar(10),
+ "info" TEXT
+);
+
+insert or ignore into db_version ('value') VALUES ('2.3.1');
+
+CREATE INDEX "noqueue_unique" on mail_noqueue (date ASC, fromm ASC, too ASC);
+CREATE INDEX "noqueue_helo" on mail_noqueue (helo ASC);
+CREATE INDEX "noqueue_too" on mail_noqueue (too ASC);
+CREATE INDEX "noqueue_fromm" on mail_noqueue (fromm ASC);
+CREATE INDEX "noqueue_info" on mail_noqueue (status_info ASC);
+CREATE INDEX "noqueue_status" on mail_noqueue (status ASC);
+CREATE INDEX "noqueue_server" on mail_noqueue (server ASC);
+CREATE INDEX "noqueue_date" on mail_noqueue (date ASC);
+
+CREATE UNIQUE INDEX "status_info" on mail_status (info ASC);
+
+CREATE UNIQUE INDEX "from_sid_server" on mail_from (sid ASC,server ASC);
+CREATE INDEX "from_client" on mail_from (client ASC);
+CREATE INDEX "from_helo" on mail_from (helo ASC);
+CREATE INDEX "from_server" on mail_from (server ASC);
+CREATE INDEX "from_subject" on mail_from (subject ASC);
+CREATE INDEX "from_msgid" on mail_from (msgid ASC);
+CREATE INDEX "from_fromm" on mail_from (fromm ASC);
+CREATE INDEX "from_date" on mail_from (date ASC);
+
+CREATE UNIQUE INDEX "mail_to_unique" on mail_to (from_id ASC, too ASC);
+CREATE INDEX "to_bounce" on mail_to (bounce ASC);
+CREATE INDEX "to_relay" on mail_to (relay ASC);
+CREATE INDEX "to_smtp" on mail_to (smtp ASC);
+CREATE INDEX "to_info" on mail_to (status_info ASC);
+CREATE INDEX "to_status" on mail_to (status ASC);
+CREATE INDEX "to_too" on mail_to (too ASC);
+
+EOF;
+#test file version
+print "checking". $postfix_dir.$postfix_db."\n";
+$dbhandle = sqlite_open($postfix_dir.$postfix_db, 0666, $error);
+if (!$dbhandle) die ($error);
+$ok = sqlite_exec($dbhandle,"select value from db_version", $error);
+sqlite_close($dbhandle);
+if (!$ok){
+ print "delete previous table version\n";
+ if (file_exists($postfix_dir.$postfix_db))
+ unlink($postfix_dir.$postfix_db);
+ $new_db=0;
+}
+if ($new_db==0){
+ $dbhandle = sqlite_open($postfix_dir.$postfix_db, 0666, $error);
+ $ok = sqlite_exec($dbhandle, $stm, $error);
+ if (!$ok)
+ print ("Cannot execute query. $error\n");
+ $ok = sqlite_exec($dbhandle, $stm2, $error);
+ if (!$ok)
+ print ("Cannot execute query. $error\n");
+ sqlite_close($dbhandle);
+ }
+}
+
+$postfix_dir="/var/db/postfix/";
+$curr_time = time();
+#console script call
+if ($argv[1]!=""){
+switch ($argv[1]){
+ case "01min":
+ $postfix_arg=array( 'grep' => array(date("H:i",strtotime('-1 min',$curr_time))),
+ 'time' => '-1 min');
+ break;
+ case "10min":
+ $postfix_arg=array( 'grep' => array(substr(date("H:i",strtotime('-10 min',$curr_time)),0,-1)),
+ 'time' => '-10 min');
+ break;
+ case "01hour":
+ $postfix_arg=array( 'grep' => array(date("H:",strtotime('-01 hour',$curr_time))),
+ 'time' => '-01 hour');
+ break;
+ case "04hour":
+ $postfix_arg=array( 'grep' => array(date("H:",strtotime('-04 hour',$curr_time)),date("H:",strtotime('-03 hour',$curr_time)),
+ date("H:",strtotime('-02 hour',$curr_time)),date("H:",strtotime('-01 hour',$curr_time))),
+ 'time' => '-04 hour');
+ break;
+ case "24hours":
+ $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
+ '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
+ 'time' => '-01 day');
+ break;
+ case "02days":
+ $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
+ '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
+ 'time' => '-02 day');
+ break;
+ case "03days":
+ $postfix_arg=array( 'grep' => array('00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:',
+ '12:','13:','14:','15:','16:','17:','18:','19:','20:','21:','22:','23:'),
+ 'time' => '-03 day');
+ break;
+
+ default:
+ die ("invalid parameters\n");
+}
+# get remote log from remote server
+get_remote_log();
+# get local log from logfile
+grep_log();
+}
+
+#http client call
+if ($_REQUEST['files']!= ""){
+ #do search
+ if($_REQUEST['queue']=="QUEUE"){
+ $stm="select * from mail_from, mail_to ,mail_status where mail_from.id=mail_to.from_id and mail_to.status=mail_status.id ";
+ $last_next=" and ";
+ }
+ else{
+ $stm="select * from mail_noqueue";
+ $last_next=" where ";
+ }
+ $limit_prefix=(preg_match("/\d+/",$_REQUEST['limit'])?"limit ":"");
+ $limit=(preg_match("/\d+/",$_REQUEST['limit'])?$_REQUEST['limit']:"");
+ $files= explode(",", $_REQUEST['files']);
+ $stm_fetch=array();
+ $total_result=0;
+ foreach ($files as $postfix_db)
+ if (file_exists($postfix_dir.'/'.$postfix_db)){
+ $dbhandle = sqlite_open($postfix_dir.'/'.$postfix_db, 0666, $error);
+ if ($_REQUEST['from']!= ""){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if (preg_match('/\*/',$_REQUEST['from']))
+ $stm .=$next."fromm like '".preg_replace('/\*/','%',$_REQUEST['from'])."'";
+ else
+ $stm .=$next."fromm in('".$_REQUEST['from']."')";
+ }
+ if ($_REQUEST['to']!= ""){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if (preg_match('/\*/',$_REQUEST['to']))
+ $stm .=$next."too like '".preg_replace('/\*/','%',$_REQUEST['to'])."'";
+ else
+ $stm .=$next."too in('".$_REQUEST['to']."')";
+ }
+ if ($_REQUEST['sid']!= "" && $_REQUEST['queue']=="QUEUE"){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ $stm .=$next."sid in('".$_REQUEST['sid']."')";
+ }
+ if ($_REQUEST['relay']!= "" && $_REQUEST['queue']=="QUEUE"){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if (preg_match('/\*/',$_REQUEST['subject']))
+ $stm .=$next."relay like '".preg_replace('/\*/','%',$_REQUEST['relay'])."'";
+ else
+ $stm .=$next."relay = '".$_REQUEST['relay']."'";
+ }
+ if ($_REQUEST['subject']!= "" && $_REQUEST['queue']=="QUEUE"){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if (preg_match('/\*/',$_REQUEST['subject']))
+ $stm .=$next."subject like '".preg_replace('/\*/','%',$_REQUEST['subject'])."'";
+ else
+ $stm .=$next."subject = '".$_REQUEST['subject']."'";
+ }
+ if ($_REQUEST['msgid']!= "" && $_REQUEST['queue']=="QUEUE"){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if (preg_match('/\*/',$_REQUEST['msgid']))
+ $stm .=$next."msgid like '".preg_replace('/\*/','%',$_REQUEST['msgid'])."'";
+ else
+ $stm .=$next."msgid = '".$_REQUEST['msgid']."'";
+ }
+ if ($_REQUEST['server']!= "" ){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ if( $_REQUEST['queue']=="QUEUE")
+ $stm .=$next."mail_from.server = '".$_REQUEST['server']."'";
+ else
+ $stm .=$next."server = '".$_REQUEST['server']."'";
+ }
+
+ if ($_REQUEST['status']!= ""){
+ $next=($last_next==" and "?" and ":" where ");
+ $last_next=" and ";
+ $stm .=$next."mail_status.info = '".$_REQUEST['status']."'";
+ }
+ #print "<pre>".$stm;
+ #$stm = "select * from mail_to,mail_status where mail_to.status=mail_status.id";
+ $result = sqlite_query($dbhandle, $stm." order by date desc $limit_prefix $limit ");
+ #$result = sqlite_query($dbhandle, $stm." $limit_prefix $limit ");
+ if (preg_match("/\d+/",$_REQUEST['limit'])){
+ for ($i = 1; $i <= $limit; $i++) {
+ $row = sqlite_fetch_array($result, SQLITE_ASSOC);
+ if (is_array($row))
+ $stm_fetch[]=$row;
+ }
+ }
+ else{
+ $stm_fetch = sqlite_fetch_all($result, SQLITE_ASSOC);
+ }
+ sqlite_close($dbhandle);
+ }
+ $fields= explode(",", $_REQUEST['fields']);
+ if ($_REQUEST['sbutton']=='export'){
+ print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
+ print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
+ print '<tr>';
+ $header="";
+ foreach ($stm_fetch as $mail){
+ foreach ($mail as $key => $data){
+ if (!preg_match("/$key/",$header))
+ $header .= $key.",";
+ $export.=preg_replace('/,/',"",$mail[$key]).",";
+ }
+ $export.= "\n";
+ }
+ print '<td class="tabcont"><textarea id="varnishlogs" rows="50" cols="100%">';
+ print "This export is in csv format, paste it without this line on any software that handles csv files.\n\n".$header."\n".$export;
+ print "</textarea></td></tr></table>";
+ }
+ else{
+ if ($_REQUEST['queue']=="NOQUEUE"){
+ print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
+ print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
+ print '<tr>';
+ if(in_array("date",$fields))
+ print '<td class="listlr"><strong>date</strong></td>';
+ if(in_array("server",$fields))
+ print '<td class="listlr"><strong>server</strong></td>';
+ if(in_array("from",$fields))
+ print '<td class="listlr"><strong>From</strong></td>';
+ if(in_array("to",$fields))
+ print '<td class="listlr"><strong>to</strong></td>';
+ if(in_array("helo",$fields))
+ print '<td class="listlr"><strong>Helo</strong></td>';
+ if(in_array("status",$fields))
+ print '<td class="listlr"><strong>Status</strong></td>';
+ if(in_array("status_info",$fields))
+ print '<td class="listlr"><strong>Status Info</strong></td>';
+ print '</tr>';
+ foreach ($stm_fetch as $mail){
+ print '<tr>';
+ if(in_array("date",$fields))
+ print '<td class="listlr">'.$mail['date'].'</td>';
+ if(in_array("server",$fields))
+ print '<td class="listlr">'.$mail['server'].'</td>';
+ if(in_array("from",$fields))
+ print '<td class="listlr">'.$mail['fromm'].'</td>';
+ if(in_array("to",$fields))
+ print '<td class="listlr">'.$mail['too'].'</td>';
+ if(in_array("helo",$fields))
+ print '<td class="listlr">'.$mail['helo'].'</td>';
+ if(in_array("status",$fields))
+ print '<td class="listlr">'.$mail['status'].'</td>';
+ if(in_array("status_info",$fields))
+ print '<td class="listlr">'.$mail['status_info'].'</td>';
+ print '</tr>';
+ $total_result++;
+ }
+ }
+ else{
+ print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
+ print '<tr><td colspan="'.count($fields).'" valign="top" class="listtopic">'.gettext("Search Results").'</td></tr>';
+ print '<tr>';
+ if(in_array("date",$fields))
+ print '<td class="listlr" ><strong>Date</strong></td>';
+ if(in_array("server",$fields))
+ print '<td class="listlr" ><strong>Server</strong></td>';
+ if(in_array("from",$fields))
+ print '<td class="listlr" ><strong>From</strong></td>';
+ if(in_array("to",$fields))
+ print '<td class="listlr" ><strong>to</strong></td>';
+ if(in_array("subject",$fields))
+ print '<td class="listlr" ><strong>Subject</strong></td>';
+ if(in_array("delay",$fields))
+ print '<td class="listlr" ><strong>Delay</strong></td>';
+ if(in_array("status",$fields))
+ print '<td class="listlr" ><strong>Status</strong></td>';
+ if(in_array("status_info",$fields))
+ print '<td class="listlr" ><strong>Status Info</strong></td>';
+ if(in_array("size",$fields))
+ print '<td class="listlr" ><strong>Size</strong></td>';
+ if(in_array("helo",$fields))
+ print '<td class="listlr" ><strong>Helo</strong></td>';
+ if(in_array("sid",$fields))
+ print '<td class="listlr" ><strong>SID</strong></td>';
+ if(in_array("msgid",$fields))
+ print '<td class="listlr" ><strong>MSGID</strong></td>';
+ if(in_array("bounce",$fields))
+ print '<td class="listlr" ><strong>Bounce</strong></td>';
+ if(in_array("relay",$fields))
+ print '<td class="listlr" ><strong>Relay</strong></td>';
+ print '</tr>';
+ foreach ($stm_fetch as $mail){
+ if(in_array("date",$fields))
+ print '<td class="listlr">'.$mail['mail_from.date'].'</td>';
+ if(in_array("server",$fields))
+ print '<td class="listlr">'.$mail['mail_from.server'].'</td>';
+ if(in_array("from",$fields))
+ print '<td class="listlr">'.$mail['mail_from.fromm'].'</td>';
+ if(in_array("to",$fields))
+ print '<td class="listlr">'.$mail['mail_to.too'].'</td>';
+ if(in_array("subject",$fields))
+ print '<td class="listlr">'.$mail['mail_from.subject'].'</td>';
+ if(in_array("delay",$fields))
+ print '<td class="listlr">'.$mail['mail_to.delay'].'</td>';
+ if(in_array("status",$fields))
+ print '<td class="listlr">'.$mail['mail_status.info'].'</td>';
+ if(in_array("status_info",$fields))
+ print '<td class="listlr">'.$mail['mail_to.status_info'].'</td>';
+ if(in_array("size",$fields))
+ print '<td class="listlr">'.$mail['mail_from.size'].'</td>';
+ if(in_array("helo",$fields))
+ print '<td class="listlr">'.$mail['mail_from.helo'].'</td>';
+ if(in_array("sid",$fields))
+ print '<td class="listlr">'.$mail['mail_from.sid'].'</td>';
+ if(in_array("msgid",$fields))
+ print '<td class="listlr">'.$mail['mail_from.msgid'].'</td>';
+ if(in_array("bounce",$fields))
+ print '<td class="listlr">'.$mail['mail_to.bounce'].'</td>';
+ if(in_array("relay",$fields))
+ print '<td class="listlr">'.$mail['mail_to.relay'].'</td>';
+ print '</tr>';
+ $total_result++;
+ }
+ }
+ print '<tr>';
+ print '<td ><strong>Total:</strong></td>';
+ print '<td ><strong>'.$total_result.'</strong></td>';
+ print '</tr>';
+ print '</table>';
+ }
+}
?> \ No newline at end of file
diff --git a/config/postfix/postfix_antispam.xml b/config/postfix/postfix_antispam.xml
index c4772085..94f52f35 100644
--- a/config/postfix/postfix_antispam.xml
+++ b/config/postfix/postfix_antispam.xml
@@ -239,6 +239,22 @@
<description></description>
</field>
<field>
+ <fielddescr>Message Hold mode</fielddescr>
+ <fieldname>hold_mode</fieldname>
+ <description><![CDATA[Select how postfix will hold messages to mailscanner.<br>
+ When using auto mode, postfix will hold all messages.<br>
+ When using manual mode, include options like this in acl headers:<br>
+ /^to:.*admin@mydomain.com/ OK<br>
+ /^from:.*user@extdomain.com/ OK<br>
+ /^from:/ HOLD<br>
+ /^to:.*@mydomain.com/ HOLD]]></description>
+ <type>select</type>
+ <options>
+ <option><name>Auto mode</name><value>auto</value></option>
+ <option><name>Manual mode using ACLs</name><value>manual</value></option>
+ </options>
+ </field>
+ <field>
<fielddescr>Software</fielddescr>
<fieldname>antispam_software</fieldname>
<description>Select Third part solution to use. See postfix forwarder package info page for instaling instructions</description>
diff --git a/config/postfix/postfix_queue.php b/config/postfix/postfix_queue.php
index eaf6b7f5..ce4d6cc6 100755
--- a/config/postfix/postfix_queue.php
+++ b/config/postfix/postfix_queue.php
@@ -62,7 +62,7 @@ function get_cmd(){
}
if ($_REQUEST['cmd'] =='qshape'){
if ($_REQUEST['qshape']!="")
- exec("/usr/local/bin/qshape ". preg_replace("/\W/"," ",$_REQUEST['qshape']), $qshape);
+ exec("/usr/local/bin/qshape -".preg_replace("/\W/","",$_REQUEST['type'])." ". preg_replace("/\W/","",$_REQUEST['qshape']), $qshape);
else
exec("/usr/local/bin/qshape", $qshape);
print '<table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">';
@@ -167,6 +167,15 @@ else{
<option value="maildrop">maildrop</option>
</select><br><?=gettext("Select how often queue will be queried.");?></td>
</tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("qshape Report type: ");?></td>
+ <td width="78%" class="vtable">
+ <select name="drop3" id="qtype">
+ <option value="s" selected>sender domain</option>
+ <option value="p">parent domain</option>
+ </select><br><?=gettext("Select between sender or parent domains to order by.");?></td>
+ </tr>
+
<tr>
<td width="22%" valign="top"></td>
<td width="78%"><input name="Submit" type="button" class="formbtn" id="run" value="<?=gettext("show queue");?>" onclick="get_queue('mailq')"><div id="search_help"></div></td>
@@ -212,6 +221,7 @@ else{
var q_args=loopSelected('qshape');
var pars = 'cmd='+$('cmd').options[$('cmd').selectedIndex].value;
var pars = pars + '&qshape='+q_args;
+ var pars = pars + '&type='+$('qtype').options[$('qtype').selectedIndex].value;
var url = "/postfix_queue.php";
var myAjax = new Ajax.Request(
url,
diff --git a/config/postfix/postfix_search.php b/config/postfix/postfix_search.php
index b76f0554..6152140d 100755
--- a/config/postfix/postfix_search.php
+++ b/config/postfix/postfix_search.php
@@ -119,6 +119,8 @@ include("head.inc");
<option value="sent">sent</option>
<option value="bounced">bounced</option>
<option value="reject">reject</option>
+ <option value="spam">spam</option>
+ <option value="hold">hold</option>
<option value="incoming">incoming</option>
</select><br><?=gettext("Max log messages to fetch per Sqlite file.");?></td>
</tr>
diff --git a/config/varnish64/varnish.inc b/config/varnish64/varnish.inc
index 7b514780..24891215 100644
--- a/config/varnish64/varnish.inc
+++ b/config/varnish64/varnish.inc
@@ -137,6 +137,7 @@ function varnish_get_url_mappings_txt() {
#director with no host or url, so director for catch all traffic not specified in config
$lasturlmappings = "\telse\t{\n\t\tset req.backend = ".$url['directorname'].";\n\t\t}\n";
$catch_all = "set";
+ $isfirst = false;
}
else{
if(!$isfirst)
@@ -149,12 +150,13 @@ function varnish_get_url_mappings_txt() {
$urlfailover = "\t\t\tset req.backend = ".$url['failover'].";";
$urlmappings .= "\t\tif (req.restarts == 0) {\n".$urlbackend.$tabs.$directo_grace_time.$tabs."}";
$urlmappings .= "\n\t\telse\t{\n".$urlfailover.$tabs.$directo_grace_time.$tabs."}\n\t\t}\n";
+ $isfirst = false;
}
else{
$tabs=($url['grace']?"\n\t\t":"");
$urlmappings .= $urlbackend.$tabs.$directo_grace_time."\n\t\t}\n";
+ $isfirst = false;
}
- $isfirst = false;
}
}
}