diff --git a/bind8/CHANGELOG b/bind8/CHANGELOG
index bb9a15c86..374cf73d6 100644
--- a/bind8/CHANGELOG
+++ b/bind8/CHANGELOG
@@ -125,3 +125,5 @@ Added the Delete Records In Selected button to the main page, for removing the s
The default view for new zones can now be set via an option on the Module Config page.
When adding cluster slave servers, their IPs are added to the also-notify and allow-transfer blocks of each domain added to the slave.
IPv6 addresses can now be used for remote nameservers in slave and delegation zones.
+---- Changes since 1.540 ----
+Added the Test Zone Transfer button to the slave zone page, to check if zone transfers are possible or not.
diff --git a/bind8/bind8-lib.pl b/bind8/bind8-lib.pl
index 0e8bf4f5d..1146393be 100755
--- a/bind8/bind8-lib.pl
+++ b/bind8/bind8-lib.pl
@@ -3279,5 +3279,39 @@ if (&find_byname("nscd")) {
}
}
+# transfer_slave_records(zone, &masters, [file])
+# Transfer DNS records from a master into some file. Returns a map from master
+# IPs to errors.
+sub transfer_slave_records
+{
+my ($dom, $masters, $file) = @_;
+my %rv;
+my $dig = &has_command("dig");
+foreach my $ip (@$masters) {
+ if (!$dig) {
+ $rv{$ip} = "Missing dig command";
+ }
+ else {
+ my $out = &backquote_logged("$dig IN AXFR ".quotemeta($dom).
+ " \@".quotemeta($ip)." 2>&1");
+ if ($?) {
+ $rv{$ip} = $out;
+ }
+ elsif (!$out) {
+ $rv{$ip} = "No records transferred";
+ }
+ else {
+ if ($file) {
+ &open_tempfile(XFER, ">$file");
+ &print_tempfile(XFER, $out);
+ &close_tempfile(XFER);
+ $file = undef;
+ }
+ }
+ }
+ }
+return \%rv;
+}
+
1;
diff --git a/bind8/edit_slave.cgi b/bind8/edit_slave.cgi
index 972c7b9c9..3ced542ba 100755
--- a/bind8/edit_slave.cgi
+++ b/bind8/edit_slave.cgi
@@ -81,6 +81,9 @@ if ($access{'whois'} && &has_command($config{'whois_cmd'}) &&
push(@titles, $text{'master_whois'});
push(@images, "images/whois.gif");
}
+push(@links, "xfer.cgi?index=$in{'index'}&view=$in{'view'}");
+push(@titles, $text{'slave_xfer'});
+push(@images, "images/xfer.gif");
if (@links) {
print &ui_hr() if ($done_recs);
&icons_table(\@links, \@titles, \@images);
diff --git a/bind8/images/xfer.gif b/bind8/images/xfer.gif
new file mode 100644
index 000000000..969922e8d
Binary files /dev/null and b/bind8/images/xfer.gif differ
diff --git a/bind8/lang/en b/bind8/lang/en
index ab0e6732c..99859cb8b 100644
--- a/bind8/lang/en
+++ b/bind8/lang/en
@@ -192,6 +192,7 @@ slave_apply=Force Update
slave_applymsg2=Click this button to force a re-transfer of the zone from the master server, so that it gets all the latest records.
slave_last=Last transferred : $1
slave_never=Never
+slave_xfer=Test Zone Transfer
screate_title1=Create Slave Zone
screate_title2=Create Stub Zone
@@ -1109,4 +1110,11 @@ trusted_ealg=Missing or invalid algorithm number in row $1
trusted_ekey=Missing base-64 encoded trusted zone key in row $1
trusted_setup=For DNSSEC to be useful to verify the majority of signed zones on the Internet, BIND must be configured to use a DLV server. Webmin can set this up for you, using the ICS DLV server at $1.
trusted_ok=Setup DLV and Enable DNSSEC Verification
+
+xfer_title=Test Zone Transfer
+xfer_doing=Testing transfer of slave zone from $1 ..
+xfer_failed=.. from $1 : Failed : $2
+xfer_done=.. from $1 : Completed OK
+xfer_count=Test transfer successfully fetched $1 records from at least one nameserver. Actual transfers by BIND should also succeed.
+
__norefs=1
diff --git a/bind8/xfer.cgi b/bind8/xfer.cgi
new file mode 100644
index 000000000..fe16a4c93
--- /dev/null
+++ b/bind8/xfer.cgi
@@ -0,0 +1,51 @@
+#!/usr/local/bin/perl
+# Force a zone transfer for a slave domain
+
+require './bind8-lib.pl';
+&ReadParse();
+$zone = &get_zone_name($in{'index'}, $in{'view'});
+&can_edit_zone($zone) ||
+ &error($text{'master_ecannot'});
+
+# Get config object
+$bconf = $conf = &get_config();
+if ($in{'view'} ne '') {
+ $view = $conf->[$in{'view'}];
+ $conf = $view->{'members'};
+ }
+$zconf = $conf->[$in{'index'}]->{'members'};
+$file = &find_value("file", $zconf);
+
+$desc = &ip6int_to_net(&arpa_to_ip($zone->{'name'}));
+&ui_print_header($desc, $text{'xfer_title'}, "",
+ undef, undef, undef, undef, &restart_links($zone));
+
+# Get master IPs
+$masters = &find("masters", $zconf);
+foreach $av (@{$masters->{'members'}}) {
+ push(@ips, join(" ", $av->{'name'}, @{$av->{'values'}}));
+ }
+print &text('xfer_doing', join(" ", @ips)),"
\n";
+$temp = &transname();
+$rv = &transfer_slave_records($zone->{'name'}, \@ips, $temp);
+foreach $ip (@ips) {
+ if ($rv->{$ip}) {
+ print &text('xfer_failed', $ip,
+ "".&html_escape($rv->{$ip}).""),
+ "
\n";
+ }
+ else {
+ print &text('xfer_done', $ip),"
\n";
+ }
+ }
+print "
\n"; + +# Show records +if (-r $temp) { + @recs = &read_zone_file($temp, $zone->{'name'}."."); + print &text('xfer_count', scalar(@recs)),"
\n"; + } +&unlink_file($temp); + +&ui_print_footer("edit_slave.cgi?index=$in{'index'}&view=$in{'view'}", + $text{'master_return'});