From 8b0f2ac7e3992089e9e805f848c1cd6e54b4a975 Mon Sep 17 00:00:00 2001 From: Charles-Henri Bruyand Date: Mon, 19 Mar 2018 19:47:25 +0100 Subject: [PATCH] auth: fix regression while handling user-defined axfr filters return values, and a typo in a documentation example --- docs/modes-of-operation.rst | 6 +++--- pdns/lua-auth4.cc | 11 +++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/modes-of-operation.rst b/docs/modes-of-operation.rst index 69b17b6d2a0c..365eab4b66a2 100644 --- a/docs/modes-of-operation.rst +++ b/docs/modes-of-operation.rst @@ -272,7 +272,7 @@ Consider the following simple example: if record:qtype() == pdns.HINFO then resp = {} resp[1] = { - qname = record:qname:toString(), + qname = record:qname():toString(), qtype = pdns.TXT, ttl = 99, content = "Hello Ahu!" @@ -281,7 +281,7 @@ Consider the following simple example: end -- Grab each _tstamp TXT record and add a time stamp - if record:qtype() == pdns.TXT and string.starts(record:qname:toString(), "_tstamp.") then + if record:qtype() == pdns.TXT and string.starts(record:qname():toString(), "_tstamp.") then resp = {} resp[1] = { qname = record:qname():toString(), @@ -296,7 +296,7 @@ Consider the following simple example: if record:qtype() == pdns.A then resp = {} resp[1] = { - qname = record:qname:toString(), + qname = record:qname():toString(), qtype = pdns.TXT, ttl = 99, content = "Hello Ahu, again!" diff --git a/pdns/lua-auth4.cc b/pdns/lua-auth4.cc index db9bb0ab37ba..f7a3414ad1ce 100644 --- a/pdns/lua-auth4.cc +++ b/pdns/lua-auth4.cc @@ -113,10 +113,17 @@ bool AuthLua4::axfrfilter(const ComboAddress& remote, const DNSName& zone, const ret = d_axfr_filter(remote, zone, in); rcode = std::get<0>(ret); - if (rcode < 0) + if (rcode < 0) { + // no modification, handle normally return false; - else if (rcode == 1) + } + else if (rcode == 0) { + // replace the matching record by the filtered record(s) + } + else if (rcode == 1) { + // append the filtered record(s) after the matching record out.push_back(in); + } else throw PDNSException("Cannot understand return code "+std::to_string(rcode)+" in axfr filter response");