Completed re-write of SMTP Client Restrictions page

This commit is contained in:
Jamie Cameron 2008-04-10 07:00:55 +00:00
parent 90b7d17537
commit a63daa2724
7 changed files with 89 additions and 8 deletions

View File

@ -52,3 +52,5 @@ Added more SMTP relaying restrictions.
Outgoing email from selected addresses and domains can now be BCCd automatically using the new BCC Mapping page. Outgoing email from selected addresses and domains can now be BCCd automatically using the new BCC Mapping page.
---- Changes since 1.400 ---- ---- Changes since 1.400 ----
Changed the default LDAP class for maps to inetLocalMailRecipient. Changed the default LDAP class for maps to inetLocalMailRecipient.
---- 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.

View File

@ -1,8 +1,6 @@
#!/usr/local/bin/perl #!/usr/local/bin/perl
# A single page just for editing smtpd_client_restrictions # A single page just for editing smtpd_client_restrictions
# XXX editing access maps? # XXX editing access maps?
# XXX maps rbl parameters
# XXX icon
require './postfix-lib.pl'; require './postfix-lib.pl';
@ -33,16 +31,23 @@ foreach $r (&list_client_restrictions()) {
# Add restrictions with values # Add restrictions with values
foreach $r (&list_multi_client_restrictions()) { foreach $r (&list_multi_client_restrictions()) {
$v = $opts{$r};
push(@grid, &ui_checkbox("client", $r, $text{'sasl_'.$r}, push(@grid, &ui_checkbox("client", $r, $text{'sasl_'.$r},
defined($v)), defined($v)),
&ui_textbox("value_$r", &ui_textbox("value_$r",
defined($v) ? $opts[$v+1] : undef, 40). defined($v) ? $opts[$v+1] : undef, 40).
($r eq "check_client_access" ? ($r eq "check_client_access" ?
" ".&map_chooser_button("value_$r", $r) : "")); " ".&map_chooser_button("value_$r", $r) : ""));
$done{$r} = 1;
$done{$opts[$v+1]} = 1;
if ($r eq "check_client_access" && defined($v)) {
# Can show client access map
$has_client_access = 1;
}
} }
# Show text field for the rest # Show text field for the rest
@rest = grep { !$done{$o} } @opts; @rest = grep { !$done{$_} } @opts;
if (@rest) { if (@rest) {
push(@grid, &ui_checkbox("other", 1, $text{'client_other'}, 1), push(@grid, &ui_checkbox("other", 1, $text{'client_other'}, 1),
&ui_textbox("other_list", join(" ", @rest), 40)); &ui_textbox("other_list", join(" ", @rest), 40));
@ -58,4 +63,13 @@ print &ui_table_row($text{'client_restrict'},
print &ui_table_end(); print &ui_table_end();
print &ui_form_end([ [ undef, $text{'save'} ] ]); print &ui_form_end([ [ undef, $text{'save'} ] ]);
if ($has_client_access) {
print "<hr>\n";
&generate_map_edit("smtpd_client_restrictions:check_client_access",
$text{'map_click'}." ".
"<font size=\"-1\">".&hlink("$text{'help_map_format'}",
"access")."</font>\n<br>\n", 1,
$text{'mapping_client'}, $text{'header_value'});
}
&ui_print_footer("", $text{'index_return'}); &ui_print_footer("", $text{'index_return'});

View File

@ -107,8 +107,8 @@ elsif ($in{'map_name'} eq 'header_checks') {
elsif ($in{'map_name'} eq 'body_checks') { elsif ($in{'map_name'} eq 'body_checks') {
&ui_print_footer("body.cgi", $text{'body_return'}); &ui_print_footer("body.cgi", $text{'body_return'});
} }
elsif ($in{'map_name'} =~ /check_sender_access/) { elsif ($in{'map_name'} =~ /^smtpd_client_restrictions:/) {
&ui_print_footer("edit_access.cgi?name=smtpd_client_restrictions:check_sender_access&title=Check sender access mapping table", $text{'access_return'}); &ui_print_footer("client.cgi", $text{'client_return'});
} }
else { else {
&ui_print_footer("", $text{'index_return'}); &ui_print_footer("", $text{'index_return'});

BIN
postfix/images/client.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -262,7 +262,7 @@ opts_delay_warning_time=Time in hours before sending a warning for no delivery
opts_delay_warning_time_default=Disabled opts_delay_warning_time_default=Disabled
opts_content_filter_default=None opts_content_filter_default=None
smtpd_title=SMTP server options smtpd_title=SMTP Server Options
smtpd_ecannot=You are not allowed to edit the SMTP server options smtpd_ecannot=You are not allowed to edit the SMTP server options
opts_disable_vrfy_command=Disable SMTP VRFY command opts_disable_vrfy_command=Disable SMTP VRFY command
opts_smtpd_banner=SMTP greeting banner opts_smtpd_banner=SMTP greeting banner
@ -290,7 +290,7 @@ opts_unknown_client_reject_code=SMTP server response on unknown client reject
opts_unknown_hostname_reject_code=SMTP server response on unknown hostname reject opts_unknown_hostname_reject_code=SMTP server response on unknown hostname reject
smtp_title=SMTP client options smtp_title=SMTP Client Options
smtp_ecannot=You are not allowed to edit the SMTP client options smtp_ecannot=You are not allowed to edit the SMTP client options
opts_best_mx_transport=Action when listed as best MX host opts_best_mx_transport=Action when listed as best MX host
opts_best_mx_transport_default=Default (bounce message) opts_best_mx_transport_default=Default (bounce message)
@ -761,6 +761,8 @@ log_start=Started Postfix server
log_delqs=Deleted $1 messages from mail queue log_delqs=Deleted $1 messages from mail queue
log_flushq=Flushed mail queue log_flushq=Flushed mail queue
log_backend=Updated configuration file for map $1 log_backend=Updated configuration file for map $1
log_sasl=Changed SMTP authentication and encryption
log_client=Changed SMTP client restrictions
sasl_title=SMTP Authentication And Encryption sasl_title=SMTP Authentication And Encryption
opts_smtpd_sasl_auth_enable=Enable SASL SMTP authentication? opts_smtpd_sasl_auth_enable=Enable SASL SMTP authentication?
@ -798,6 +800,9 @@ client_restrict=Client restrictions
client_restrict1=Postfix default (allow all clients) client_restrict1=Postfix default (allow all clients)
client_restrict0=Selected below .. client_restrict0=Selected below ..
client_other=Other restrictions : client_other=Other restrictions :
client_err=Failed to save client restrictions
client_evalue=Missing value for restriction $1
client_return=SMTP client restrictions
chooser_title=Select Map Source chooser_title=Select Map Source
chooser_header=Map source $1 chooser_header=Map source $1

View File

@ -1592,7 +1592,7 @@ elsif ($map_name =~ /relocated/) { &redirect("relocated.cgi"); }
elsif ($map_name =~ /header/) { &redirect("header.cgi"); } elsif ($map_name =~ /header/) { &redirect("header.cgi"); }
elsif ($map_name =~ /body/) { &redirect("body.cgi"); } elsif ($map_name =~ /body/) { &redirect("body.cgi"); }
elsif ($map_name =~ /sender_bcc/) { &redirect("bcc.cgi"); } elsif ($map_name =~ /sender_bcc/) { &redirect("bcc.cgi"); }
elsif ($map_name =~ /sender_access/) { &redirect("edit_access.cgi?name=smtpd_client_restrictions:check_sender_access&title=Check+sender+access+mapping+table"); } elsif ($map_name =~ /^smtpd_client_restrictions:/) { &redirect("client.cgi"); }
else { &redirect(""); } else { &redirect(""); }
} }

60
postfix/save_client.cgi Executable file
View File

@ -0,0 +1,60 @@
#!/usr/local/bin/perl
# Save SMTP authentication options
require './postfix-lib.pl';
&ReadParse();
$access{'client'} || &error($text{'opts_ecannot'});
&error_setup($text{'client_err'});
&lock_postfix_files();
# Save client options
@opts = split(/[\s,]+/, &get_current_value("smtpd_client_restrictions"));
%oldopts = map { $_, 1 } @opts;
%newopts = map { $_, 1 } split(/\0/, $in{'client'});
# Save boolean options
foreach $o (&list_client_restrictions()) {
if ($newopts{$o} && !$oldopts{$o}) {
push(@opts, $o);
}
elsif (!$newopts{$o} && $oldopts{$o}) {
@opts = grep { $_ ne $o } @opts;
}
}
# Save options with values
foreach $o (&list_multi_client_restrictions()) {
$idx = &indexof($o, @opts);
if ($newopts{$o}) {
$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);
}
}
&set_current_value("smtpd_client_restrictions", join(" ", &unique(@opts)));
&unlock_postfix_files();
&reload_postfix();
&webmin_log("client");
&redirect("");