From: Mark Andrews Date: Tue, 4 Jul 2023 01:57:56 +0000 (+1000) Subject: Set the modification time of the zone file after dumping X-Git-Tag: v9.19.17~25^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9e03b5f5cc3d6cb63a19be24f9cd7a1329b0cd7f;p=thirdparty%2Fbind9.git Set the modification time of the zone file after dumping For secondary, mirror and redirect zones the expiry time is set from the zone file's modification time on restart. As zone dumping take time, set the modification time of the zone file to the expire time less the expire interval. --- diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 64064a41572..d4634909082 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -11390,6 +11390,27 @@ dump_done(void *arg, isc_result_t result) { ENTER; + /* + * Adjust modification time of zone file to preserve expire timing. + */ + if ((zone->type == dns_zone_secondary || + zone->type == dns_zone_mirror || + zone->type == dns_zone_redirect) && + result == ISC_R_SUCCESS) + { + LOCK_ZONE(zone); + isc_time_t when; + isc_interval_t i; + isc_interval_set(&i, zone->expire, 0); + result = isc_time_subtract(&zone->expiretime, &i, &when); + if (result == ISC_R_SUCCESS) { + (void)isc_file_settime(zone->masterfile, &when); + } else { + result = ISC_R_SUCCESS; + } + UNLOCK_ZONE(zone); + } + if (result == ISC_R_SUCCESS && zone->journal != NULL) { /* * We don't own these, zone->dctx must stay valid. @@ -11573,6 +11594,22 @@ redo: } else { result = dns_master_dump(zone->mctx, db, version, masterstyle, masterfile, masterformat, &rawdata); + if ((zone->type == dns_zone_secondary || + zone->type == dns_zone_mirror || + zone->type == dns_zone_redirect) && + result == ISC_R_SUCCESS) + { + isc_time_t when; + isc_interval_t i; + isc_interval_set(&i, zone->expire, 0); + result = isc_time_subtract(&zone->expiretime, &i, + &when); + if (result == ISC_R_SUCCESS) { + (void)isc_file_settime(zone->masterfile, &when); + } else { + result = ISC_R_SUCCESS; + } + } } fail: if (version != NULL) {