]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge pull request #7787 from rgacogne/auth-api-replace-ent
authorRemi Gacogne <rgacogne@users.noreply.github.com>
Wed, 15 May 2019 08:43:35 +0000 (10:43 +0200)
committerGitHub <noreply@github.com>
Wed, 15 May 2019 08:43:35 +0000 (10:43 +0200)
auth: Fix ENTs removal when "replacing" new records via the API

1  2 
pdns/ws-auth.cc

diff --combined pdns/ws-auth.cc
index 7f5d1b7cde0554aa521e7329f28268c1ad68dd54,bf20af53c9e549219aafa5610168890350da785b..21396729caa9b996574d57932e3d98cd546a8dbf
@@@ -522,7 -522,7 +522,7 @@@ static void validateGatheredRRType(cons
    }
  }
  
 -static void gatherRecords(const Json container, const DNSName& qname, const QType qtype, const int ttl, vector<DNSResourceRecord>& new_records, vector<DNSResourceRecord>& new_ptrs) {
 +static void gatherRecords(const string& logprefix, const Json container, const DNSName& qname, const QType qtype, const int ttl, vector<DNSResourceRecord>& new_records, vector<DNSResourceRecord>& new_ptrs) {
    UeberBackend B;
    DNSResourceRecord rr;
    rr.qname = qname;
  
      if ((rr.qtype.getCode() == QType::A || rr.qtype.getCode() == QType::AAAA) &&
          boolFromJson(record, "set-ptr", false) == true) {
 +
 +      g_log<<Logger::Warning<<logprefix<<"API call uses deprecated set-ptr feature, please remove it"<<endl;
 +
        DNSResourceRecord ptr;
        makePtr(rr, &ptr);
  
@@@ -1555,7 -1552,7 +1555,7 @@@ static void apiServerZones(HttpRequest
          }
          if (rrset["records"].is_array()) {
            int ttl = intFromJson(rrset, "ttl");
 -          gatherRecords(rrset, qname, qtype, ttl, new_records, new_ptrs);
 +          gatherRecords(req->logprefix, rrset, qname, qtype, ttl, new_records, new_ptrs);
          }
          if (rrset["comments"].is_array()) {
            gatherComments(rrset, qname, qtype, new_comments);
@@@ -1986,7 -1983,7 +1986,7 @@@ static void patchZone(HttpRequest* req
            // ttl shouldn't be part of DELETE, and it shouldn't be required if we don't get new records.
            int ttl = intFromJson(rrset, "ttl");
            // new_ptrs is merged.
 -          gatherRecords(rrset, qname, qtype, ttl, new_records, new_ptrs);
 +          gatherRecords(req->logprefix, rrset, qname, qtype, ttl, new_records, new_ptrs);
  
            for(DNSResourceRecord& rr : new_records) {
              rr.domain_id = di.id;
            di.backend->lookup(QType(QType::ANY), qname);
            DNSResourceRecord rr;
            while (di.backend->get(rr)) {
-             if (qtype.getCode() == 0) {
+             if (rr.qtype.getCode() == 0) {
                ent_present = true;
+               /* that's fine, we will override it */
+               continue;
              }
              if (qtype.getCode() != rr.qtype.getCode()
                && (exclusiveEntryTypes.count(qtype.getCode()) != 0