Handle hostnames with upper-case letters
[webmin.git] / dovecot / save_net.cgi
1 #!/usr/local/bin/perl
2 # Update networking options
3
4 require './dovecot-lib.pl';
5 &ReadParse();
6 &error_setup($text{'net_err'});
7 $conf = &get_config();
8 &lock_dovecot_files($conf);
9
10 &save_directive($conf, "protocols", join(" ", split(/\0/, $in{'protocols'})));
11 $sslopt = &find("ssl_disable", $conf, 2) ? "ssl_disable" : "ssl";
12 &save_directive($conf, $sslopt, $in{$sslopt} eq '' ? undef : $in{$sslopt});
13 @listens = &find("imap_listen", $conf, 2) ?
14                 ("imap_listen", "pop3_listen", "imaps_listen", "pop3s_listen") :
15                 ("listen", "ssl_listen");
16 foreach $l (@listens) {
17         if ($in{$l."_mode"} == 0) {
18                 $listen = undef;
19                 }
20         elsif ($in{$l."_mode"} == 1) {
21                 $listen = "[::]";
22                 }
23         elsif ($in{$l."_mode"} == 2) {
24                 $listen = "*";
25                 }
26         elsif ($in{$l."_mode"} == 3) {
27                 &check_ipaddress($in{$l}) || &error($text{'net_e'.$l});
28                 $listen = $in{$l};
29                 }
30         &save_directive($conf, $l, $listen);
31         }
32
33 &flush_file_lines();
34 &unlock_dovecot_files($conf);
35 &webmin_log("net");
36 &redirect("");
37