From: Bert Hubert Date: Sun, 22 Jun 2008 20:02:23 +0000 (+0000) Subject: first preparatory commit towards making the auth server safe for boost::multi_index X-Git-Tag: rec-3.1.7.1~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=379ab44558958e54a2da9d7bc1460fa115bcb8d9;p=pdns first preparatory commit towards making the auth server safe for boost::multi_index git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1215 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/communicator.cc b/pdns/communicator.cc index 62eeae2dc..912535abf 100644 --- a/pdns/communicator.cc +++ b/pdns/communicator.cc @@ -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 #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(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<void *Distributorint Distributorarg().asNum("max-queue-length")) { - L<::arg().asNum("max-queue-length")) { + L<= 0) + if(::bind(d_sock, (struct sockaddr *)&sin, sizeof(sin)) >= 0) break; } if(n==10) { diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index c120466e1..05eb3dad9 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -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&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 diff --git a/pdns/resolver.cc b/pdns/resolver.cc index cff098bca..3c2c18150 100644 --- a/pdns/resolver.cc +++ b/pdns/resolver.cc @@ -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 @@ -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()); diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index c52783c1e..e7a323791 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -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 #include @@ -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 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 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 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(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; vectorlocals; - stringtok(locals,arg()["local-address"]," ,"); + stringtok(locals,::arg()["local-address"]," ,"); vectorlocals6; - 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 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::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<