Handle hostnames with upper-case letters
[webmin.git] / postfix / sasl.cgi
1 #!/usr/local/bin/perl
2 # Show SMTP authentication related paramters
3
4 require './postfix-lib.pl';
5
6 $access{'sasl'} || &error($text{'sasl_ecannot'});
7 &ui_print_header(undef, $text{'sasl_title'}, "");
8
9 $default = $text{'opts_default'};
10 $none = $text{'opts_none'};
11 $no_ = $text{'opts_no'};
12
13 # Form start
14 print &ui_form_start("save_sasl.cgi");
15 print &ui_table_start($text{'sasl_title'}, "width=100%", 4);
16
17 # Enabled, accept broken clients
18 &option_yesno("smtpd_sasl_auth_enable");
19 &option_yesno("broken_sasl_auth_clients");
20
21 # Anonymous and plain-text options
22 %opts = map { $_, 1 }
23             split(/[\s,]+/, &get_current_value("smtpd_sasl_security_options"));
24 @cbs = ( );
25 foreach $o ("noanonymous", "noplaintext") {
26         push(@cbs, &ui_checkbox("sasl_opts", $o, $text{'sasl_'.$o}, $opts{$o}));
27         }
28 print &ui_table_row($text{'sasl_opts'}, join("<br>\n", @cbs), 3);
29
30 # SASL-related relay restrictions
31 %recip = map { $_, 1 }
32             split(/[\s,]+/, &get_current_value("smtpd_recipient_restrictions"));
33 @cbs = ( );
34 foreach $o (&list_smtpd_restrictions()) {
35         push(@cbs, &ui_checkbox("sasl_recip", $o, $text{'sasl_'.$o},
36                                 $recip{$o}));
37         }
38 print &ui_table_row($text{'sasl_recip'}, join("<br>\n", @cbs), 3);
39
40 # Delay bad logins
41 &option_yesno("smtpd_delay_reject");
42
43 print &ui_table_hr();
44
45 # SMTP TLS options
46 if ($postfix_version >= 2.3) {
47         $level = &get_current_value("smtpd_tls_security_level");
48         print &ui_table_row($text{'opts_smtpd_use_tls'},
49                 &ui_select("smtpd_tls_security_level", $level, 
50                            [ [ "", $text{'default'} ],
51                              [ "none", $text{'sasl_level_none'} ],
52                              [ "may", $text{'sasl_level_may'} ],
53                              [ "encrypt", $text{'sasl_level_encrypt'} ] ]));
54         }
55 else {
56         &option_yesno("smtpd_use_tls");
57         }
58
59 &option_radios_freefield("smtpd_tls_cert_file", 60, $none);
60
61 &option_radios_freefield("smtpd_tls_key_file", 60, $none);
62
63 &option_radios_freefield("smtpd_tls_CAfile", 60, $none);
64
65 print &ui_table_hr();
66
67 # Outgoing authentication options
68 &option_radios_freefield("relayhost", 45, $text{'opts_direct'});
69
70 # Get the current map value for the relayhost
71 $rh = &get_current_value("relayhost");
72 $rh =~ s/^\[(.*)\]$/$1/g;
73 if ($rh) {
74         $pmap = &get_maps("smtp_sasl_password_maps");
75         foreach my $o (@$pmap) {
76                 if ($o->{'name'} eq $rh) {
77                         ($ruser, $rpass) = split(/:/, $o->{'value'});
78                         }
79                 }
80         }
81 print &ui_table_row($text{'sasl_login'},
82         &ui_radio("login_none", $ruser ? 0 : 1,
83                   [ [ 1, $text{'sasl_nologin'}."<br>" ],
84                     [ 0, &text('sasl_userpass',
85                                 &ui_textbox("login_user", $ruser, 20), 
86                                 &ui_textbox("login_pass", $rpass, 20)) ] ]), 3);
87
88 print &ui_table_end();
89 print &ui_form_end([ [ undef, $text{'opts_save'} ] ]);
90
91 &ui_print_footer("", $text{'index_return'});