From: Miod Vallat Date: Mon, 11 Aug 2025 09:45:55 +0000 (+0200) Subject: Move "zone edit" SOA increase code to a separate routine. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a5cb32d2427434953329b11fab9d38921888dc39;p=thirdparty%2Fpdns.git Move "zone edit" SOA increase code to a separate routine. Change its interface so that it can report the lack of an SOA record, in which case we go to the "invalid zone data" state to give the user a chance to repair the zone. Signed-off-by: Miod Vallat --- diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 548f1ca38..98359e75a 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -1899,6 +1899,36 @@ static bool parseZoneFile(const char* tmpnam, int& errorline, std::vector& 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&(); }); + // There should be one SOA record, therefore iter should be valid... + // ...but it is possible to f*ck up a zone well enough to reach this + // path with no SOA record at all. + if (iter == records.end()) { + return false; + } + DNSRecord oldSoaDR = *iter; + ostringstream str; + str<< col.red() << "-" << oldSoaDR.d_name << " " << oldSoaDR.d_ttl << " IN " << DNSRecordContent::NumberToType(oldSoaDR.d_type) << " " <getZoneRepresentation(true) << col.rst() <getZoneRepresentation(true) << col.rst() <getZoneRepresentation(true) << col.rst() <getZoneRepresentation(true) << col.rst() <