]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix catalog zone reconfiguration crash
authorAram Sargsyan <aram@isc.org>
Mon, 11 Oct 2021 18:13:39 +0000 (18:13 +0000)
committerAram Sargsyan <aram@isc.org>
Tue, 23 Nov 2021 11:39:37 +0000 (11:39 +0000)
The following scenario triggers a "named" crash:

1. Configure a catalog zone.
2. Start "named".
3. Comment out the "catalog-zone" clause.
4. Run `rndc reconfig`.
5. Uncomment the "catalog-zone" clause.
6. Run `rndc reconfig` again.

Implement the required cleanup of the in-memory catalog zone during
the first `rndc reconfig`, so that the second `rndc reconfig` could
find it in an expected state.

bin/named/server.c
lib/dns/include/dns/zone.h
lib/dns/zone.c

index e39ad83b0276b98c465e6c30e581831df865b1c1..b2d47186228e0fdcfc07b57b367fd76918945182 100644 (file)
@@ -6657,6 +6657,8 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
 
        if (zone_is_catz) {
                dns_zone_catz_enable(zone, view->catzs);
+       } else if (dns_zone_catz_is_enabled(zone)) {
+               dns_zone_catz_disable(zone);
        }
 
        /*
index e05b653d6cdc3c05cf3eb04cbf48acb3991a7221..d82d6eb0dadfc9107490936bd0d93d806de20b9a 100644 (file)
@@ -2635,6 +2635,26 @@ dns_zone_catz_enable(dns_zone_t *zone, dns_catz_zones_t *catzs);
  * \li prior to calling, zone->catzs is NULL or is equal to 'catzs'
  */
 
+void
+dns_zone_catz_disable(dns_zone_t *zone);
+/*%<
+ * Disable zone as catalog zone, if it is one.
+ *
+ * Requires:
+ *
+ * \li 'zone' is a valid zone object
+ */
+
+bool
+dns_zone_catz_is_enabled(dns_zone_t *zone);
+/*%<
+ * Return a boolean indicating whether the zone is enabled as catalog zone.
+ *
+ * Requires:
+ *
+ * \li 'zone' is a valid zone object
+ */
+
 void
 dns_zone_catz_enable_db(dns_zone_t *zone, dns_db_t *db);
 /*%<
index 20d31386f08c6daa073b823cc1617897ce10da3b..92d23558c5810d65796c36505c11f5a780485166 100644 (file)
@@ -1967,6 +1967,24 @@ dns_zone_catz_enable(dns_zone_t *zone, dns_catz_zones_t *catzs) {
        UNLOCK_ZONE(zone);
 }
 
+void
+dns_zone_catz_disable(dns_zone_t *zone) {
+       REQUIRE(DNS_ZONE_VALID(zone));
+
+       LOCK_ZONE(zone);
+       if (zone->catzs != NULL) {
+               dns_catz_catzs_detach(&zone->catzs);
+       }
+       UNLOCK_ZONE(zone);
+}
+
+bool
+dns_zone_catz_is_enabled(dns_zone_t *zone) {
+       REQUIRE(DNS_ZONE_VALID(zone));
+
+       return (zone->catzs != NULL);
+}
+
 /*
  * If a zone is a catalog zone, attach it to update notification in database.
  */