Handle hostnames with upper-case letters
[webmin.git] / sendmail / list_ports.cgi
1 #!/usr/local/bin/perl
2 # Show a list of TCP ports Sendmail uses
3
4 require './sendmail-lib.pl';
5 $access{'ports'} || &error($text{'ports_ecannot'});
6 &ui_print_header(undef, $text{'ports_title'}, "");
7
8 # Get and parse current setting
9 $conf = &get_sendmailcf();
10 foreach $dpo (&find_options("DaemonPortOptions", $conf)) {
11         local %opts;
12         foreach $o (split(/\s*,\s*/, $dpo->[1])) {
13                 if ($o =~ /^([^=]+)=(\S+)$/) {
14                         $opts{$1} = $2;
15                         }
16                 }
17         push(@ports, \%opts);
18         }
19
20 # Show table of ports
21 print &ui_form_start("save_ports.cgi");
22 print &ui_radio("ports_def", @ports ? 0 : 1,
23         [ [ 1, $text{'ports_def1'} ], [ 0, $text{'ports_def0'} ] ])."<p>\n";
24 print &ui_columns_start([
25         $text{'ports_name'},
26         $text{'ports_addr'},
27         $text{'ports_port'},
28         $text{'ports_opts'},
29         ], 100);
30 $i = 0;
31 @tds = ( "valign=top", "valign=top", "valign=top" );
32 @known_opts = ( 'Name', 'Address', 'Port', 'Modifiers', 'Family' );
33 foreach $p (@ports, { }) {
34         @cols = ( );
35         foreach $k (@known_opts) {
36                 $fk = substr($k, 0, 1);
37                 if ($p->{$fk} && !$p->{$k}) {
38                         # Using first letter abbreviation only
39                         $p->{$k} = $p->{$fk};
40                         delete($p->{$fk});
41                         }
42                 }
43         if ($p->{'Addr'}) {
44                 # Some systems use 'Addr' instead of 'Address'
45                 $p->{'Address'} = $p->{'Addr'};
46                 delete($p->{'Addr'});
47                 }
48         push(@cols, &ui_textbox("name_$i", $p->{'Name'}, 10));
49         push(@cols, &ui_opt_textbox("addr_$i", $p->{'Address'}, 15,
50                                     $text{'ports_all'}, $text{'ports_ip'}).
51                     "<br>\n".
52                     $text{'ports_family'}." ".
53                     &ui_select("family_$i", $p->{'Family'},
54                                [ [ '', $text{'default'} ],
55                                  [ 'inet', $text{'ports_inet'} ],
56                                  [ 'inet6', $text{'ports_inet6'} ] ]));
57         push(@cols, &ui_opt_textbox("port_$i", $p->{'Port'}, 6,
58                                     $text{'default'}." (25)"));
59         @mods = ( );
60         foreach $m (@port_modifier_flags) {
61                 push(@mods, &ui_checkbox("mod_$i", $m, $text{'ports_mod_'.$m},
62                                          $p->{'Modifiers'} =~ /$m/));
63                 }
64         push(@cols, &ui_grid_table(\@mods, 2));
65         print &ui_columns_row(\@cols, \@tds);
66
67         # Hidden field for other settings
68         foreach $k (@known_opts) {
69                 delete($p->{$k});
70                 }
71         print &ui_hidden("other_$i",
72                 join(",", map { $_."=".$p->{$_} } keys %$p));
73         $i++;
74         }
75 print &ui_columns_end();
76 print &ui_form_end([ [ undef, $text{'save'} ] ]);
77
78 &ui_print_footer("", $text{'index_return'});
79