If a slave zone is in binary format, convert it to text when it becomes a master http://virtualmin.com/node/36245

This commit is contained in:
Jamie Cameron
2015-02-20 16:58:22 -08:00
parent 3fcb565086
commit dbd29ec126
2 changed files with 21 additions and 0 deletions

View File

@@ -14,6 +14,10 @@ $file = &find("file", $zconf->{'members'});
if (!$file) {
&error($text{'convert_efile'});
}
$file = &make_chroot(&absolute_path($file));
if (!-s $file) {
&error(&text('convert_efilesize', $file));
}
&lock_file(&make_chroot($zconf->{'file'}));
# Change the type directive
@@ -26,5 +30,19 @@ if (!$file) {
&flush_file_lines();
&unlock_file(&make_chroot($zconf->{'file'}));
# Convert from binary slave format to text
if (&is_raw_format_records($file)) {
&has_command("named-compilezone") ||
&error($text{'convert_ebinary'});
$temp = &transname();
&copy_source_dest($file, $temp);
$out = &backquote_logged("named-compilezone -f raw -F text ".
"-o $file $zone->{'name'} $temp 2>&1");
&error(&text('convert_ecompile', "<tt>".&html_escape($out)."</tt>"))
if ($?);
&unlink_file($temp);
}
&redirect("");

View File

@@ -824,6 +824,9 @@ log_dnssec=Change DNSSEC key re-signing
convert_err=Failed to convert zone
convert_efile=A records file must be specified before a slave zone can be converted to a master.
convert_efilesize=Records file $1 does not exist or is empty
convert_ebinary=The command needed to convert from a binary slave zone to a text format master is not installed
convert_ecompile=Binary to text format conversion failed : $1
whois_title=WHOIS Information
whois_header=Output from command $1 ..