Handle hostnames with upper-case letters
[webmin.git] / sendmail / save_masq.cgi
1 #!/usr/local/bin/perl
2 # save_masq.cgi
3 # Save domain masquerading
4
5 require './sendmail-lib.pl';
6 &ReadParseMime();
7 $access{'masq'} || &error($text{'masq_ecannot'});
8 &error_setup($text{'masq_err'});
9 &lock_file($config{'sendmail_cf'});
10 $conf = &get_sendmailcf();
11 $in{'masq'} =~ /^[A-z0-9\-\.]*$/ ||
12         &error(&text('masq_edomain', $in{'masq'}));
13 @mlist = split(/\s+/, $in{'mlist'});
14 foreach $m (@mlist) {
15         $m =~ /^[A-z0-9\-\.]+$/ ||
16                 &error(&text('masq_ehost', $m));
17         &check_ipaddress($m) &&
18                 &error(&text('masq_eip', $m));
19         }
20 @mlist = &unique(@mlist);
21 @nlist = split(/\s+/, $in{'nlist'});
22 foreach $n (@nlist) {
23         $n =~ /^[A-z0-9\-\.]+$/ ||
24                 &error(&text('masq_ehost', $n));
25         &check_ipaddress($n) &&
26                 &error(&text('masq_eip', $n));
27         }
28 @nlist = &unique(@nlist);
29
30 # Update the DM directive (if there is one)
31 foreach $d (&find_type("D", $conf)) {
32         if ($d->{'value'} =~ /^M/) { push(@dmconf, $d); }
33         }
34 &save_directives($conf, \@dmconf,
35                  [ { 'type' => 'D', 'values' => [ "M$in{'masq'}" ] } ]);
36
37 # Update domains to masquerade, and not to
38 &save_file_or_config($conf, "M", \@mlist);
39 &save_file_or_config($conf, "N", \@nlist);
40 &flush_file_lines();
41 &unlock_file($config{'sendmail_cf'});
42
43 &restart_sendmail();
44 &webmin_log("masq");
45 &redirect("");
46