From 3fd6806be0cd9d22528c00c8e282d733ceb32e7c Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 2 May 2024 16:50:47 -0400 Subject: [PATCH] BIND: BUGFIX: SOA serial number doesn't change if SOA() used (#2908) --- providers/bind/bindProvider.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/providers/bind/bindProvider.go b/providers/bind/bindProvider.go index 753fcbacd..27dbb1598 100644 --- a/providers/bind/bindProvider.go +++ b/providers/bind/bindProvider.go @@ -22,6 +22,7 @@ import ( "time" "github.com/StackExchange/dnscontrol/v4/models" + "github.com/StackExchange/dnscontrol/v4/pkg/bindserial" "github.com/StackExchange/dnscontrol/v4/pkg/diff2" "github.com/StackExchange/dnscontrol/v4/pkg/prettyzone" "github.com/StackExchange/dnscontrol/v4/pkg/printer" @@ -117,14 +118,13 @@ func (s SoaDefaults) String() string { // bindProvider is the provider handle for the bindProvider driver. type bindProvider struct { - DefaultNS []string `json:"default_ns"` - DefaultSoa SoaDefaults `json:"default_soa"` - nameservers []*models.Nameserver - directory string - filenameformat string - zonefile string // Where the zone data is e texpected - zoneFileFound bool // Did the zonefile exist? - skipNextSoaIncrease bool // skip next SOA increment (for testing only) + DefaultNS []string `json:"default_ns"` + DefaultSoa SoaDefaults `json:"default_soa"` + nameservers []*models.Nameserver + directory string + filenameformat string + zonefile string // Where the zone data is e texpected + zoneFileFound bool // Did the zonefile exist? } // GetNameservers returns the nameservers for a domain. @@ -241,7 +241,6 @@ func (c *bindProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundR desiredSoa = dc.Records[len(dc.Records)-1] } else { *desiredSoa = *soaRec - c.skipNextSoaIncrease = true } var msgs []string @@ -273,8 +272,11 @@ func (c *bindProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundR ) // We only change the serial number if there is a change. - if !c.skipNextSoaIncrease { - desiredSoa.SoaSerial = nextSerial + desiredSoa.SoaSerial = nextSerial + + // If the --bindserial flag is used, force the serial to that value + if bindserial.ForcedValue != 0 { + desiredSoa.SoaSerial = uint32(bindserial.ForcedValue & 0xFFFF) } corrections = append(corrections,