From: Peter van Dijk Date: Thu, 9 Mar 2023 16:11:49 +0000 (+0100) Subject: auth: make feedComment return bool, have callers check it X-Git-Tag: auth-4.8.0-beta1~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f79eef0540ac7e819a9027361d0cd97f01a123d4;p=thirdparty%2Fpdns.git auth: make feedComment return bool, have callers check it --- diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index ead6243d68..5a231e115b 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -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& comments) diff --git a/pdns/backends/gsql/gsqlbackend.hh b/pdns/backends/gsql/gsqlbackend.hh index a7afbd13fe..9ba76db92d 100644 --- a/pdns/backends/gsql/gsqlbackend.hh +++ b/pdns/backends/gsql/gsqlbackend.hh @@ -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& comments) override; string directBackendCmd(const string &query) override; bool searchRecords(const string &pattern, int maxResults, vector& result) override; diff --git a/pdns/dnsbackend.hh b/pdns/dnsbackend.hh index 244782da6c..5859c77dce 100644 --- a/pdns/dnsbackend.hh +++ b/pdns/dnsbackend.hh @@ -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& /* comments */) diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 03da0ac208..eb30fbec3b 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -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++; } } diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index c0827d1b66..20d79875f6 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -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());