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

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 2e98c781a84b21d0c50a9253e40b8f7f74e33c24..e9cc620dec729a734e9512d476ef1b92ee2c63c5 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]
+
        --- 9.9.3b1 released ---
        
 3468.  [security]      RPZ rules to generate A records (but not AAAA records)
index 9bfbb67e7acc07db94642ca00116a719fb444f6a..2d539910df96197b2d219865d0b5d1d9d6139532 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 4b8cd066b2544771946573620fbfc3c3aee85af1..8a881cdf752f9fc980c7e2d35856570d8657a921 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 9d3897f7e839371851826e1f2d15c927cfa112a7..a10f7edddedf36e6a311aaff67752d00dfe5a429 100644 (file)
@@ -8856,6 +8856,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;
 
@@ -8865,6 +8866,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?
@@ -13223,6 +13225,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);
@@ -13230,14 +13234,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",