From a296ae3c2e89468a191d134b3d360f817e0a9119 Mon Sep 17 00:00:00 2001 From: marknl <marknl@ispconfig3> Date: Fri, 30 Sep 2011 06:17:01 -0400 Subject: [PATCH] FS#553 - option to add RBL entries --- install/lib/installer_base.lib.php | 17 ++++++++++++++++- interface/web/admin/lib/lang/en_server_config.lng | 3 ++- install/tpl/server.ini.master | 1 + server/plugins-available/postfix_server_plugin.inc.php | 17 ++++++++++++++++- interface/web/admin/templates/server_config_mail_edit.htm | 5 ++++- interface/web/admin/form/server_config.tform.php | 8 ++++++++ 6 files changed, 47 insertions(+), 4 deletions(-) diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index a4ec514..4167f0e 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -625,6 +625,21 @@ $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 @@ '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 469823c..d7a27e0 100644 --- a/install/tpl/server.ini.master +++ b/install/tpl/server.ini.master @@ -30,6 +30,7 @@ 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 fe2a1c6..1c46831 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -282,6 +282,14 @@ '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 ec91e01..956abdd 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_mail_txt"] = 'Disable Email monitoring'; $wb["rescue_description_txt"] = '<b>Information:</b> If you want to shut down mysql you have to select the "Disable MySQL monitor" checkbox and then wait 2-3 minutes.<br>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 94dff00..11399b3 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 @@ <label for="message_size_limit">{tmpl_var name='message_size_limit_txt'}</label> <input name="message_size_limit" id="message_size_limit" value="{tmpl_var name='message_size_limit'}" size="10" maxlength="15" type="text" class="textInput formLengthLimit" /> MB </div> + <div class="ctrlHolder"> + <label for="realtime_blackhole_list">{tmpl_var name='realtime_blackhole_list_txt'}</label> + <input name="realtime_blackhole_list" id="realtime_blackhole_list" value="{tmpl_var name='realtime_blackhole_list'}" size="40" maxlength="255" type="text" class="textInput" /> {tmpl_var name='realtime_blackhole_list_note_txt'} + </div> </fieldset> <input type="hidden" name="id" value="{tmpl_var name='id'}"> @@ -80,5 +84,4 @@ <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_config_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button> </div> </div> - </div> diff --git a/server/plugins-available/postfix_server_plugin.inc.php b/server/plugins-available/postfix_server_plugin.inc.php index e426eb1..98dd675 100644 --- a/server/plugins-available/postfix_server_plugin.inc.php +++ b/server/plugins-available/postfix_server_plugin.inc.php @@ -106,7 +106,22 @@ } 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)."'"); -- Gitblit v1.9.1