Handle hostnames with upper-case letters
[webmin.git] / bind8 / save_slave.cgi
1 #!/usr/local/bin/perl
2 # save_slave.cgi
3 # Save changes to slave zone options in named.conf
4
5 require './bind8-lib.pl';
6 &ReadParse();
7 $conf = &get_config();
8 if ($in{'view'} ne '') {
9         $view = $conf->[$in{'view'}];
10         $conf = $view->{'members'};
11         $indent = 2;
12         }
13 else {
14         $indent = 1;
15         }
16 $zconf = $conf->[$in{'index'}];
17 &lock_file(&make_chroot($zconf->{'file'}));
18 &error_setup($text{'slave_err'});
19 &can_edit_zone($zconf, $view) ||
20         &error($text{'slave_ecannot'});
21 $access{'ro'} && &error($text{'master_ero'});
22 $access{'opts'} || &error($text{'master_eoptscannot'});
23
24 &save_port_address("masters", "port", $zconf, $indent);
25 &save_opt("max-transfer-time-in", \&mtti_check, $zconf, $indent);
26 &save_opt("file", \&file_check, $zconf, $indent);
27 &save_choice("check-names", $zconf, $indent);
28 &save_choice("notify", $zconf, $indent);
29 &save_addr_match("allow-update", $zconf, $indent);
30 &save_addr_match("allow-transfer", $zconf, $indent);
31 &save_addr_match("allow-query", $zconf, $indent);
32 &save_address("also-notify", $zconf, $indent);
33 &flush_file_lines();
34 &unlock_file(&make_chroot($zconf->{'file'}));
35 &webmin_log("opts", undef, $zconf->{'value'}, \%in);
36 &redirect("edit_slave.cgi?index=$in{'index'}&view=$in{'view'}");
37
38 sub mtti_check
39 {
40 return $_[0] =~ /^\d+$/ ? undef : &text('slave_emax', $_[0]);
41 }
42
43 sub file_check
44 {
45 return $text{'slave_efile'} if ($_[0] !~ /\S/);
46 local $file = $_[0];
47 if ($_[0] !~ /^\//) {
48         $file = &base_directory($conf)."/".$file;
49         }
50 return &allowed_zone_file(\%access, $file) ? undef :
51         &text('slave_efile2', $_[0]);
52 }
53