]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
In zone copy, proceed anyway if --force even if target doesn't support comments. 16209/head
authorMiod Vallat <miod.vallat@powerdns.com>
Mon, 13 Oct 2025 11:52:48 +0000 (13:52 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Mon, 13 Oct 2025 11:52:48 +0000 (13:52 +0200)
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
pdns/pdnsutil.cc

index 890e60cd350360260ede3eebaf36204526b3c1e4..d9cc2251c6f99d2a8330d6118794b87c4881d436 100644 (file)
@@ -1889,27 +1889,33 @@ static void copyZoneContents(const DomainInfo& srcinfo, const ZoneName& dstzone,
   // Copy comments, if any
   if (src->listComments(srcinfo.id)) {
     bool firstComment{true};
+    bool copyComments{true};
     Comment 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");
+          if (g_force) {
+            copyComments = false;
+          }
+          else {
+            tgt->abortTransaction();
+            throw PDNSException("Target backend does not support comments - remove them first or use --force");
+          }
         }
       }
-      comm.domain_id = dstinfo.id;
-      if (rewriteNames) {
-        comm.qname.makeUsRelative(srcinfo.zone);
-        comm.qname += dstzone.operator const DNSName&();
-      }
-      if (!tgt->feedComment(comm)) {
-        tgt->abortTransaction();
-        throw PDNSException("Failed to feed zone comments");
+      if (copyComments) {
+        comm.domain_id = dstinfo.id;
+        if (rewriteNames) {
+          comm.qname.makeUsRelative(srcinfo.zone);
+          comm.qname += dstzone.operator const DNSName&();
+        }
+        if (!tgt->feedComment(comm)) {
+          tgt->abortTransaction();
+          throw PDNSException("Failed to feed zone comments");
+        }
+        num_comments++;
       }
-      num_comments++;
     }
   }