]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] dump masterfile after successful xfrin
authorEvan Hunt <each@isc.org>
Tue, 22 Jan 2013 23:49:50 +0000 (15:49 -0800)
committerEvan Hunt <each@isc.org>
Tue, 22 Jan 2013 23:49:50 +0000 (15:49 -0800)
3470. [bug] Slave zones could fail to dump when successfully
refreshing after an initial failure. [RT #31276]

CHANGES
bin/tests/system/xfer/clean.sh
bin/tests/system/xfer/ns2/named.conf
bin/tests/system/xfer/ns2/slave.db.in [new file with mode: 0644]
bin/tests/system/xfer/setup.sh
bin/tests/system/xfer/tests.sh
lib/dns/zone.c

diff --git a/CHANGES b/CHANGES
index 9808534c9f25dbbd2812c518fbf051ad93119b76..85568410ed172a84763bd16afacaab9b6647eaea 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3470.  [bug]           Slave zones could fail to dump when successfully
+                       refreshing after an initial failure. [RT #31276]
+
 3469.  [bug]           Handle DLZ lookup failures more gracefully. Improve
                        backward compatibility between versions of DLZ dlopen
                        API. [RT #32275]
index 747490f5818aa9eabb37279e73e95b4fc2dc2140..b9c45a6030537c76b6fc9b40e3a290bc310f37d4 100644 (file)
@@ -24,7 +24,7 @@
 rm -f dig.out.ns1 dig.out.ns2 dig.out.ns3 dig.out.ns4
 rm -f dig.out.ns5 dig.out.ns6 dig.out.ns7
 rm -f axfr.out
-rm -f ns1/slave.db
+rm -f ns1/slave.db ns2/slave.db
 rm -f ns2/example.db ns2/tsigzone.db ns2/example.db.jnl
 rm -f ns3/example.bk ns3/tsigzone.bk ns3/example.bk.jnl
 rm -f ns3/master.bk ns3/master.bk.jnl
index 53a64ab96267819d66ee25b4b21e4c0c8fc45f38..5f010740f8489c44ada5a1ff25670b6550f6bcc8 100644 (file)
@@ -59,3 +59,10 @@ zone "tsigzone" {
        file "tsigzone.db";
        allow-transfer { tzkey; };
 };
+
+zone "slave" {
+       type slave;
+       file "slave.db";
+       masters { 10.53.0.1; };
+        masterfile-format text;
+};
diff --git a/bin/tests/system/xfer/ns2/slave.db.in b/bin/tests/system/xfer/ns2/slave.db.in
new file mode 100644 (file)
index 0000000..a67eef0
--- /dev/null
@@ -0,0 +1,8 @@
+$TTL 5
+
+@                      IN SOA  ns1 hostmaster 1 5 5 5 5
+@                      NS      ns1
+ns1                    A       10.53.0.1
+a01                    A       1.1.1.1
+a02                    A       255.255.255.255
+
index b9a97b4446e9d29382967f7c58219b30220c3399..4bf4752c261859f3507218fdb87e28949f1e0a15 100644 (file)
@@ -32,3 +32,6 @@ rm -f ns4/*.db ns4/*.jnl
 cp -f ns4/root.db.in ns4/root.db
 $PERL -e 'for ($i=0;$i<10000;$i++){ printf("x%u 0 in a 10.53.0.1\n", $i);}' >> ns4/root.db
 cp -f ns4/named.conf.base ns4/named.conf
+
+cp ns2/slave.db.in ns2/slave.db
+touch -t 200101010000 ns2/slave.db
index 621f01f6dd00501c1ecc88764fc550d3d056f85e..414e95499c8cc54eef154777f4a22118699d8559 100644 (file)
@@ -116,6 +116,14 @@ $RNDC -c ../common/rndc.conf -s 10.53.0.7 -p 9953 reload 2>&1 | sed 's/^/I:ns7 /
 
 sleep 3
 
+echo "I:testing zone is dumped after successful transfer"
+$DIG $DIGOPTS +noall +answer +multi @10.53.0.2 -p 5300 \
+       slave. soa > dig.out.ns2 || tmp=1
+grep "1397051952 ; serial" dig.out.ns2 > /dev/null 2>&1 || tmp=1
+grep "1397051952 ; serial" ns2/slave.db > /dev/null 2>&1 || tmp=1
+if test $tmp != 0 ; then echo "I:failed"; fi
+status=`expr $status + $tmp`
+
 echo "I:testing ixfr-from-differences yes;"
 tmp=0
 
index a051d17a9690be1cbe1937235447478d2eceeb93..b38836dcb4025468e613c1485a8b4dac4995f49f 100644 (file)
@@ -8959,6 +8959,7 @@ dns_zone_dump(dns_zone_t *zone) {
 
 static void
 zone_needdump(dns_zone_t *zone, unsigned int delay) {
+       const char me[] = "zone_needdump";
        isc_time_t dumptime;
        isc_time_t now;
 
@@ -8968,6 +8969,7 @@ zone_needdump(dns_zone_t *zone, unsigned int delay) {
 
        REQUIRE(DNS_ZONE_VALID(zone));
        REQUIRE(LOCKED_ZONE(zone));
+       ENTER;
 
        /*
         * Do we have a place to dump to and are we loaded?
@@ -13326,6 +13328,8 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
                 * won't hurt with an AXFR.
                 */
                if (zone->masterfile != NULL || zone->journal != NULL) {
+                       unsigned int delay = DNS_DUMP_DELAY;
+
                        result = ISC_R_FAILURE;
                        if (zone->journal != NULL)
                                result = isc_file_settime(zone->journal, &now);
@@ -13333,14 +13337,16 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
                            zone->masterfile != NULL)
                                result = isc_file_settime(zone->masterfile,
                                                          &now);
-                       /* Someone removed the file from underneath us! */
-                       if (result == ISC_R_FILENOTFOUND &&
-                           zone->masterfile != NULL) {
-                               unsigned int delay = DNS_DUMP_DELAY;
-                               if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NODELAY))
-                                       delay = 0;
+
+                       if ((DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NODELAY) != 0) ||
+                           result == ISC_R_FILENOTFOUND)
+                               delay = 0;
+
+                       if ((result == ISC_R_SUCCESS ||
+                           result == ISC_R_FILENOTFOUND) &&
+                           zone->masterfile != NULL)
                                zone_needdump(zone, delay);
-                       else if (result != ISC_R_SUCCESS)
+                       else if (result != ISC_R_SUCCESS)
                                dns_zone_log(zone, ISC_LOG_ERROR,
                                             "transfer: could not set file "
                                             "modification time of '%s': %s",