Skip to content

Commit 54fb593

Browse files
committed
Added postfix header- and body check filters.
1 parent 63e63f6 commit 54fb593

15 files changed

+517
-12
lines changed

install/lib/installer_base.lib.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,20 @@ function configure_postfix($options = '') {
284284
'smtpd_client_restrictions = check_client_access mysql:'.$conf["dist_postfix_config_dir"].'/mysql-virtual_client.cf',
285285
'maildrop_destination_concurrency_limit = 1',
286286
'maildrop_destination_recipient_limit = 1',
287-
'virtual_transport = maildrop'
287+
'virtual_transport = maildrop',
288+
'header_checks = regexp:/etc/postfix/header_checks',
289+
'mime_header_checks = regexp:/etc/postfix/mime_header_checks',
290+
'nested_header_checks = regexp:/etc/postfix/nested_header_checks',
291+
'body_checks = regexp:/etc/postfix/body_checks'
288292
);
289293

294+
// Create the header ynd body check files
295+
touch('/etc/postfix/header_checks');
296+
touch('/etc/postfix/mime_header_checks');
297+
touch('/etc/postfix/nested_header_checks');
298+
touch('/etc/postfix/body_checks');
299+
300+
290301
// Make a backup copy of the main.cf file
291302
copy($conf["dist_postfix_config_dir"].'/main.cf',$conf["dist_postfix_config_dir"].'/main.cf~');
292303

