From: Kees Monshouwer Date: Thu, 1 Jun 2017 23:08:27 +0000 (+0200) Subject: auth: keep slave dnssec status in sync with the master X-Git-Tag: rec-4.1.0-alpha1~92^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fa35c07102ceeb5e14214bd9d43156c5ed1d3d9;p=thirdparty%2Fpdns.git auth: keep slave dnssec status in sync with the master --- diff --git a/pdns/dbdnsseckeeper.cc b/pdns/dbdnsseckeeper.cc index d3bfff3737..35e7097709 100644 --- a/pdns/dbdnsseckeeper.cc +++ b/pdns/dbdnsseckeeper.cc @@ -51,6 +51,11 @@ pthread_rwlock_t DNSSECKeeper::s_keycachelock = PTHREAD_RWLOCK_INITIALIZER; AtomicCounter DNSSECKeeper::s_ops; time_t DNSSECKeeper::s_last_prune; +bool DNSSECKeeper::doesDNSSEC() +{ + return d_keymetadb->doesDNSSEC(); +} + bool DNSSECKeeper::isSecuredZone(const DNSName& zone) { if(isPresigned(zone)) diff --git a/pdns/dnsseckeeper.hh b/pdns/dnsseckeeper.hh index 73b4b89fd1..da79a796ad 100644 --- a/pdns/dnsseckeeper.hh +++ b/pdns/dnsseckeeper.hh @@ -156,6 +156,7 @@ public: if(d_ourDB) delete d_keymetadb; } + bool doesDNSSEC(); bool isSecuredZone(const DNSName& zone); static uint64_t dbdnssecCacheSizes(const std::string& str); keyset_t getEntryPoints(const DNSName& zname); diff --git a/pdns/slavecommunicator.cc b/pdns/slavecommunicator.cc index 6731862fd4..c58f10c973 100644 --- a/pdns/slavecommunicator.cc +++ b/pdns/slavecommunicator.cc @@ -779,7 +779,7 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P) DomainNotificationInfo dni; dni.di=di; - dni.dnssecOk = dk.isPresigned(di.zone); + dni.dnssecOk = dk.doesDNSSEC(); if(dk.getTSIGForAccess(di.zone, sr.master, &dni.tsigkeyname)) { string secret64; @@ -874,14 +874,10 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P) di.backend->setFresh(di.id); } else if(theirserial == ourserial) { - if(!dk.isPresigned(di.zone)) { - L<setFresh(di.id); - } - else { + uint32_t maxExpire=0, maxInception=0; + if(dk.isPresigned(di.zone)) { B->lookup(QType(QType::RRSIG), di.zone); // can't use DK before we are done with this lookup! DNSZoneRecord zr; - uint32_t maxExpire=0, maxInception=0; while(B->get(zr)) { auto rrsig = getRR(zr.dr); if(rrsig->d_type == QType::SOA) { @@ -889,14 +885,30 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P) maxExpire = std::max(maxExpire, rrsig->d_sigexpire); } } - if(maxInception == ssr.d_freshness[di.id].theirInception && maxExpire == ssr.d_freshness[di.id].theirExpire) { - L<setFresh(di.id); - } - else { - L<setFresh(di.id); + } + else if(maxInception == ssr.d_freshness[di.id].theirInception && maxExpire == ssr.d_freshness[di.id].theirExpire) { + L<setFresh(di.id); + } + else if(maxExpire >= now && ! ssr.d_freshness[di.id].theirInception ) { + L<setFresh(di.id); + } + else if(maxInception && ! ssr.d_freshness[di.id].theirInception ) { + L<doesDNSSEC()) + return true; + } + return false; +} + bool UeberBackend::addDomainKey(const DNSName& name, const DNSBackend::KeyData& key, int64_t& id) { id = -1; diff --git a/pdns/ueberbackend.hh b/pdns/ueberbackend.hh index c6989ddded..37ab30d884 100644 --- a/pdns/ueberbackend.hh +++ b/pdns/ueberbackend.hh @@ -109,6 +109,7 @@ public: bool getDomainInfo(const DNSName &domain, DomainInfo &di); bool createDomain(const DNSName &domain); + bool doesDNSSEC(); bool addDomainKey(const DNSName& name, const DNSBackend::KeyData& key, int64_t& id); bool getDomainKeys(const DNSName& name, std::vector& keys); bool getAllDomainMetadata(const DNSName& name, std::map >& meta);