]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: make feedComment return bool, have callers check it
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 9 Mar 2023 16:11:49 +0000 (17:11 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 9 Mar 2023 16:11:49 +0000 (17:11 +0100)
pdns/backends/gsql/gsqlbackend.cc
pdns/backends/gsql/gsqlbackend.hh
pdns/dnsbackend.hh
pdns/pdnsutil.cc
pdns/ws-auth.cc

index ead6243d68fa74e3299d415ab4af7bc5a47c4d4a..5a231e115bd866e896e1e89bf423fb61a01753b5 100644 (file)
@@ -1989,7 +1989,7 @@ bool GSQLBackend::getComment(Comment& comment)
   }
 }
 
-void GSQLBackend::feedComment(const Comment& comment)
+bool GSQLBackend::feedComment(const Comment& comment)
 {
   try {
     reconnectIfNeeded();
@@ -2007,6 +2007,8 @@ void GSQLBackend::feedComment(const Comment& comment)
   catch (SSqlException &e) {
     throw PDNSException("GSQLBackend unable to feed comment for RRSet '" + comment.qname.toLogString() + "|" + comment.qtype.toString() + "': "+e.txtReason());
   }
+
+  return true;
 }
 
 bool GSQLBackend::replaceComments(const uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<Comment>& comments)
index a7afbd13fe6d184f01d554cc23bbf4d981f77096..9ba76db92d0b0bada136ee77b43ab694c726ada9 100644 (file)
@@ -251,7 +251,7 @@ public:
 
   bool listComments(const uint32_t domain_id) override;
   bool getComment(Comment& comment) override;
-  void feedComment(const Comment& comment) override;
+  bool feedComment(const Comment& comment) override;
   bool replaceComments(const uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<Comment>& comments) override;
   string directBackendCmd(const string &query) override;
   bool searchRecords(const string &pattern, int maxResults, vector<DNSResourceRecord>& result) override;
index 244782da6cced7d5bf8696779365c1910bd6bd20..5859c77dceb1081e157c4f6cf77f7873247d106c 100644 (file)
@@ -268,8 +268,9 @@ public:
     return false;
   }
 
-  virtual void feedComment(const Comment& /* comment */)
+  virtual bool feedComment(const Comment& /* comment */)
   {
+    return false;
   }
 
   virtual bool replaceComments(const uint32_t /* domain_id */, const DNSName& /* qname */, const QType& /* qt */, const vector<Comment>& /* comments */)
index 03da0ac208437e000ba62c58c7678bedc9a31122..eb30fbec3b0ac6fcf009c724ccbae664d1597e8c 100644 (file)
@@ -4126,7 +4126,9 @@ try
         Comment c;
         while(src->getComment(c)) {
           c.domain_id = di_new.id;
-          tgt->feedComment(c);
+          if (!tgt->feedComment(c)) {
+            throw PDNSException("Target backend does not support comments - remove them first");
+          }
           nc++;
         }
       }
index c0827d1b666725fac374977cf36e0e585c2a395b..20d79875f68204d10d4cafb5218447114dcae7a9 100644 (file)
@@ -1829,7 +1829,9 @@ static void apiServerZones(HttpRequest* req, HttpResponse* resp) {
     }
     for(Comment& c : new_comments) {
       c.domain_id = di.id;
-      di.backend->feedComment(c);
+      if (!di.backend->feedComment(c)) {
+        throw ApiException("Hosting backend does not support editing comments.");
+      }
     }
 
     updateDomainSettingsFromDocument(B, di, zonename, document, !new_records.empty());