]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
When copying/migrating zones, only complain about comments if there are any.
authorMiod Vallat <miod.vallat@powerdns.com>
Fri, 3 Oct 2025 05:25:22 +0000 (07:25 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Fri, 3 Oct 2025 05:25:22 +0000 (07:25 +0200)
Fixes: #16201
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
pdns/pdnsutil.cc

index 76b89ef2700858dfe7e1eec66891564846d98cc7..890e60cd350360260ede3eebaf36204526b3c1e4 100644 (file)
@@ -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);