From 7731e32c57f1153dabe5e402caf8aaa919cdb5d1 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Sun, 14 Jun 2015 21:14:36 +0300 Subject: [PATCH] In supermaster mode, set TSIG key used as domain's TSIG key --- pdns/packethandler.cc | 32 +++++++++++++------------------- pdns/packethandler.hh | 4 ++-- pdns/slavecommunicator.cc | 7 ++++++- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index cc028dbc4..6e8e45692 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -765,13 +765,13 @@ How MySQLBackend would implement this: */ -int PacketHandler::trySuperMaster(DNSPacket *p) +int PacketHandler::trySuperMaster(DNSPacket *p, const string& tsigkeyname) { if(p->d_tcp) { // do it right now if the client is TCP // rarely happens - return trySuperMasterSynchronous(p); + return trySuperMasterSynchronous(p, tsigkeyname); } else { @@ -781,7 +781,7 @@ int PacketHandler::trySuperMaster(DNSPacket *p) } } -int PacketHandler::trySuperMasterSynchronous(DNSPacket *p) +int PacketHandler::trySuperMasterSynchronous(DNSPacket *p, const string& tsigkeyname) { Resolver::res_t nsset; try { @@ -819,6 +819,11 @@ int PacketHandler::trySuperMasterSynchronous(DNSPacket *p) } try { db->createSlaveDomain(p->getRemote(), p->qdomain, nameserver, account); + if (tsigkeyname.empty() == false) { + vector meta; + meta.push_back(tsigkeyname); + db->setDomainMetadata(p->qdomain, "AXFR-MASTER-TSIG", meta); + } } catch(PDNSException& ae) { L<qdomain<<" for potential supermaster "<getRemote()<<": "< do stuff */ vector meta; - string tsigkeyname; if(!::arg().mustDo("slave")) { L<qdomain<<" from "<getRemote()<<" but slave support is disabled in the configuration"<d_remote ) || p->d_havetsig) { - if (p->d_havetsig) { - TSIGRecordContent trc; - UeberBackend B; - string tsigsecret; - - if (!checkForCorrectTSIG(p, &B, &tsigkeyname, &tsigsecret, &trc)) { - L<qdomain<<" from "<getRemote()<<" but TSIG key '"<qdomain<<" from "<getRemote()<<", allowed by TSIG key '"<d_havetsig && p->getTSIGKeyname().empty() == false) { + L<qdomain<<" from "<getRemote()<<", allowed by TSIG key '"<getTSIGKeyname()<<"'"<qdomain<<" from "<getRemote()<<" but remote is not permitted by TSIG or allow-notify-from"<qdomain, di) || !(db=di.backend)) { L<qdomain<<" from "<getRemote()<<" for which we are not authoritative"<getTSIGKeyname()); } - meta.clear(); if (B.getDomainMetadata(p->qdomain,"AXFR-MASTER-TSIG",meta) && meta.size() > 0) { - if (!p->d_havetsig || meta[0] != tsigkeyname) { - L<qdomain<<" from "<getRemote()<<": expected TSIG key '"<d_havetsig || meta[0] != p->getTSIGKeyname()) { + L<qdomain<<" from "<getRemote()<<": expected TSIG key '"<getTSIGKeyname()<<"'"<trySuperMasterSynchronous(&dp); + res=P->trySuperMasterSynchronous(&dp, tsigkeyname); if(res>=0) { DNSPacket *r=dp.replyPacket(); r->setRcode(res); -- 2.40.0