Handle hostnames with upper-case letters
[webmin.git] / bind8 / save_net.cgi
1 #!/usr/local/bin/perl
2 # save_net.cgi
3 # Save global address and topology options
4
5 require './bind8-lib.pl';
6 $access{'defaults'} || &error($text{'net_ecannot'});
7 &error_setup($text{'net_err'});
8 &ReadParse();
9
10 &lock_file(&make_chroot($config{'named_conf'}));
11 $conf = &get_config();
12 $options = &find("options", $conf);
13 if (!$in{'listen_def'}) {
14         for($i=0; defined($addr = $in{"addrs_$i"}); $i++) {
15                 next if (!$addr);
16                 local $l = { 'name' => 'listen-on',
17                              'type' => 1 };
18                 if (!$in{"pdef_$i"}) {
19                         $in{"port_$i"} =~ /^\d+$/ ||
20                                 &error(&text('net_eport', $in{"port_$i"}));
21                         $l->{'values'} = [ 'port', $in{"port_$i"} ];
22                         }
23                 $port = $in{"pdef_$i"} ? 53 : $in{"port_$i"};
24                 $used{$port}++ && &error(&text('net_eusedport', $port));
25                 $l->{'members'} =
26                         [ map { { 'name' => $_ } } split(/\s+/, $addr) ];
27                 push(@listen, $l);
28                 }
29         }
30 &save_directive($options, 'listen-on', \@listen, 1);
31 if (!$in{'saddr_def'}) {
32         &check_ipaddress($in{'saddr'}) ||
33                 &error(&text('net_eaddr', $in{'saddr'}));
34         push(@qvals, "address", $in{'saddr'});
35         }
36 if (!$in{'sport_def'}) {
37         $in{'sport'} =~ /^\d+$/ || &error(&text('net_eport', $in{'sport'}));
38         push(@qvals, "port", $in{'sport'});
39         }
40 if (@qvals) {
41         &save_directive($options, 'query-source',
42                         [ { 'name' => 'query-source',
43                             'values' => \@qvals } ], 1);
44         }
45 else {
46         &save_directive($options, 'query-source', [ ], 1);
47         }
48 $in{'topology_def'} || $in{'topology'} || &error($text{'net_etopology'});
49 &save_addr_match('topology', $options, 1);
50 $in{'allow-recursion_def'} || $in{'allow-recursion'} ||
51         &error($text{'net_erecur'});
52 &save_addr_match('allow-recursion', $options, 1);
53
54 &flush_file_lines();
55 &unlock_file(&make_chroot($config{'named_conf'}));
56 &webmin_log("net", undef, undef, \%in);
57 &redirect("");