From 98fa3598936dcc6782639141c82e6516b8f29e37 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 26 Nov 2018 12:11:14 +0100 Subject: [PATCH] auth: Handle ANY queries with Lua records --- pdns/dnsrecords.cc | 2 +- pdns/dnsrecords.hh | 2 +- pdns/lua-record.cc | 4 ++-- pdns/packethandler.cc | 10 ++++++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index eec772c368..4109a70c61 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -162,7 +162,7 @@ boilerplate_conv(OPT, QType::OPT, ); #ifdef HAVE_LUA_RECORDS -string LUARecordContent::getCode() +string LUARecordContent::getCode() const { // in d_code, series of "part1" "part2" vector parts; diff --git a/pdns/dnsrecords.hh b/pdns/dnsrecords.hh index 8f7ad2a6ab..353bbef31a 100644 --- a/pdns/dnsrecords.hh +++ b/pdns/dnsrecords.hh @@ -195,7 +195,7 @@ class LUARecordContent : public DNSRecordContent { public: includeboilerplate(LUA) - string getCode(); + string getCode() const; uint16_t d_type; string d_code; }; diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index 07aecc0bbd..9f189537da 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -860,9 +860,9 @@ std::vector> luaSynth(const std::string& code, cons for(const auto& content: contents) { if(qtype==QType::TXT) - ret.push_back(std::shared_ptr(DNSRecordContent::mastermake(qtype, 1, '"'+content+'"' ))); + ret.push_back(DNSRecordContent::mastermake(qtype, QClass::IN, '"'+content+'"' )); else - ret.push_back(std::shared_ptr(DNSRecordContent::mastermake(qtype, 1, content ))); + ret.push_back(DNSRecordContent::mastermake(qtype, QClass::IN, content )); } } catch(std::exception &e) { g_log<(rr.dr); - if(rec->d_type == QType::CNAME || rec->d_type == p->qtype.getCode()) { + if (!rec) { + continue; + } + if(rec->d_type == QType::CNAME || rec->d_type == p->qtype.getCode() || (p->qtype.getCode() == QType::ANY && rec->d_type != QType::RRSIG)) { // noCache=true; DLOG(g_log<<"Executing Lua: '"<getCode()<<"'"<(rr.dr); - if(rec->d_type == QType::CNAME || rec->d_type == p->qtype.getCode()) { + if (!rec) { + continue; + } + if(rec->d_type == QType::CNAME || rec->d_type == p->qtype.getCode() || (p->qtype.getCode() == QType::ANY && rec->d_type != QType::RRSIG)) { noCache=true; try { auto recvec=luaSynth(rec->getCode(), target, sd.qname, sd.domain_id, *p, rec->d_type); -- 2.39.5