Skip to content

Commit a296ae3

Browse files
author
marknl
committed
FS#553 - option to add RBL entries
1 parent c930e0a commit a296ae3

File tree

6 files changed

+47
-4
lines changed

6 files changed

+47
-4
lines changed

install/lib/installer_base.lib.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,21 @@ public function configure_postfix($options = '') {
625625
$command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
626626
if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
627627

628+
$server_ini_rec = $this->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']);
629+
$server_ini_array = ini_to_array(stripslashes($server_ini_rec['config']));
630+
unset($server_ini_rec);
631+
632+
//* If there are RBL's defined, format the list and add them to smtp_recipient_restrictions to prevent removeal after an update
633+
$rbl_list = '';
634+
if ($server_ini_array['mail']['realtime_blackhole_list'] != '') {
635+
$rbl_hosts = explode(",",str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list']));
636+
foreach ($rbl_hosts as $key => $value) {
637+
$rbl_list .= ", reject_rbl_client ". $value;
638+
}
639+
}
640+
unset($rbl_hosts);
641+
unset($server_ini_array);
642+
628643
$postconf_commands = array (
629644
'myhostname = '.$conf['hostname'],
630645
'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain',
@@ -641,7 +656,7 @@ public function configure_postfix($options = '') {
641656
'smtpd_sasl_auth_enable = yes',
642657
'broken_sasl_auth_clients = yes',
643658
'smtpd_sasl_authenticated_header = yes',
644-
'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination',
659+
'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination'. $rbl_list,
645660
'smtpd_use_tls = yes',
646661
'smtpd_tls_security_level = may',
647662
'smtpd_tls_cert_file = '.$config_dir.'/smtpd.cert',

install/tpl/server.ini.master

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ relayhost_user=
3030
relayhost_password=
3131
mailbox_size_limit=0
3232
message_size_limit=0
33+
realtime_blackhole_list=
3334

3435
[getmail]
3536
getmail_config_dir=/etc/getmail

interface/web/admin/form/server_config.tform.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,14 @@
282282
'width' => '10',
283283
'maxlength' => '15'
284284
),
285+
'realtime_blackhole_list' => array(
286+
'datatype' => 'VARCHAR',
287+
'formtype' => 'TEXT',
288+
'default' => '',
289+
'value' => '',
290+
'width' => '40',
291+
'maxlength' => '255'
292+
),
285293
##################################
286294
# ENDE Datatable fields
287295
##################################

interface/web/admin/lib/lang/en_server_config.lng

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,6 @@ $wb["do_not_try_rescue_mysql_txt"] = 'Disable MySQL monitoring';
149149
$wb["do_not_try_rescue_mail_txt"] = 'Disable Email monitoring';
150150
$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!';
151151
$wb["enable_sni_txt"] = 'Enable SNI';
152-
152+
$wb["realtime_blackhole_list_txt"] = 'Real-time Blackhole List';
153+
$wb["realtime_blackhole_list_note_txt"] = '(Separate RBL\'s with commas)';
153154
?>

interface/web/admin/templates/server_config_mail_edit.htm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ <h2><tmpl_var name="list_head_txt"></h2>
7171
<label for="message_size_limit">{tmpl_var name='message_size_limit_txt'}</label>
7272
<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" />&nbsp;MB
7373
</div>
74+
<div class="ctrlHolder">
75+
<label for="realtime_blackhole_list">{tmpl_var name='realtime_blackhole_list_txt'}</label>
76+
<input name="realtime_blackhole_list" id="realtime_blackhole_list" value="{tmpl_var name='realtime_blackhole_list'}" size="40" maxlength="255" type="text" class="textInput" />&nbsp;{tmpl_var name='realtime_blackhole_list_note_txt'}
77+
</div>
7478
</fieldset>
7579

7680
<input type="hidden" name="id" value="{tmpl_var name='id'}">
@@ -80,5 +84,4 @@ <h2><tmpl_var name="list_head_txt"></h2>
8084
<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>
8185
</div>
8286
</div>
83-
8487
</div>

server/plugins-available/postfix_server_plugin.inc.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,22 @@ function update($event_name,$data) {
106106
} else {
107107
exec("postconf -e 'relayhost ='");
108108
}
109-
109+
110+
if($mail_config['realtime_blackhole_list'] != '') {
111+
$rbl_hosts = explode(",",str_replace(" ", "", $mail_config['realtime_blackhole_list']));
112+
$options = explode(", ", exec("postconf -h smtpd_recipient_restrictions"));
113+
foreach ($options as $key => $value) {
114+
if (!preg_match('/reject_rbl_client/', $value)) {
115+
$new_options[] = $value;
116+
}
117+
}
118+
foreach ($rbl_hosts as $key => $value) {
119+
$new_options[] = "reject_rbl_client ".$value;
120+
}
121+
122+
exec("postconf -e 'smtpd_recipient_restrictions = ".implode(", ", $new_options)."'");
123+
}
124+
110125
exec("postconf -e 'mailbox_size_limit = ".intval($mail_config['mailbox_size_limit']*1024*1024)."'");
111126
exec("postconf -e 'message_size_limit = ".intval($mail_config['message_size_limit']*1024*1024)."'");
112127

0 commit comments

Comments
 (0)