Handle hostnames with upper-case letters
[webmin.git] / bind8 / old_save_controls.cgi
1 #!/usr/local/bin/perl
2 # save_misc.cgi
3 # Save global miscellaneous options
4
5 require './bind8-lib.pl';
6 $access{'defaults'} || &error($text{'misc_ecannot'});
7 &error_setup($text{'controls_err'});
8 &ReadParse();
9
10 &lock_file(&make_chroot($config{'named_conf'}));
11 $conf = &get_config();
12 my $controls = &find("controls", $conf);
13
14 if ($in{'inet_def'} && $in{'unix_def'}) {
15   if (defined($controls)) {
16     &save_directive(&get_config_parent(), 'controls', [ ], 0);
17   }
18 } else {
19   if (!defined($controls)) {
20     $controls={ 'name' => 'controls', 'type' => 1 };
21     &save_directive(&get_config_parent(), 'controls', [ $controls ], 0);
22   }
23   if (!$in{'inet_def'}) {
24     my $addr=$in{'inetaddr'};
25     &check_ipaddress($addr) || &error(&text('controls_eip', $addr));
26
27     my $port=$in{'inetport'};
28     $port =~ /^\d+$/ || &error($text{'controls_eport'});
29     my @allows=();
30     foreach $allow (split(/\s+/, $in{'inetallow'})) {
31       # Need to check acl is OK!
32       push(@allows, { 'name' => $allow });
33     }
34
35     my $inetdir = { 'name' => 'inet', 'type' => 1,
36                     'values' => [ $addr,
37                                   'port', $port,
38                                   'allow' ],
39                     'members' => \@allows };
40
41     &save_directive($controls, "inet", [ $inetdir ], 1);
42   } else {
43     &save_directive($controls, "inet", [ ], 1);
44   }
45
46   if (!$in{'unix_def'}) {
47     my $file=$in{'unixfile'};
48     my $perms=$in{'unixperms'};
49     my $owner=$in{'unixowner'};
50     my $group=$in{'unixgroup'};
51     $file =~ /^\S+$/ || &error($text{'controls_efile'});
52     $perms =~ /^\d+$/ || &error($text{'controls_eperms'});
53     $owner =~ /^\d+$/ || &error($text{'controls_eowner'});
54     $group =~ /^\d+$/ || &error($text{'controls_egroup'});
55
56     my $unixdir = { 'name' => 'unix', 'type' => 0,
57                     'values' => [ "\"$file\"",
58                                   'perm', $perms,
59                                   'owner', $owner,
60                                   'group', $group ] };
61
62     &save_directive($controls, "unix", [ $unixdir ], 1);
63   } else {
64     &save_directive($controls, "unix", [ ], 1);
65   }
66 }
67
68 &flush_file_lines();
69 &unlock_file(&make_chroot($config{'named_conf'}));
70 &webmin_log("controls", undef, undef, \%in);
71 &redirect("");
72