]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Display the before/after SOA records when updating serial number.
authorMiod Vallat <miod.vallat@powerdns.com>
Mon, 11 Aug 2025 10:21:18 +0000 (12:21 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Mon, 11 Aug 2025 11:10:05 +0000 (13:10 +0200)
This used to be the case and then the code kept building the string but
would no longer output it...

Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
pdns/pdnsutil.cc

index 2d06ff02c851d1e07107adc51f2f73e35783f029..a9aea8ef7e3f24eae37be8b8b9a4e7b41be87e1d 100644 (file)
@@ -1899,6 +1899,10 @@ static bool parseZoneFile(const char* tmpnam, int& errorline, std::vector<DNSRec
   return true;
 }
 
+// Increase the serial number of the SOA record according to the
+// SOA-EDIT-INCREASE policy.
+// Returns true if successful, with `update' containing the updated
+// record, false otherwise.
 static bool increaseZoneSerial(UtilBackend &B, DNSSECKeeper& dsk, DomainInfo& info, std::vector<DNSRecord>& records, const PDNSColors& col, DNSRecord& update) // NOLINT(readability-identifier-length)
 {
   auto iter = std::find_if(records.begin(), records.end(), [&info](const DNSRecord& rec) { return rec.d_type == QType::SOA && rec.d_name == info.zone.operator const DNSName&(); });
@@ -1909,8 +1913,6 @@ static bool increaseZoneSerial(UtilBackend &B, DNSSECKeeper& dsk, DomainInfo& in
     return false;
   }
   DNSRecord oldSoaDR = *iter;
-  ostringstream str;
-  str<< col.red() << "-" << oldSoaDR.d_name << " " << oldSoaDR.d_ttl << " IN " << DNSRecordContent::NumberToType(oldSoaDR.d_type) << " " <<oldSoaDR.getContent()->getZoneRepresentation(true) << col.rst() <<endl;
 
   SOAData soa;
   B.getSOAUncached(info.zone, soa);
@@ -1923,8 +1925,13 @@ static bool increaseZoneSerial(UtilBackend &B, DNSSECKeeper& dsk, DomainInfo& in
   makeIncreasedSOARecord(soa, "SOA-EDIT-INCREASE", soaEditKind, resrec);
   DNSRecord rec(resrec);
 
+  ostringstream str;
+  str<< col.red() << "-" << oldSoaDR.d_name << " " << oldSoaDR.d_ttl << " IN " << DNSRecordContent::NumberToType(oldSoaDR.d_type) << " " <<oldSoaDR.getContent()->getZoneRepresentation(true) << col.rst() <<endl;
+  str << col.green() << "+" << rec.d_name << " " << rec.d_ttl<< " IN " <<DNSRecordContent::NumberToType(rec.d_type) << " " <<rec.getContent()->getZoneRepresentation(true) << col.rst() <<endl;
+  cout << str.str();
+
   *iter = rec;
-  cout<<endl<<"SOA serial for zone "<<info.zone<<" set to "<<soa.serial;
+  cout<<"SOA serial for zone "<<info.zone<<" set to "<<soa.serial;
   update = std::move(rec);
   return true;
 }