]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
simplify, also improve --config output, thanks @mind04
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Wed, 4 Nov 2020 13:43:55 +0000 (14:43 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Wed, 31 Mar 2021 10:46:24 +0000 (12:46 +0200)
pdns/common_startup.cc
pdns/dynhandler.cc
pdns/mastercommunicator.cc
pdns/packethandler.cc
pdns/receiver.cc
pdns/slavecommunicator.cc

index 7d646f5bfafe3317d0bb6f9c0cbd29dda40080f5..3635a66615b64c247ccaf019b0a20077a155e6bf 100644 (file)
@@ -578,7 +578,7 @@ void mainthread()
      }
 #endif
      triggerLoadOfLibraries();
-     if(::arg().mustDo("master") || ::arg().mustDo("slave") || ::arg().mustDo("primary") || ::arg().mustDo("secondary"))
+     if(::arg().mustDo("primary") || ::arg().mustDo("secondary"))
         gethostbyname("a.root-servers.net"); // this forces all lookup libraries to be loaded
      Utility::dropGroupPrivs(newuid, newgid);
      if(chroot(::arg()["chroot"].c_str())<0 || chdir("/")<0) {
@@ -655,7 +655,7 @@ void mainthread()
   if(::arg().mustDo("webserver") || ::arg().mustDo("api"))
     webserver.go();
 
-  if(::arg().mustDo("slave") || ::arg().mustDo("master") || ::arg().mustDo("primary") || ::arg().mustDo("secondary")|| !::arg()["forward-notify"].empty())
+  if(::arg().mustDo("primary") || ::arg().mustDo("secondary")|| !::arg()["forward-notify"].empty())
     Communicator.go(); 
 
   TN->go(); // tcp nameserver launch
index 96ab1ce4e831b1d3ff9bc126db4c03e8a2770eac..d78f38ccc1b4af63fa1843e50716265a9d2f496b 100644 (file)
@@ -289,7 +289,7 @@ string DLNotifyHostHandler(const vector<string>&parts, Utility::pid_t ppid)
   ostringstream os;
   if(parts.size()!=3)
     return "syntax: notify-host domain ip";
-  if(!(::arg().mustDo("master") || ::arg().mustDo("primary")) && !((::arg().mustDo("slave") || ::arg().mustDo("secondary")) && ::arg().mustDo("slave-renotify")))
+  if(!::arg().mustDo("primary") && !(::arg().mustDo("secondary") && ::arg().mustDo("secondary-renotify")))
       return "PowerDNS not configured as primary (master), or secondary (slave) with re-notifications";
 
   DNSName domain;
@@ -317,7 +317,7 @@ string DLNotifyHandler(const vector<string>&parts, Utility::pid_t ppid)
   UeberBackend B;
   if(parts.size()!=2)
     return "syntax: notify domain";
-  if(!(::arg().mustDo("master") || ::arg().mustDo("primary")) && !((::arg().mustDo("slave") || ::arg().mustDo("secondary")) && ::arg().mustDo("slave-renotify")))
+  if(!::arg().mustDo("primary") && !(::arg().mustDo("secondary") && ::arg().mustDo("secondary-renotify")))
       return "PowerDNS not configured as primary (master), or secondary (slave) with re-notifications";
   g_log<<Logger::Warning<<"Notification request for domain '"<<parts[1]<<"' received from operator"<<endl;
 
index 686b3706f1873053b1e0f16f0d24c16d4ae9c315..5f235e50a352af2dd747371cf6eb8ff468eb684b 100644 (file)
@@ -138,7 +138,7 @@ void NotificationQueue::dump()
 
 void CommunicatorClass::masterUpdateCheck(PacketHandler *P)
 {
-  if(!::arg().mustDo("master") && !::arg().mustDo("primary"))
+  if(!::arg().mustDo("primary"))
     return; 
 
   UeberBackend *B=P->getBackend();
index 5e77a80d764dcba7faaac9b304bef4b05b1947bc..f7fa4eb030ab54f4e25fed1c424cb002825c1109 100644 (file)
@@ -961,7 +961,7 @@ int PacketHandler::processNotify(const DNSPacket& p)
 
   g_log<<Logger::Debug<<"Received NOTIFY for "<<p.qdomain<<" from "<<p.getRemote()<<endl;
 
-  if(!::arg().mustDo("slave") && !::arg().mustDo("secondary") && s_forwardNotify.empty()) {
+  if(!::arg().mustDo("secondary") && s_forwardNotify.empty()) {
     g_log<<Logger::Warning<<"Received NOTIFY for "<<p.qdomain<<" from "<<p.getRemote()<<" but slave support is disabled in the configuration"<<endl;
     return RCode::Refused;
   }
@@ -996,7 +996,7 @@ int PacketHandler::processNotify(const DNSPacket& p)
   //
   DomainInfo di;
   if(!B.getDomainInfo(p.qdomain, di, false) || !di.backend) {
-    if(::arg().mustDo("superslave") || ::arg().mustDo("autosecondary")) {
+    if(::arg().mustDo("autosecondary")) {
       g_log<<Logger::Warning<<"Received NOTIFY for "<<p.qdomain<<" from "<<p.getRemote()<<" for which we are not authoritative, trying supermaster"<<endl;
       return trySuperMaster(p, p.getTSIGKeyname());
     }
@@ -1011,7 +1011,7 @@ int PacketHandler::processNotify(const DNSPacket& p)
     }
     g_log<<Logger::Notice<<"Received NOTIFY for "<<p.qdomain<<" from trusted-notification-proxy "<<p.getRemote()<<endl;
   }
-  else if((::arg().mustDo("master") || ::arg().mustDo("primary")) && di.kind == DomainInfo::Master) {
+  else if(::arg().mustDo("primary") && di.kind == DomainInfo::Master) {
     g_log<<Logger::Warning<<"Received NOTIFY for "<<p.qdomain<<" from "<<p.getRemote()<<" but we are master (Refused)"<<endl;
     return RCode::Refused;
   }
@@ -1028,7 +1028,7 @@ int PacketHandler::processNotify(const DNSPacket& p)
     }
   }
 
-  if(::arg().mustDo("slave") || ::arg().mustDo("secondary")) {
+  if(::arg().mustDo("secondary")) {
     g_log<<Logger::Notice<<"Received NOTIFY for "<<p.qdomain<<" from "<<p.getRemote()<<" - queueing check"<<endl;
     Communicator.addSlaveCheckRequest(di, p.d_remote);
   }
index 4ee85848947472218b6dd7e335b99a90d6f95bc5..8d1d461e87b06e36a6b9d17c58fc6e8f1cfc25be 100644 (file)
@@ -427,6 +427,17 @@ int main(int argc, char **argv)
         g_log<<Logger::Error<<"Unknown logging facility "<<::arg().asNum("logging-facility") <<endl;
     }
 
+    if (::arg().mustDo("master")) ::arg().set("primary")="yes";
+    if (::arg().mustDo("slave")) ::arg().set("secondary")="yes";
+    if (::arg().mustDo("slave-renotify")) ::arg().set("secondary-renotify")="yes";
+    if (::arg().mustDo("superslave")) ::arg().set("autosecondary")="yes";
+
+    // this mirroring back is on purpose, so that config dumps reflect the actual setting on both names
+    if (::arg().mustDo("primary")) ::arg().set("master")="yes";
+    if (::arg().mustDo("secondary")) ::arg().set("slave")="yes";
+    if (::arg().mustDo("secondary-renotify")) ::arg().set("slave-renotify")="yes";
+    if (::arg().mustDo("autosecondary")) ::arg().set("superslave")="yes";
+
     g_log.setLoglevel((Logger::Urgency)(::arg().asNum("loglevel")));
     g_log.disableSyslog(::arg().mustDo("disable-syslog"));
     g_log.setTimestamps(::arg().mustDo("log-timestamp"));
index 66cd7ee7072d38cb0262435a603e12b02710b6bc..ed41dbf9d4b539fb7987a3638e229518b6e0f0e5 100644 (file)
@@ -764,7 +764,7 @@ void CommunicatorClass::addTrySuperMasterRequest(const DNSPacket& p)
 void CommunicatorClass::slaveRefresh(PacketHandler *P)
 {
   // not unless we are slave
-  if (!::arg().mustDo("slave") && !::arg().mustDo("secondary")) return;
+  if (!::arg().mustDo("secondary")) return;
 
   UeberBackend *B=P->getBackend();
   vector<DomainInfo> rdomains;