diff --git a/bind8/convert_slave.cgi b/bind8/convert_slave.cgi index 03d6d592c..9dc1dae50 100755 --- a/bind8/convert_slave.cgi +++ b/bind8/convert_slave.cgi @@ -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(); + ©_source_dest($file, $temp); + $out = &backquote_logged("named-compilezone -f raw -F text ". + "-o $file $zone->{'name'} $temp 2>&1"); + &error(&text('convert_ecompile', "".&html_escape($out)."")) + if ($?); + &unlink_file($temp); + } + &redirect(""); diff --git a/bind8/lang/en b/bind8/lang/en index c506cea1a..96b77efbd 100644 --- a/bind8/lang/en +++ b/bind8/lang/en @@ -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 ..