BOOST_CHECK_EQUAL(queriesCount, 0);
}
+BOOST_AUTO_TEST_CASE(test_answer_no_aa) {
+ std::unique_ptr<SyncRes> sr;
+ initSR(sr, true);
+
+ primeHints();
+
+ const DNSName target("powerdns.com.");
+
+ sr->setAsyncCallback([target](const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional<Netmask>& srcmask, boost::optional<const ResolveContext&> context, LWResult* res, bool* chained) {
+
+ setLWResult(res, 0, false, false, true);
+ addRecordToLW(res, domain, QType::A, "192.0.2.1");
+ return 1;
+ });
+
+ const time_t now = sr->getNow().tv_sec;
+
+ vector<DNSRecord> ret;
+ int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
+ BOOST_CHECK_EQUAL(res, RCode::ServFail);
+ BOOST_CHECK_EQUAL(ret.size(), 0);
+
+ /* check that the record in the answer section has not been cached */
+ const ComboAddress who;
+ vector<DNSRecord> cached;
+ vector<std::shared_ptr<RRSIGRecordContent>> signatures;
+ BOOST_REQUIRE_EQUAL(t_RC->get(now, target, QType(QType::A), false, &cached, who, &signatures), -1);
+}
+
BOOST_AUTO_TEST_CASE(test_special_types) {
std::unique_ptr<SyncRes> sr;
initSR(sr);
continue;
}
+ if (!(lwr.d_aabit || wasForwardRecurse) && rec.d_place == DNSResourceRecord::ANSWER) {
+ LOG("NO! - we don't accept records in the answers section without the AA bit set"<<endl);
+ continue;
+ }
+
if(rec.d_name.isPartOf(auth)) {
if(rec.d_type == QType::RRSIG) {
LOG("RRSIG - separate"<<endl);
/* if we forwarded the query to a recursor, we can expect the answer to be signed,
even if the answer is not AA. Of course that's not only true inside a Secure
zone, but we check that below. */
- bool expectSignature = isAA || wasForwardRecurse;
+ bool expectSignature = i->first.place == DNSResourceRecord::ANSWER || ((lwr.d_aabit || wasForwardRecurse) && i->first.place != DNSResourceRecord::ADDITIONAL);
if (isCNAMEAnswer && (i->first.place != DNSResourceRecord::ANSWER || i->first.type != QType::CNAME || i->first.name != qname)) {
/*
rfc2181 states:
if (rec.d_type!=QType::OPT && rec.d_class!=QClass::IN)
continue;
+ if (rec.d_place==DNSResourceRecord::ANSWER && !(lwr.d_aabit || sendRDQuery)) {
+ continue;
+ }
+
if(rec.d_place==DNSResourceRecord::AUTHORITY && rec.d_type==QType::SOA &&
lwr.d_rcode==RCode::NXDomain && qname.isPartOf(rec.d_name) && rec.d_name.isPartOf(auth)) {
LOG(prefix<<qname<<": got negative caching indication for name '"<<qname<<"' (accept="<<rec.d_name.isPartOf(auth)<<"), newtarget='"<<newtarget<<"'"<<endl);