]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
In zone copy, proceed anyway if --force even if target doesn't support comments.
authorMiod Vallat <miod.vallat@powerdns.com>
Mon, 13 Oct 2025 11:52:48 +0000 (13:52 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Thu, 23 Oct 2025 09:28:11 +0000 (11:28 +0200)
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
(cherry picked from commit 516d38c2037c39fcc1833f49c8aa4e2fe263e12a)

pdns/pdnsutil.cc

index 4482b4effae03e59180cc089e37b58d07fdbaea2..08417c52bf04bd6c67a4834970ebecdcb45b90a3 100644 (file)
@@ -5056,23 +5056,29 @@ static int B2BMigrate(vector<string>& cmds, const std::string_view synopsis)
     nc=0;
     if (src->listComments(di.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");
+            }
           }
         }
-        comm.domain_id = di_new.id;
-        if (!tgt->feedComment(comm)) {
-          tgt->abortTransaction();
-          throw PDNSException("Failed to feed zone comments");
+        if (copyComments) {
+          comm.domain_id = di_new.id;
+          if (!tgt->feedComment(comm)) {
+            tgt->abortTransaction();
+            throw PDNSException("Failed to feed zone comments");
+          }
+          nc++;
         }
-        nc++;
       }
     }
     // move metadata