Commit 54fb5932 authored by tbrehm's avatar tbrehm
Browse files

Added postfix header- and body check filters.

parent 63e63f68
......@@ -284,9 +284,20 @@ class installer_base {
'smtpd_client_restrictions = check_client_access mysql:'.$conf["dist_postfix_config_dir"].'/mysql-virtual_client.cf',
'maildrop_destination_concurrency_limit = 1',
'maildrop_destination_recipient_limit = 1',
'virtual_transport = maildrop'
'virtual_transport = maildrop',
'header_checks = regexp:/etc/postfix/header_checks',
'mime_header_checks = regexp:/etc/postfix/mime_header_checks',
'nested_header_checks = regexp:/etc/postfix/nested_header_checks',
'body_checks = regexp:/etc/postfix/body_checks'
);
// Create the header ynd body check files
touch('/etc/postfix/header_checks');
touch('/etc/postfix/mime_header_checks');
touch('/etc/postfix/nested_header_checks');
touch('/etc/postfix/body_checks');
// Make a backup copy of the main.cf file
copy($conf["dist_postfix_config_dir"].'/main.cf',$conf["dist_postfix_config_dir"].'/main.cf~');
......
......@@ -183,6 +183,28 @@ CREATE TABLE `mail_access` (
--
-- --------------------------------------------------------
--
-- Tabellenstruktur fr Tabelle `mail_content_filter`
--
CREATE TABLE `mail_content_filter` (
`content_filter_id` bigint(20) NOT NULL auto_increment,
`sys_userid` int(11) NOT NULL default '0',
`sys_groupid` int(11) NOT NULL default '0',
`sys_perm_user` varchar(5) default NULL,
`sys_perm_group` varchar(5) default NULL,
`sys_perm_other` varchar(5) default NULL,
`server_id` int(11) NOT NULL default '0',
`type` varchar(255) default NULL,
`pattern` varchar(255) default NULL,
`data` varchar(255) default NULL,
`action` varchar(255) default NULL,
`active` varchar(255) NOT NULL default 'y',
PRIMARY KEY (`content_filter_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
......
......@@ -35,6 +35,12 @@ ini_set('register_globals',0);
$conf["app_title"] = "ISPConfig";
$conf["app_version"] = "3.0.0";
$conf["modules_available"] = "admin,mail,sites,monitor,client,dns";
/*
Server variables
*/
$conf["server_id"] = "{server_id}";
......@@ -100,18 +106,9 @@ $conf["start_db"] = true;
$conf["start_session"] = true;
/*
DNS Settings
Constants
*/
$conf["auto_create_ptr"] = 1; // Automatically create PTR records?
$conf["default_ns"] = 'ns1.example.com.'; // must be set if $conf['auto_create_ptr'] is 1. Don't forget the trailing dot!
$conf["default_mbox"] = 'admin.example.com.'; // Admin email address. Must be set if $conf['auto_create_ptr'] is 1. Replace "@" with ".". Don't forget the trailing dot!
$conf["default_ttl"] = 86400;
$conf["default_refresh"] = 28800;
$conf["default_retry"] = 7200;
$conf["default_expire"] = 604800;
$conf["default_minimum_ttl"] = 86400;
define("LOGLEVEL_DEBUG",0);
define("LOGLEVEL_WARN",1);
define("LOGLEVEL_ERROR",2);
......
......@@ -35,6 +35,7 @@ ini_set('register_globals',0);
$conf["app_title"] = "ISPConfig";
$conf["app_version"] = "3.0.0";
$conf["modules_available"] = "admin,mail,sites,monitor,client,dns";
/*
......
<?php
/*
Form Definition
Tabledefinition
Datatypes:
- INTEGER (Forces the input to Int)
- DOUBLE
- CURRENCY (Formats the values to currency notation)
- VARCHAR (no format check, maxlength: 255)
- TEXT (no format check)
- DATE (Dateformat, automatic conversion to timestamps)
Formtype:
- TEXT (Textfield)
- TEXTAREA (Textarea)
- PASSWORD (Password textfield, input is not shown when edited)
- SELECT (Select option field)
- RADIO
- CHECKBOX
- CHECKBOXARRAY
- FILE
VALUE:
- Wert oder Array
Hint:
The ID field of the database table is not part of the datafield definition.
The ID field must be always auto incement (int or bigint).
*/
$form["title"] = "Mail Content Filter";
$form["description"] = "";
$form["name"] = "mail_content_filter";
$form["action"] = "mail_content_filter_edit.php";
$form["db_table"] = "mail_content_filter";
$form["db_table_idx"] = "content_filter_id";
$form["db_history"] = "yes";
$form["tab_default"] = "filter";
$form["list_default"] = "mail_content_filter_list.php";
$form["auth"] = 'yes'; // yes / no
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['filter'] = array (
'title' => "Filter",
'width' => 100,
'template' => "templates/mail_content_filter_edit.htm",
'fields' => array (
##################################
# Begin Datatable fields
##################################
'server_id' => array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
'value' => ''
),
'type' => array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => '',
'value' => array('header' => 'Header Filter','body' => 'Body Filter','mime_header' => 'MIME-Header Filter','nested_header' => 'Nested-Header Filter')
),
'pattern' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'pattern_error_empty'),
),
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'data' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'action' => array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => '',
'value' => array('DISCARD' => 'DISCARD','DUNNO'=>'DUNNO','FILTER'=>'FILTER','HOLD'=>'HOLD','IGNORE'=>'IGNORE','PREPEND'=>'PREPEND','REDIRECT'=>'REDIRECT','REPLACE'=>'REPLACE','REJECT'=>'REJECT','WARN'=>'WARN')
),
'active' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'y',
'value' => array(0 => 'n',1 => 'y')
),
##################################
# ENDE Datatable fields
##################################
)
);
?>
\ No newline at end of file
<?php
$wb["server_id_txt"] = 'Server';
$wb["type_txt"] = 'Filter';
$wb["pattern_txt"] = 'Regexp. Pattern';
$wb["data_txt"] = 'Data';
$wb["action_txt"] = 'Action';
$wb["active_txt"] = 'Active';
$wb["btn_save_txt"] = 'Save';
$wb["btn_cancel_txt"] = 'Cancel';
?>
\ No newline at end of file
<?php
$wb["list_head_txt"] = 'Postfix Header and Body Checks';
$wb["active_txt"] = 'Active';
$wb["server_id_txt"] = 'Server';
$wb["pattern_txt"] = 'Pattern';
$wb["action_txt"] = 'Action';
$wb["page_txt"] = 'Page';
$wb["page_of_txt"] = 'of';
$wb["page_next_txt"] = 'Next';
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
$wb["add_new_record_txt"] = 'Add new Content Filter';
?>
\ No newline at end of file
......@@ -101,6 +101,10 @@ if($_SESSION["s"]["user"]["typ"] == 'admin') {
$items[] = array( 'title' => "Postfix Blacklist",
'target' => 'content',
'link' => 'mail/mail_blacklist_list.php');
$items[] = array( 'title' => "Content Filter",
'target' => 'content',
'link' => 'mail/mail_content_filter_list.php');
$module["nav"][] = array( 'title' => 'Global Filters',
'open' => 1,
......
<?php
/*
Datatypes:
- INTEGER
- DOUBLE
- CURRENCY
- VARCHAR
- TEXT
- DATE
*/
// Name of the list
$liste["name"] = "mail_content_filter";
// Database table
$liste["table"] = "mail_content_filter";
// Index index field of the database table
$liste["table_idx"] = "content_filter_id";
// Search Field Prefix
$liste["search_prefix"] = "search_";
// Records per page
$liste["records_per_page"] = 15;
// Script File of the list
$liste["file"] = "mail_content_filter_list.php";
// Script file of the edit form
$liste["edit_file"] = "mail_content_filter_edit.php";
// Script File of the delete script
$liste["delete_file"] = "mail_content_filter_del.php";
// Paging Template
$liste["paging_tpl"] = "templates/paging.tpl.htm";
// Enable auth
$liste["auth"] = "yes";
/*****************************************************
* Suchfelder
*****************************************************/
$liste["item"][] = array( 'field' => "active",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
'op' => "=",
'prefix' => "",
'suffix' => "",
'width' => "",
'value' => array('y' => "Yes",'n' => "No"));
$liste["item"][] = array( 'field' => "server_id",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
'width' => "",
'value' => "");
$liste["item"][] = array( 'field' => "pattern",
'datatype' => "VARCHAR",
'formtype' => "TEXT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'width' => "",
'value' => "");
$liste["item"][] = array( 'field' => "action",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'width' => "",
'value' => array('DISCARD' => 'DISCARD','DUNNO'=>'DUNNO','FILTER'=>'FILTER','HOLD'=>'HOLD','IGNORE'=>'IGNORE','PREPEND'=>'PREPEND','REDIRECT'=>'REDIRECT','REPLACE'=>'REPLACE','REJECT'=>'REJECT','WARN'=>'WARN'));
?>
\ No newline at end of file
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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.
*/
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/mail_content_filter.list.php";
$tform_def_file = "form/mail_content_filter.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Checke Berechtigungen für Modul
if(!stristr($_SESSION["s"]["user"]["modules"],'mail')) {
header("Location: ../index.php");
exit;
}
$app->uses("tform_actions");
$app->tform_actions->onDelete();
?>
\ No newline at end of file
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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.
*/
/******************************************
* Begin Form configuration
******************************************/
$tform_def_file = "form/mail_content_filter.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Checking module permissions
if(!stristr($_SESSION["s"]["user"]["modules"],'mail')) {
header("Location: ../index.php");
exit;
}
if(!$_SESSION["s"]["user"]["typ"] == 'admin') die('These Filters are only for Admins.');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
}
$page = new page_action;
$page->onLoad();
?>
\ No newline at end of file
<?php
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/mail_content_filter.list.php";
/******************************************
* End Form configuration
******************************************/
// Checking module permissions
if(!stristr($_SESSION["s"]["user"]["modules"],'mail')) {
header("Location: ../index.php");
exit;
}
$app->uses('listform_actions');
// Limit the results to alias domains
// $app->listform_actions->SQLExtWhere = "type = 'local'";
$app->listform_actions->onLoad();
?>
\ No newline at end of file
<table width="500" border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="frmText11">{tmpl_var name='server_id_txt'}:</td>
<td class="frmText11">
<select name="server_id" class="text">
{tmpl_var name='server_id'}
</select>
</td>
</tr>
<tr>
<td class="frmText11">{tmpl_var name='type_txt'}:</td>
<td class="frmText11">
<select name="type" class="text">
{tmpl_var name='type'}
</select>
</td>
</tr>
<tr>
<td class="frmText11">{tmpl_var name='pattern_txt'}:</td>
<td class="frmText11"><input name="pattern" type="text" class="text" value="{tmpl_var name='pattern'}" size="30" maxlength="255"></td>
</tr>
<tr>
<td class="frmText11">{tmpl_var name='data_txt'}:</td>
<td class="frmText11"><input name="data" type="text" class="text" value="{tmpl_var name='data'}" size="30" maxlength="255"></td>
</tr>
<tr>
<td class="frmText11">{tmpl_var name='action_txt'}:</td>
<td class="frmText11">
<select name="action" class="text">
{tmpl_var name='action'}
</select>
</td>
</tr>
<tr>
<td class="frmText11">{tmpl_var name='active_txt'}:</td>
<td class="frmText11">{tmpl_var name='active'}</td>
</tr> <tr>
<td class="frmText11">&nbsp;</td>
<td class="frmText11">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','mail/mail_content_filter_edit.php');"><div class="buttonEnding"></div>&nbsp;
<input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('mail/mail_content_filter_list.php');"><div class="buttonEnding"></div>
</td>
</tr>
</table>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
\ No newline at end of file
<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
<input type="button" value="{tmpl_var name="add_new_record_txt"}" class="button" onClick="loadContent('mail/mail_content_filter_edit.php');" /><div class="buttonEnding"></div><br /><br />
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="listTable">
<tr>
<td class="tblHead"><tmpl_var name="active_txt"></td>
<td class="tblHead"><tmpl_var name="server_id_txt"></td>
<td class="tblHead"><tmpl_var name="pattern_txt"></td>
<td class="tblHead"><tmpl_var name="action_txt"></td>
<td class="tblHead">&nbsp;</td>
</tr>
<tr>
<td class="frmText11"><select name="search_active" onChange="submitForm('pageForm','mail/mail_content_filter_list.php');">{tmpl_var name='search_active'}</select></td>
<td class="frmText11"><select name="search_server_id" onChange="submitForm('pageForm','mail/mail_content_filter_list.php');">{tmpl_var name='search_server_id'}</select></td>
<td class="frmText11"><input type="text" name="search_pattern" value="{tmpl_var name='search_pattern'}" class="text" /></td>
<td class="frmText11"><select name="search_action" onChange="submitForm('pageForm','mail/mail_content_filter_list.php');">{tmpl_var name='search_action'}</select></td>
<td class="frmText11" align="right"><input name="Filter" type="button" id="Filter" value="{tmpl_var name="filter_txt"}" class="button" onClick="submitForm('pageForm','mail/mail_content_filter_list.php');"><div class="buttonEnding"></div></td>
</tr>
<tmpl_loop name="records">
<tr bgcolor="{tmpl_var name="bgcolor"}">
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_content_filter_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="active"}</a></td>
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_content_filter_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="server_id"}</a></td>
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_content_filter_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="pattern"}</a></td>
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_content_filter_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="action"}</a></td>
<td class="frmText11" align="right">[<a href="javascript: del_record('mail/mail_content_filter_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}');" class="frmText11">{tmpl_var name='delete_txt'}</a>]</td>
</tr>
</tmpl_loop>
<tr>
<td colspan="5" height="40" align="center" class="tblFooter"><tmpl_var name="paging"></td>
</tr>
</table>
\ No newline at end of file
......@@ -49,7 +49,10 @@ class mail_module {
'mail_transport_delete',
'mail_get_insert',
'mail_get_update',
'mail_get_delete');
'mail_get_delete',
'mail_content_filter_insert',
'mail_content_filter_update',
'mail_content_filter_delete');
/*
This function is called when the module is loaded
......@@ -81,6 +84,7 @@ class mail_module {
$app->modules->registerTableHook('mail_transport','mail_module','process');
$app->modules->registerTableHook('mail_user','mail_module','process');
$app->modules->registerTableHook('mail_get','mail_module','process');
$app->modules->registerTableHook('mail_content_filter','mail_module','process');
}
......@@ -123,6 +127,11 @@ class mail_module {