install/sql/ispconfig3.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,28 @@ CREATE TABLE `mail_access` (
183183
--
184184

185185

186+
-- --------------------------------------------------------
187+
188+
--
189+
-- Tabellenstruktur für Tabelle `mail_content_filter`
190+
--
191+
192+
CREATE TABLE `mail_content_filter` (
193+
`content_filter_id` bigint(20) NOT NULL auto_increment,
194+
`sys_userid` int(11) NOT NULL default '0',
195+
`sys_groupid` int(11) NOT NULL default '0',
196+
`sys_perm_user` varchar(5) default NULL,
197+
`sys_perm_group` varchar(5) default NULL,
198+
`sys_perm_other` varchar(5) default NULL,
199+
`server_id` int(11) NOT NULL default '0',
200+
`type` varchar(255) default NULL,
201+
`pattern` varchar(255) default NULL,
202+
`data` varchar(255) default NULL,
203+
`action` varchar(255) default NULL,
204+
`active` varchar(255) NOT NULL default 'y',
205+
PRIMARY KEY (`content_filter_id`)
206+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
207+
186208
-- --------------------------------------------------------
187209

188210
--

install/tpl/config.inc.php.master

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ini_set('register_globals',0);
3535

3636
$conf["app_title"] = "ISPConfig";
3737
$conf["app_version"] = "3.0.0";
38+
$conf["modules_available"] = "admin,mail,sites,monitor,client,dns";
39+
40+
/*
41+
Server variables
42+
*/
43+
3844
$conf["server_id"] = "{server_id}";
3945

4046

@@ -100,18 +106,9 @@ $conf["start_db"] = true;
100106
$conf["start_session"] = true;
101107

102108
/*
103-
DNS Settings
109+
Constants
104110
*/
105111

106-
$conf["auto_create_ptr"] = 1; // Automatically create PTR records?
107-
$conf["default_ns"] = 'ns1.example.com.'; // must be set if $conf['auto_create_ptr'] is 1. Don't forget the trailing dot!
108-
$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!
109-
$conf["default_ttl"] = 86400;
110-
$conf["default_refresh"] = 28800;
111-
$conf["default_retry"] = 7200;
112-
$conf["default_expire"] = 604800;
113-
$conf["default_minimum_ttl"] = 86400;
114-
115112
define("LOGLEVEL_DEBUG",0);
116113
define("LOGLEVEL_WARN",1);
117114
define("LOGLEVEL_ERROR",2);

interface/lib/config.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
$conf["app_title"] = "ISPConfig";
3737
$conf["app_version"] = "3.0.0";
38+
$conf["modules_available"] = "admin,mail,sites,monitor,client,dns";
3839

3940

4041
/*
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?php
2+
3+
/*
4+
Form Definition
5+
6+
Tabledefinition
7+
8+
Datatypes:
9+
- INTEGER (Forces the input to Int)
10+
- DOUBLE
11+
- CURRENCY (Formats the values to currency notation)
12+
- VARCHAR (no format check, maxlength: 255)
13+
- TEXT (no format check)
14+
- DATE (Dateformat, automatic conversion to timestamps)
15+
16+
Formtype:
17+
- TEXT (Textfield)
18+
- TEXTAREA (Textarea)
19+
- PASSWORD (Password textfield, input is not shown when edited)
20+
- SELECT (Select option field)
21+
- RADIO
22+
- CHECKBOX
23+
- CHECKBOXARRAY
24+
- FILE
25+
26+
VALUE:
27+
- Wert oder Array
28+
29+
Hint:
30+
The ID field of the database table is not part of the datafield definition.
31+
The ID field must be always auto incement (int or bigint).
32+
33+
34+
*/
35+
36+
$form["title"] = "Mail Content Filter";
37+
$form["description"] = "";
38+
$form["name"] = "mail_content_filter";
39+
$form["action"] = "mail_content_filter_edit.php";
40+
$form["db_table"] = "mail_content_filter";
41+
$form["db_table_idx"] = "content_filter_id";
42+
$form["db_history"] = "yes";
43+
$form["tab_default"] = "filter";
44+
$form["list_default"] = "mail_content_filter_list.php";
45+
$form["auth"] = 'yes'; // yes / no
46+
47+
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
48+
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
49+
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
50+
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
51+
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
52+
53+
$form["tabs"]['filter'] = array (
54+
'title' => "Filter",
55+
'width' => 100,
56+
'template' => "templates/mail_content_filter_edit.htm",
57+
'fields' => array (
58+
##################################
59+
# Begin Datatable fields
60+
##################################
61+
'server_id' => array (
62+
'datatype' => 'INTEGER',
63+
'formtype' => 'SELECT',
64+
'default' => '',
65+
'datasource' => array ( 'type' => 'SQL',
66+
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
67+
'keyfield'=> 'server_id',
68+
'valuefield'=> 'server_name'
69+
),
70+
'value' => ''
71+
),
72+
'type' => array (
73+
'datatype' => 'VARCHAR',
74+
'formtype' => 'SELECT',
75+
'default' => '',
76+
'value' => array('header' => 'Header Filter','body' => 'Body Filter','mime_header' => 'MIME-Header Filter','nested_header' => 'Nested-Header Filter')
77+
),
78+
'pattern' => array (
79+
'datatype' => 'VARCHAR',
80+
'formtype' => 'TEXT',
81+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
82+
'errmsg'=> 'pattern_error_empty'),
83+
),
84+
'default' => '',
85+
'value' => '',
86+
'width' => '30',
87+
'maxlength' => '255'
88+
),
89+
'data' => array (
90+
'datatype' => 'VARCHAR',
91+
'formtype' => 'TEXT',
92+
'default' => '',
93+
'value' => '',
94+
'width' => '30',
95+
'maxlength' => '255'
96+
),
97+
'action' => array (
98+
'datatype' => 'VARCHAR',
99+
'formtype' => 'SELECT',
100+
'default' => '',
101+
'value' => array('DISCARD' => 'DISCARD','DUNNO'=>'DUNNO','FILTER'=>'FILTER','HOLD'=>'HOLD','IGNORE'=>'IGNORE','PREPEND'=>'PREPEND','REDIRECT'=>'REDIRECT','REPLACE'=>'REPLACE','REJECT'=>'REJECT','WARN'=>'WARN')
102+
),
103+
'active' => array (
104+
'datatype' => 'VARCHAR',
105+
'formtype' => 'CHECKBOX',
106+
'default' => 'y',
107+
'value' => array(0 => 'n',1 => 'y')
108+
),
109+
##################################
110+
# ENDE Datatable fields
111+
##################################
112+
)
113+
);
114+
115+
116+
?>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
$wb["server_id_txt"] = 'Server';
3+
$wb["type_txt"] = 'Filter';
4+
$wb["pattern_txt"] = 'Regexp. Pattern';
5+
$wb["data_txt"] = 'Data';
6+
$wb["action_txt"] = 'Action';
7+
$wb["active_txt"] = 'Active';
8+
$wb["btn_save_txt"] = 'Save';
9+
$wb["btn_cancel_txt"] = 'Cancel';
10+
?>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
$wb["list_head_txt"] = 'Postfix Header and Body Checks';
3+
$wb["active_txt"] = 'Active';
4+
$wb["server_id_txt"] = 'Server';
5+
$wb["pattern_txt"] = 'Pattern';
6+
$wb["action_txt"] = 'Action';
7+
$wb["page_txt"] = 'Page';
8+
$wb["page_of_txt"] = 'of';
9+
$wb["page_next_txt"] = 'Next';
10+
$wb["page_back_txt"] = 'Back';
11+
$wb["delete_txt"] = 'Delete';
12+
$wb["filter_txt"] = 'Filter';
13+
$wb["add_new_record_txt"] = 'Add new Content Filter';
14+
?>

