From a4e0f63258dab82dcc9dc27930de13e4d38b9fdc Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Wed, 15 Jan 2020 21:02:13 +0100 Subject: [PATCH] lmdb: fill di.serial --- modules/lmdbbackend/lmdbbackend.cc | 19 +++++++++++++++++++ pdns/pdnsutil.cc | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index a79b8d837c..020a275f17 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -811,6 +811,25 @@ bool LMDBBackend::getDomainInfo(const DNSName &domain, DomainInfo &di, bool getS if(!(di.id=txn.get<0>(domain, di))) return false; di.backend = this; + + di.serial = 0; + + if(getSerial) { + auto txn2 = getRecordsROTransaction(di.id); + compoundOrdername co; + MDBOutVal val; + + if(!txn2->txn->get(txn2->db->dbi, co(di.id, g_rootdnsname, QType::SOA), val)) { + DNSResourceRecord rr; + serFromString(val.get(), rr); + + if(rr.content.size() >= 5 * sizeof(uint32_t)) { + uint32_t serial = *reinterpret_cast(&rr.content[rr.content.size() - (5 * sizeof(uint32_t))]); + di.serial = ntohl(serial); + } + } + } + return true; } diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 9325291efb..918171deaa 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -1860,7 +1860,7 @@ static bool secureZone(DNSSECKeeper& dk, const DNSName& zone) DomainInfo di; UeberBackend B("default"); - if(!B.getDomainInfo(zone, di) || !di.backend) { // di.backend and B are mostly identical + if(!B.getDomainInfo(zone, di, false) || !di.backend) { // di.backend and B are mostly identical cerr<<"Can't find a zone called '"<