From 9e03b5f5cc3d6cb63a19be24f9cd7a1329b0cd7f Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 4 Jul 2023 11:57:56 +1000 Subject: [PATCH] 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. --- lib/dns/zone.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 64064a4157..d463490908 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) {