]> granicus.if.org Git - pdns/commitdiff
first preparatory commit towards making the auth server safe for boost::multi_index
authorBert Hubert <bert.hubert@netherlabs.nl>
Sun, 22 Jun 2008 20:02:23 +0000 (20:02 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sun, 22 Jun 2008 20:02:23 +0000 (20:02 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1215 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/communicator.cc
pdns/distributor.hh
pdns/dnsproxy.cc
pdns/dynhandler.cc
pdns/resolver.cc
pdns/tcpreceiver.cc

index 62eeae2dc2b4c82a589e8ae354da96d27e986a14..912535abfa65f509b05f08066baadc17d4946a7a 100644 (file)
@@ -15,7 +15,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
-
+#include "packetcache.hh"
 #include "utility.hh"
 #include <errno.h>
 #include "communicator.hh"
@@ -197,7 +197,7 @@ bool CommunicatorClass::notifyDomain(const string &domain)
 
 void CommunicatorClass::masterUpdateCheck(PacketHandler *P)
 {
-  if(!arg().mustDo("master"))
+  if(!::arg().mustDo("master"))
     return; 
 
   UeberBackend *B=dynamic_cast<UeberBackend *>(P->getBackend());
@@ -369,7 +369,7 @@ void CommunicatorClass::makeNotifySocket()
   sin.sin_family = AF_INET;
 
   // Bind to a specific IP (query-local-address) if specified
-  string querylocaladdress(arg()["query-local-address"]);
+  string querylocaladdress(::arg()["query-local-address"]);
   if (querylocaladdress=="") {
     sin.sin_addr.s_addr = INADDR_ANY;
   }
@@ -390,7 +390,7 @@ void CommunicatorClass::makeNotifySocket()
   for(;n<10;n++) {
     sin.sin_port = htons(10000+(Utility::random()%50000));
     
-    if(bind(d_nsock, (struct sockaddr *)&sin, sizeof(sin)) >= 0) 
+    if(::bind(d_nsock, (struct sockaddr *)&sin, sizeof(sin)) >= 0) 
       break;
   }
   if(n==10) {
@@ -418,7 +418,7 @@ void CommunicatorClass::mainloop(void)
 #endif // WIN32
     L<<Logger::Error<<"Master/slave communicator launching"<<endl;
     PacketHandler P;
-    d_tickinterval=arg().asNum("slave-cycle-interval");
+    d_tickinterval=::arg().asNum("slave-cycle-interval");
     makeNotifySocket();
 
     int rc;
index a507214709cc10a59298d425cebd95fe548ed601..23c99c2a4e3091d7159dff8cdc84bc385d277191 100644 (file)
@@ -151,7 +151,7 @@ template<class Answer, class Question, class Backend>void *Distributor<Answer,Qu
 
     // this is so gross
 #ifndef SMTPREDIR 
-    int queuetimeout=arg().asNum("queue-limit"); 
+    int queuetimeout=::arg().asNum("queue-limit"); 
 #endif 
     // ick ick ick!
 
@@ -287,8 +287,8 @@ template<class Answer, class Question, class Backend>int Distributor<Answer,Ques
   if(!(nextid%50)) {
     int val;
     numquestions.getValue( &val );
-    if(val>arg().asNum("max-queue-length")) {
-      L<<Logger::Error<<val<<" questions waiting for database attention. Limit is "<<arg().asNum("max-queue-length")<<", respawning"<<endl;
+    if(val>::arg().asNum("max-queue-length")) {
+      L<<Logger::Error<<val<<" questions waiting for database attention. Limit is "<<::arg().asNum("max-queue-length")<<", respawning"<<endl;
       exit(1);
     }
   }
index 768ddb114b2bba71c1defbff60740baa419334ef..d09f91c6fda2d958ec647e2b6a1f48060d57adc1 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2004  PowerDNS.COM BV
+    Copyright (C) 2004 - 2008 PowerDNS.COM BV
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 as 
@@ -15,6 +15,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
+#include "packetcache.hh"
 #include "utility.hh"
 #include "dnsproxy.hh"
 #include "ahuexception.hh"
@@ -23,7 +24,7 @@
 #include "dns.hh"
 #include "logger.hh"
 #include "statbag.hh"
-#include "packetcache.hh"
+
 
 extern StatBag S;
 extern PacketCache PC;
@@ -50,7 +51,7 @@ DNSProxy::DNSProxy(const string &remote)
   for(;n<10;n++) {
     sin.sin_port = htons(10000+( Utility::random()%50000));
     
-    if(bind(d_sock, (struct sockaddr *)&sin, sizeof(sin)) >= 0) 
+    if(::bind(d_sock, (struct sockaddr *)&sin, sizeof(sin)) >= 0) 
       break;
   }
   if(n==10) {
index c120466e1766d7eb8aa6c38f9b613ba3654ec3c4..05eb3dad9faf72448614a26b8f37a011fd7354a5 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2002 - 2005  PowerDNS.COM BV
+    Copyright (C) 2002 - 2008  PowerDNS.COM BV
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 as 
@@ -15,6 +15,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
+#include "packetcache.hh"
 #include "utility.hh"
 #include "dynhandler.hh"
 #include "statbag.hh"
@@ -164,7 +165,7 @@ string DLSettingsHandler(const vector<string>&parts, Utility::pid_t ppid)
     if(*p==parts[1])
       break;
   if(*p) {
-    arg().set(parts[1])=parts[2];
+    ::arg().set(parts[1])=parts[2];
     return "done";
   }
   else
index cff098bcabdf1fcb77467ef900a8087cfb95ec0d..3c2c18150b79cb109fbc75aba0c6d1bc772ae84d 100644 (file)
@@ -15,6 +15,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
+#include "packetcache.hh"
 #include "utility.hh"
 #include "resolver.hh"
 #include <pthread.h>
@@ -61,14 +62,14 @@ void Resolver::makeSocket(int type)
   memset((char *)&sin,0, sizeof(sin));
   
   sin.sin_family = AF_INET;
-  if(!IpToU32(arg()["query-local-address"], &sin.sin_addr.s_addr))
-    throw AhuException("Unable to resolve local address '"+ arg()["query-local-address"] +"'"); 
+  if(!IpToU32(::arg()["query-local-address"], &sin.sin_addr.s_addr))
+    throw AhuException("Unable to resolve local address '"+ ::arg()["query-local-address"] +"'"); 
 
   int tries=10;
   while(--tries) {
     sin.sin_port = htons(10000+(dns_random(10000)));
   
-    if (bind(d_sock, (struct sockaddr *)&sin, sizeof(sin)) >= 0) 
+    if (::bind(d_sock, (struct sockaddr *)&sin, sizeof(sin)) >= 0) 
       break;
 
   }
@@ -228,11 +229,11 @@ void Resolver::makeTCPSocket(const string &ip, uint16_t port)
     throw ResolverException("Unable to make a TCP socket for resolver: "+stringerror());
 
   // Use query-local-address as source IP for queries, if specified.
-  string querylocaladdress(arg()["query-local-address"]);
+  string querylocaladdress(::arg()["query-local-address"]);
   if (!querylocaladdress.empty()) {
     ComboAddress fromaddr(querylocaladdress, 0);
 
-    if (bind(d_sock, (struct sockaddr *)&fromaddr, fromaddr.getSocklen()) < 0) {
+    if (::bind(d_sock, (struct sockaddr *)&fromaddr, fromaddr.getSocklen()) < 0) {
       Utility::closesocket(d_sock);
       d_sock=-1;
       throw ResolverException("Binding to query-local-address: "+stringerror());
index c52783c1eff4418a9c0904ca5236e98cfa76b7f1..e7a323791bc1f08610e750894dcf3965666bc65c 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2002-2007  PowerDNS.COM BV
+    Copyright (C) 2002-2008  PowerDNS.COM BV
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2
@@ -15,6 +15,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
+#include "packetcache.hh"
 #include "utility.hh"
 #include <cstdio>
 #include <cstring>
@@ -34,7 +35,7 @@
 #include "lock.hh"
 #include "logger.hh"
 #include "arguments.hh"
-#include "packetcache.hh"
+
 #include "packethandler.hh"
 #include "statbag.hh"
 #include "resolver.hh"
@@ -195,7 +196,7 @@ static void proxyQuestion(shared_ptr<DNSPacket> packet)
   Utility::setNonBlocking(sock);
   ServiceTuple st;
   st.port=53;
-  parseService(arg()["recursor"],st);
+  parseService(::arg()["recursor"],st);
 
   try {
     ComboAddress recursor(st.host, st.port);
@@ -337,10 +338,10 @@ void *TCPNameserver::doConnection(void *data)
 
 bool TCPNameserver::canDoAXFR(shared_ptr<DNSPacket> q)
 {
-  if(arg().mustDo("disable-axfr"))
+  if(::arg().mustDo("disable-axfr"))
     return false;
 
-  if( arg()["allow-axfr-ips"].empty() || d_ng.match( (ComboAddress *) &q->remote ) )
+  if( ::arg()["allow-axfr-ips"].empty() || d_ng.match( (ComboAddress *) &q->remote ) )
     return true;
 
   extern CommunicatorClass Communicator;
@@ -438,7 +439,7 @@ int TCPNameserver::doAXFR(const string &target, shared_ptr<DNSPacket> q, int out
 
   int count=0;
   int chunk=100; // FIXME: this should probably be autosizing
-  if(arg().mustDo("strict-rfc-axfrs"))
+  if(::arg().mustDo("strict-rfc-axfrs"))
     chunk=1;
 
   outpacket=shared_ptr<DNSPacket>(q->replyPacket());
@@ -482,15 +483,15 @@ TCPNameserver::~TCPNameserver()
 
 TCPNameserver::TCPNameserver()
 {
-//  sem_init(&d_connectionroom_sem,0,arg().asNum("max-tcp-connections"));
-  d_connectionroom_sem = new Semaphore( arg().asNum( "max-tcp-connections" ));
+//  sem_init(&d_connectionroom_sem,0,::arg().asNum("max-tcp-connections"));
+  d_connectionroom_sem = new Semaphore( ::arg().asNum( "max-tcp-connections" ));
 
   s_timeout=10;
   vector<string>locals;
-  stringtok(locals,arg()["local-address"]," ,");
+  stringtok(locals,::arg()["local-address"]," ,");
 
   vector<string>locals6;
-  stringtok(locals6,arg()["local-ipv6"]," ,");
+  stringtok(locals6,::arg()["local-ipv6"]," ,");
 
   if(locals.empty() && locals6.empty())
     throw AhuException("No local address specified");
@@ -498,7 +499,7 @@ TCPNameserver::TCPNameserver()
   d_highfd=0;
 
   vector<string> parts;
-  stringtok( parts, arg()["allow-axfr-ips"], ", \t" ); // is this IP on the guestlist?
+  stringtok( parts, ::arg()["allow-axfr-ips"], ", \t" ); // is this IP on the guestlist?
   for( vector<string>::const_iterator i = parts.begin(); i != parts.end(); ++i ) {
     d_ng.addMask( *i );
   }
@@ -514,7 +515,7 @@ TCPNameserver::TCPNameserver()
     if(s<0) 
       throw AhuException("Unable to acquire TCP socket: "+stringerror());
 
-    ComboAddress local(*laddr, arg().asNum("local-port"));
+    ComboAddress local(*laddr, ::arg().asNum("local-port"));
       
     int tmp=1;
     if(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) {
@@ -522,7 +523,7 @@ TCPNameserver::TCPNameserver()
       exit(1);  
     }
 
-    if(bind(s, (sockaddr*)&local, local.getSocklen())<0) {
+    if(::bind(s, (sockaddr*)&local, local.getSocklen())<0) {
       L<<Logger::Error<<"binding to TCP socket: "<<strerror(errno)<<endl;
       throw AhuException("Unable to bind to TCP socket");
     }
@@ -541,7 +542,7 @@ TCPNameserver::TCPNameserver()
     if(s<0) 
       throw AhuException("Unable to acquire TCPv6 socket: "+stringerror());
 
-    ComboAddress local(*laddr, arg().asNum("local-port"));
+    ComboAddress local(*laddr, ::arg().asNum("local-port"));
 
     int tmp=1;
     if(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) {