Handle hostnames with upper-case letters
[webmin.git] / bind8 / save_text.cgi
1 #!/usr/local/bin/perl
2 # save_text.cgi
3 # Save a manually edit zone file
4
5 require './bind8-lib.pl';
6 &ReadParseMime();
7 $zone = &get_zone_name($in{'index'}, $in{'view'});
8 $file = &absolute_path($zone->{'file'});
9 $tv = $zone->{'type'};
10 &can_edit_zone($zone) ||
11         &error($text{'master_ecannot'});
12 $access{'file'} || &error($text{'text_ecannot'});
13 $access{'ro'} && &error($text{'master_ero'});
14
15 # Write out the file
16 &lock_file(&make_chroot($file));
17 $in{'text'} =~ s/\r//g;
18 $in{'text'} .= "\n" if ($in{'text'} !~ /\n$/);
19 &open_tempfile(FILE, ">".&make_chroot($file));
20 &print_tempfile(FILE, $in{'text'});
21 &close_tempfile(FILE);
22
23 # BUMP soa too
24 @recs = &read_zone_file($file, $zone->{'name'});
25 if ($in{'soa'}) {
26         &bump_soa_record($file, \@recs);
27         }
28
29 # Sign too
30 &sign_dnssec_zone_if_key($zone, \@recs);
31
32 &unlock_file(&make_chroot($file));
33 &webmin_log("text", undef, $zone->{'name'},
34             { 'file' => $file });
35 &redirect("edit_master.cgi?index=$in{'index'}&view=$in{'view'}");
36