]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth pdns.conf, pdnsutil, pdns_control: modern aliases for master/slave
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 3 Nov 2020 19:36:02 +0000 (20:36 +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/communicator.cc
pdns/dynhandler.cc
pdns/mastercommunicator.cc
pdns/packethandler.cc
pdns/pdnsutil.cc
pdns/slavecommunicator.cc
regression-tests/backends/gsqlite3-slave

index db4b4aa5dcbf7c6104286c8bf9ba379a94391d58..7d646f5bfafe3317d0bb6f9c0cbd29dda40080f5 100644 (file)
@@ -141,15 +141,19 @@ void declareArguments()
   ::arg().set("also-notify", "When notifying a domain, also notify these nameservers")="";
   ::arg().set("allow-notify-from","Allow AXFR NOTIFY from these IP ranges. If empty, drop all incoming notifies.")="0.0.0.0/0,::/0";
   ::arg().set("slave-cycle-interval","Schedule slave freshness checks once every .. seconds")="60";
+  ::arg().set("replication-cycle-interval","Schedule primary/secondary replication freshness checks once every .. seconds")="60";
 
   ::arg().set("tcp-control-address","If set, PowerDNS can be controlled over TCP on this address")="";
   ::arg().set("tcp-control-port","If set, PowerDNS can be controlled over TCP on this address")="53000";
   ::arg().set("tcp-control-secret","If set, PowerDNS can be controlled over TCP after passing this secret")="";
   ::arg().set("tcp-control-range","If set, remote control of PowerDNS is possible over these networks only")="127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10";
   
-  ::arg().setSwitch("slave","Act as a slave")="no";
-  ::arg().setSwitch("master","Act as a master")="no";
-  ::arg().setSwitch("superslave", "Act as a superslave")="no";
+  ::arg().setSwitch("slave","Act as a secondary")="no";
+  ::arg().setSwitch("secondary","Act as a secondary")="no";
+  ::arg().setSwitch("master","Act as a primary")="no";
+  ::arg().setSwitch("primary","Act as a primary")="no";
+  ::arg().setSwitch("superslave", "Act as a autosecondary (formerly superslave)")="no";
+  ::arg().setSwitch("autosecondary", "Act as an autosecondary")="no";
   ::arg().setSwitch("disable-axfr-rectify","Disable the rectify step during an outgoing AXFR. Only required for regression testing.")="no";
   ::arg().setSwitch("guardian","Run within a guardian process")="no";
   ::arg().setSwitch("prevent-self-notification","Don't send notifications to what we think is ourself")="yes";
@@ -184,7 +188,8 @@ void declareArguments()
   ::arg().set("domain-metadata-cache-ttl","Seconds to cache domain metadata from the database")="60";
 
   ::arg().set("trusted-notification-proxy", "IP address of incoming notification proxy")="";
-  ::arg().set("slave-renotify", "If we should send out notifications for slaved updates")="no";
+  ::arg().set("slave-renotify", "If we should send out notifications for secondaried updates")="no";
+  ::arg().set("secondary-renotify", "If we should send out notifications for secondaried updates")="no";
   ::arg().set("forward-notify", "IP addresses to forward received notifications to regardless of master or slave settings")="";
 
   ::arg().set("default-ttl","Seconds a result is valid if not set otherwise")="3600";
@@ -573,7 +578,7 @@ void mainthread()
      }
 #endif
      triggerLoadOfLibraries();
