Handle hostnames with upper-case letters
[webmin.git] / bind8 / create_hint.cgi
1 #!/usr/local/bin/perl
2 # create_hint.cgi
3 # Create a new root zone
4
5 require './bind8-lib.pl';
6 &ReadParse();
7 &error_setup($text{'hcreate_err'});
8 $access{'master'} || &error($text{'hcreate_ecannot'});
9 $access{'ro'} && &error($text{'master_ero'});
10
11 # Validate inputs
12 &allowed_zone_file(\%access, $in{'file'}) ||
13         &error(&text('hcreate_efile', $in{'file'}));
14 &lock_file(&make_chroot($in{'file'}));
15 open(FILE, ">>".&make_chroot($in{'file'})) ||
16         &error($text{'hcreate_efile2'});
17 close(FILE);
18
19 # Get the root server information
20 if ($in{'real'} == 1) {
21         # Download from internic
22         $err = &download_root_zone($in{'file'});
23         &error($err) if ($err);
24         }
25 elsif ($in{'real'} == 2) {
26         # Use webmin's copy
27         &copy_source_dest("$module_root_directory/db.cache",
28                           &make_chroot($in{'file'}));
29         }
30 else {
31         # Just check the existing file
32         @recs = &read_zone_file(&make_chroot($in{'file'}), ".");
33         &error($text{'mcreate_erecs'}) if (@recs < 2);
34         }
35 &unlock_file(&make_chroot($in{'file'}));
36
37 # Create zone structure
38 $dir = { 'name' => 'zone',
39          'values' => [ '.' ],
40          'type' => 1,
41          'members' => [ { 'name' => 'type',
42                           'values' => [ 'hint' ] },
43                         { 'name' => 'file',
44                           'values' => [ $in{'file'} ] }
45                       ]
46         };
47
48 # Add a new hint zone
49 $conf = &get_config();
50 &create_zone($dir, $conf, $in{'view'});
51 &webmin_log("create", "hint", ".", \%in);
52 &redirect("");
53