interface/web/mail/lib/module.conf.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
$items[] = array( 'title' => "Postfix Blacklist",
102102
'target' => 'content',
103103
'link' => 'mail/mail_blacklist_list.php');
104+
105+
$items[] = array( 'title' => "Content Filter",
106+
'target' => 'content',
107+
'link' => 'mail/mail_content_filter_list.php');
104108

105109
$module["nav"][] = array( 'title' => 'Global Filters',
106110
'open' => 1,
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
3+
/*
4+
Datatypes:
5+
- INTEGER
6+
- DOUBLE
7+
- CURRENCY
8+
- VARCHAR
9+
- TEXT
10+
- DATE
11+
*/
12+
13+
14+
15+
// Name of the list
16+
$liste["name"] = "mail_content_filter";
17+
18+
// Database table
19+
$liste["table"] = "mail_content_filter";
20+
21+
// Index index field of the database table
22+
$liste["table_idx"] = "content_filter_id";
23+
24+
// Search Field Prefix
25+
$liste["search_prefix"] = "search_";
26+
27+
// Records per page
28+
$liste["records_per_page"] = 15;
29+
30+
// Script File of the list
31+
$liste["file"] = "mail_content_filter_list.php";
32+
33+
// Script file of the edit form
34+
$liste["edit_file"] = "mail_content_filter_edit.php";
35+
36+
// Script File of the delete script
37+
$liste["delete_file"] = "mail_content_filter_del.php";
38+
39+
// Paging Template
40+
$liste["paging_tpl"] = "templates/paging.tpl.htm";
41+
42+
// Enable auth
43+
$liste["auth"] = "yes";
44+
45+
46+
/*****************************************************
47+
* Suchfelder
48+
*****************************************************/
49+
50+
51+
$liste["item"][] = array( 'field' => "active",
52+
'datatype' => "VARCHAR",
53+
'formtype' => "SELECT",
54+
'op' => "=",
55+
'prefix' => "",
56+
'suffix' => "",
57+
'width' => "",
58+
'value' => array('y' => "Yes",'n' => "No"));
59+
60+
61+
$liste["item"][] = array( 'field' => "server_id",
62+
'datatype' => "VARCHAR",
63+
'formtype' => "SELECT",
64+
'op' => "like",
65+
'prefix' => "%",
66+
'suffix' => "%",
67+
'datasource' => array ( 'type' => 'SQL',
68+
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
69+
'keyfield'=> 'server_id',
70+
'valuefield'=> 'server_name'
71+
),
72+
'width' => "",
73+
'value' => "");
74+
75+
$liste["item"][] = array( 'field' => "pattern",
76+
'datatype' => "VARCHAR",
77+
'formtype' => "TEXT",
78+
'op' => "like",
79+
'prefix' => "%",
80+
'suffix' => "%",
81+
'width' => "",
82+
'value' => "");
83+
84+
$liste["item"][] = array( 'field' => "action",
85+
'datatype' => "VARCHAR",
86+
'formtype' => "SELECT",
87+
'op' => "like",
88+
'prefix' => "%",
89+
'suffix' => "%",
90+
'width' => "",
91+
'value' => array('DISCARD' => 'DISCARD','DUNNO'=>'DUNNO','FILTER'=>'FILTER','HOLD'=>'HOLD','IGNORE'=>'IGNORE','PREPEND'=>'PREPEND','REDIRECT'=>'REDIRECT','REPLACE'=>'REPLACE','REJECT'=>'REJECT','WARN'=>'WARN'));
92+
93+
94+
95+
?>

0 commit comments

Comments
 (0)