-     if(::arg().mustDo("master") || ::arg().mustDo("slave"))
+     if(::arg().mustDo("master") || ::arg().mustDo("slave") || ::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) {
@@ -650,7 +655,7 @@ void mainthread()
   if(::arg().mustDo("webserver") || ::arg().mustDo("api"))
     webserver.go();
 
-  if(::arg().mustDo("slave") || ::arg().mustDo("master") || !::arg()["forward-notify"].empty())
+  if(::arg().mustDo("slave") || ::arg().mustDo("master") || ::arg().mustDo("primary") || ::arg().mustDo("secondary")|| !::arg()["forward-notify"].empty())
     Communicator.go(); 
 
   TN->go(); // tcp nameserver launch
index 19135f8c869b0f412d12e01c68d183f857403d3b..dda4909456cdde03cf29e73664da0eb1661f55e3 100644 (file)
@@ -112,9 +112,9 @@ void CommunicatorClass::mainloop()
   try {
     setThreadName("pdns/comm-main");
     signal(SIGPIPE,SIG_IGN);
-    g_log<<Logger::Error<<"Master/slave communicator launching"<<endl;
+    g_log<<Logger::Error<<"Primary/secondary communicator launching"<<endl;
     PacketHandler P;
-    d_tickinterval=::arg().asNum("slave-cycle-interval");
+    d_tickinterval=min(::arg().asNum("slave-cycle-interval"), ::arg().asNum("replication-cycle-interval"));
     makeNotifySockets();
 
     int rc;
index 8926738f5673cc9612c9d3eb046bbb2be10d31f3..96ab1ce4e831b1d3ff9bc126db4c03e8a2770eac 100644 (file)
@@ -289,8 +289,8 @@ 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("slave") && ::arg().mustDo("slave-renotify")))
-      return "PowerDNS not configured as master or slave with re-notifications";
+  if(!(::arg().mustDo("master") || ::arg().mustDo("primary")) && !((::arg().mustDo("slave") || ::arg().mustDo("secondary")) && ::arg().mustDo("slave-renotify")))
+      return "PowerDNS not configured as primary (master), or secondary (slave) with re-notifications";
 
   DNSName domain;
   try {
@@ -317,8 +317,8 @@ 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("slave") && ::arg().mustDo("slave-renotify")))
-      return "PowerDNS not configured as master or slave with re-notifications";
+  if(!(::arg().mustDo("master") || ::arg().mustDo("primary")) && !((::arg().mustDo("slave") || ::arg().mustDo("secondary")) && ::arg().mustDo("slave-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;
 
   if (parts[1] == "*") {
@@ -384,9 +384,9 @@ string DLListZones(const vector<string>&parts, Utility::pid_t ppid)
   ostringstream ret;
   int kindFilter = -1;
   if (parts.size() > 1) {
-    if (toUpper(parts[1]) == "MASTER")
+    if (toUpper(parts[1]) == "MASTER" || toUpper(parts[1]) == "PRIMARY")
       kindFilter = 0;
-    else if (toUpper(parts[1]) == "SLAVE")
+    else if (toUpper(parts[1]) == "SLAVE" || toUpper(parts[1]) == "SECONDARY")
       kindFilter = 1;
     else if (toUpper(parts[1]) == "NATIVE")
       kindFilter = 2;
index 624a2e65d3b0a95fa7c6283a9e4d6bcbf064c92d..686b3706f1873053b1e0f16f0d24c16d4ae9c315 100644 (file)
@@ -138,7 +138,7 @@ void NotificationQueue::dump()
 
 void CommunicatorClass::masterUpdateCheck(PacketHandler *P)
 {
-  if(!::arg().mustDo("master"))
+  if(!::arg().mustDo("master") && !::arg().mustDo("primary"))
     return; 
 
   UeberBackend *B=P->getBackend();
index fb3ed7a8837cd001f18643efa0e972fd717887ae..5e77a80d764dcba7faaac9b304bef4b05b1947bc 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") && s_forwardNotify.empty()) {
+  if(!::arg().mustDo("slave") && !::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")) {
+    if(::arg().mustDo("superslave") || ::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") && di.kind == DomainInfo::Master) {
+  else if((::arg().mustDo("master") || ::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")) {
+  if(::arg().mustDo("slave") || ::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 0660951281c8c923c4bf54e5ca948b337bd573d9..45d1b1896acdf068e6f400c1d67868d739c98d8a 100644 (file)
@@ -3271,14 +3271,14 @@ try
   } else if (cmds[0]=="activate-tsig-key") {
      string metaKey;
      if (cmds.size() < 4) {
-        cerr << "Syntax: " << cmds[0] << " ZONE NAME {master|slave}" << endl;
+        cerr << "Syntax: " << cmds[0] << " ZONE NAME {primary|secondary|master|slave}" << endl;
         return 0;
      }
      DNSName zname(cmds[1]);
      string name = cmds[2];
-     if (cmds[3] == "master")
+     if (cmds[3] == "master" || cmds[3] == "primary")
         metaKey = "TSIG-ALLOW-AXFR";
-     else if (cmds[3] == "slave")
+     else if (cmds[3] == "slave" || cmds[3] == "secondary")
         metaKey = "AXFR-MASTER-TSIG";
      else {
         cerr << "Invalid parameter '" << cmds[3] << "', expected master or slave" << endl;
@@ -3315,9 +3315,9 @@ try
      }
      DNSName zname(cmds[1]);
      string name = cmds[2];
-     if (cmds[3] == "master")
+     if (cmds[3] == "master" || cmds[3] == "primary")
         metaKey = "TSIG-ALLOW-AXFR";
-     else if (cmds[3] == "slave")
+     else if (cmds[3] == "slave" || cmds[3] == "secondary")
         metaKey = "AXFR-MASTER-TSIG";
      else {
         cerr << "Invalid parameter '" << cmds[3] << "', expected master or slave" << endl;
index 924113672f84a1e2546430b332e4a052336c2cb9..66cd7ee7072d38cb0262435a603e12b02710b6bc 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")) return;
+  if (!::arg().mustDo("slave") && !::arg().mustDo("secondary")) return;
 
   UeberBackend *B=P->getBackend();
   vector<DomainInfo> rdomains;
index e5afc84aa9e43c6b0a2ae56a7d3ad4b0f0e2bd66..5e5551a34674346073c23ff10fa8f2fd9755f53e 100644 (file)
@@ -34,8 +34,8 @@ __EOF__
 
        $RUNWRAPPER $PDNS2 --daemon=no --local-port=$port --config-dir=. \
                --config-name=gsqlite32 --socket-dir=./ --no-shuffle \
-               --slave --retrieval-threads=4 \
-               --slave-cycle-interval=300 --dname-processing &
+               --secondary --retrieval-threads=4 \
+               --replication-cycle-interval=300 --dname-processing &
 
        echo 'waiting for zones to be slaved'
        set +e