From a296ae3c2e89468a191d134b3d360f817e0a9119 Mon Sep 17 00:00:00 2001 From: marknl Date: Fri, 30 Sep 2011 10:17:01 +0000 Subject: [PATCH] FS#553 - option to add RBL entries --- install/lib/installer_base.lib.php | 17 ++++++++++++++++- install/tpl/server.ini.master | 1 + .../web/admin/form/server_config.tform.php | 8 ++++++++ .../web/admin/lib/lang/en_server_config.lng | 3 ++- .../admin/templates/server_config_mail_edit.htm | 5 ++++- .../postfix_server_plugin.inc.php | 17 ++++++++++++++++- 6 files changed, 47 insertions(+), 4 deletions(-) diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index a4ec514db3..4167f0ee96 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -625,6 +625,21 @@ class installer_base { $command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m'; if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); + $server_ini_rec = $this->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']); + $server_ini_array = ini_to_array(stripslashes($server_ini_rec['config'])); + unset($server_ini_rec); + + //* If there are RBL's defined, format the list and add them to smtp_recipient_restrictions to prevent removeal after an update + $rbl_list = ''; + if ($server_ini_array['mail']['realtime_blackhole_list'] != '') { + $rbl_hosts = explode(",",str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list'])); + foreach ($rbl_hosts as $key => $value) { + $rbl_list .= ", reject_rbl_client ". $value; + } + } + unset($rbl_hosts); + unset($server_ini_array); + $postconf_commands = array ( 'myhostname = '.$conf['hostname'], 'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain', @@ -641,7 +656,7 @@ class installer_base { 'smtpd_sasl_auth_enable = yes', 'broken_sasl_auth_clients = yes', 'smtpd_sasl_authenticated_header = yes', - 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination', + 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination'. $rbl_list, 'smtpd_use_tls = yes', 'smtpd_tls_security_level = may', 'smtpd_tls_cert_file = '.$config_dir.'/smtpd.cert', diff --git a/install/tpl/server.ini.master b/install/tpl/server.ini.master index 469823c6b3..d7a27e01a7 100644 --- a/install/tpl/server.ini.master +++ b/install/tpl/server.ini.master @@ -30,6 +30,7 @@ relayhost_user= relayhost_password= mailbox_size_limit=0 message_size_limit=0 +realtime_blackhole_list= [getmail] getmail_config_dir=/etc/getmail diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php index fe2a1c66e5..1c46831716 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -282,6 +282,14 @@ $form["tabs"]['mail'] = array( 'width' => '10', 'maxlength' => '15' ), + 'realtime_blackhole_list' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '40', + 'maxlength' => '255' + ), ################################## # ENDE Datatable fields ################################## diff --git a/interface/web/admin/lib/lang/en_server_config.lng b/interface/web/admin/lib/lang/en_server_config.lng index ec91e01c66..956abdd818 100644 --- a/interface/web/admin/lib/lang/en_server_config.lng +++ b/interface/web/admin/lib/lang/en_server_config.lng @@ -149,5 +149,6 @@ $wb["do_not_try_rescue_mysql_txt"] = 'Disable MySQL monitoring'; $wb["do_not_try_rescue_mail_txt"] = 'Disable Email monitoring'; $wb["rescue_description_txt"] = 'Information: If you want to shut down mysql you have to select the "Disable MySQL monitor" checkbox and then wait 2-3 minutes.
if you do not wait 2-3 minutes, rescue will try to restart mysql!'; $wb["enable_sni_txt"] = 'Enable SNI'; - +$wb["realtime_blackhole_list_txt"] = 'Real-time Blackhole List'; +$wb["realtime_blackhole_list_note_txt"] = '(Separate RBL\'s with commas)'; ?> \ No newline at end of file diff --git a/interface/web/admin/templates/server_config_mail_edit.htm b/interface/web/admin/templates/server_config_mail_edit.htm index 94dff00459..11399b319e 100644 --- a/interface/web/admin/templates/server_config_mail_edit.htm +++ b/interface/web/admin/templates/server_config_mail_edit.htm @@ -71,6 +71,10 @@  MB +
+ +  {tmpl_var name='realtime_blackhole_list_note_txt'} +
@@ -80,5 +84,4 @@ - diff --git a/server/plugins-available/postfix_server_plugin.inc.php b/server/plugins-available/postfix_server_plugin.inc.php index e426eb156d..98dd675164 100644 --- a/server/plugins-available/postfix_server_plugin.inc.php +++ b/server/plugins-available/postfix_server_plugin.inc.php @@ -106,7 +106,22 @@ class postfix_server_plugin { } else { exec("postconf -e 'relayhost ='"); } - + + if($mail_config['realtime_blackhole_list'] != '') { + $rbl_hosts = explode(",",str_replace(" ", "", $mail_config['realtime_blackhole_list'])); + $options = explode(", ", exec("postconf -h smtpd_recipient_restrictions")); + foreach ($options as $key => $value) { + if (!preg_match('/reject_rbl_client/', $value)) { + $new_options[] = $value; + } + } + foreach ($rbl_hosts as $key => $value) { + $new_options[] = "reject_rbl_client ".$value; + } + + exec("postconf -e 'smtpd_recipient_restrictions = ".implode(", ", $new_options)."'"); + } + exec("postconf -e 'mailbox_size_limit = ".intval($mail_config['mailbox_size_limit']*1024*1024)."'"); exec("postconf -e 'message_size_limit = ".intval($mail_config['message_size_limit']*1024*1024)."'"); -- GitLab