---- Changes since 1.410 ----
Added the SMTP Client Restrictions page, and replaced some oddly-designed UI fields on the SMTP Server Options page to it with more Webmin-standard inputs for configuring RBLs and client access.
Updated the BCC Mappings page to allow both sender and recipient maps to be defined and edited.
+---- Changes since 1.420 ----
+Properly handle multiple reject_rbl_client DNS domains on the SMTP Client Restrictions page.
print &ui_form_start("save_client.cgi", "post");
print &ui_table_start($text{'client_title'}, undef, 2);
-# Parse current settings
+# Parse current settings, by building a map from names to indexes
@opts = split(/[\s,]+/, &get_current_value('smtpd_client_restrictions'));
for(my $i=0; $i<@opts; $i++) {
- $opts{$opts[$i]} = $i;
+ $opts{$opts[$i]} ||= [ ];
+ push(@{$opts{$opts[$i]}}, $i);
}
# Add binary restrictions to list
# Add restrictions with values
foreach $r (&list_multi_client_restrictions()) {
- $v = $opts{$r};
+ @v = @{$opts{$r}};
+ $vals = undef;
+ if (scalar(@v)) {
+ $vals = join(" ", map { $opts[$_+1] } @v);
+ }
push(@grid, &ui_checkbox("client", $r, $text{'sasl_'.$r},
- defined($v)),
- &ui_textbox("value_$r",
- defined($v) ? $opts[$v+1] : undef, 40).
+ scalar(@v)),
+ &ui_textbox("value_$r", $vals, 40).
($r eq "check_client_access" ?
" ".&map_chooser_button("value_$r", $r) : ""));
$done{$r} = 1;
- $done{$opts[$v+1]} = 1;
+ foreach $v (@v) {
+ $done{$opts[$v+1]} = 1;
+ }
if ($r eq "check_client_access" && defined($v)) {
# Can show client access map
$has_client_access = 1;
{
local ($file) = @_;
local %rv;
-local $lref = &read_file_lines($file);
+local $lref = &read_file_lines($file, 1);
foreach my $l (@$lref) {
if ($l =~ /^\s*([a-z0-9\_]+)\s*=\s*(.*)/i) {
$rv{$1} = $2;
# Save options with values
foreach $o (&list_multi_client_restrictions()) {
- $idx = &indexof($o, @opts);
+ # Find all current positions
+ local @pos;
+ for(my $i=0; $i<@opts; $i++) {
+ push(@pos, $i) if ($opts[$i] eq $o);
+ }
+
+ # Make sure something was entered
if ($newopts{$o}) {
- $in{"value_$o"} =~ /^\S+$/ ||
+ $in{"value_$o"} =~ /\S/ ||
&error(&text('client_evalue', $text{'sasl_'.$o}));
}
- if ($newopts{$o} && !$oldopts{$o}) {
- # Add to end
- push(@opts, $o, $in{"value_$o"});
- }
- elsif ($newopts{$o} && $oldopts{$o}) {
- # Update value
- $opts[$idx+1] = $in{"value_$o"};
- }
- elsif (!$newopts{$o} && $oldopts{$o}) {
- # Remove and value
- splice(@opts, $idx, 2);
+
+ # Sync with values entered
+ @v = split(/\s+/, $in{"value_$o"});
+ for(my $i=0; $i<@pos || $i<@v; $i++) {
+ if ($i<@pos && $i<@v) {
+ # Updating a value
+ $opts[$pos[$i]+1] = $v[$i];
+ }
+ elsif ($i<@pos && $i>=@v) {
+ # Removing a value
+ splice(@opts, $pos[$i], 2);
+ }
+ elsif ($i>=@pos && $i<@v) {
+ # Adding a value, at the end
+ push(@opts, $o, $v[$i]);
+ }
}
}
- &set_current_value("smtpd_client_restrictions",
- join(" ", &unique(@opts)));
+ &set_current_value("smtpd_client_restrictions", join(" ", @opts));
}
&unlock_postfix_files();