2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

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.
This commit is contained in:
Mark Andrews 2023-07-04 11:57:56 +10:00
parent b04d941354
commit 9e03b5f5cc

View File

@ -11390,6 +11390,27 @@ dump_done(void *arg, isc_result_t result) {
ENTER; 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) { if (result == ISC_R_SUCCESS && zone->journal != NULL) {
/* /*
* We don't own these, zone->dctx must stay valid. * We don't own these, zone->dctx must stay valid.
@ -11573,6 +11594,22 @@ redo:
} else { } else {
result = dns_master_dump(zone->mctx, db, version, masterstyle, result = dns_master_dump(zone->mctx, db, version, masterstyle,
masterfile, masterformat, &rawdata); 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: fail:
if (version != NULL) { if (version != NULL) {