From dd6e79a5bf56bd80452295ac1f4a8ccbaafdd126 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Fri, 3 Oct 2025 07:25:22 +0200 Subject: [PATCH] When copying/migrating zones, only complain about comments if there are any. Fixes: #16201 Signed-off-by: Miod Vallat --- pdns/pdnsutil.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 76b89ef270..890e60cd35 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -1886,14 +1886,20 @@ static void copyZoneContents(const DomainInfo& srcinfo, const ZoneName& dstzone, num_records++; } - // Copy comments + // Copy comments, if any if (src->listComments(srcinfo.id)) { - if ((tgt->getCapabilities() & DNSBackend::CAP_COMMENTS) == 0) { - tgt->abortTransaction(); - throw PDNSException("Target backend does not support comments - remove them first"); - } + bool firstComment{true}; Comment comm; - while(src->getComment(comm)) { + while (src->getComment(comm)) { + if (firstComment) { + firstComment = false; + if ((tgt->getCapabilities() & DNSBackend::CAP_COMMENTS) == 0) { + // TODO: consider simply warning about comments not being copied, and + // skip them, rather than abort everything? + tgt->abortTransaction(); + throw PDNSException("Target backend does not support comments - remove them first"); + } + } comm.domain_id = dstinfo.id; if (rewriteNames) { comm.qname.makeUsRelative(srcinfo.zone); -- 2.47.3