From: Bert Hubert Date: Sat, 30 Aug 2003 14:34:04 +0000 (+0000) Subject: cosmetic fixes X-Git-Tag: pdns-2.9.12~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f1d58264cd5421ad5c82b8422a520af8a85baf2;p=pdns cosmetic fixes 0.0.0.0/0 support SRV support git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@183 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/ChangeLog b/ChangeLog index 524d9c67b..56d051103 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ changes since 2.9.11: - ldap updates no longer sends entire reverse zone with AXFR + - SRV fixes for zonefiles (Christof Meerwald) + - gpgsql no longer reports as gmysql (Sherwin Daganoto) + - we now understand 0.0.0.0/0 changes since 2.9.10: - pdns_recursor now cleans its cache diff --git a/modules/gpgsqlbackend/gpgsqlbackend.cc b/modules/gpgsqlbackend/gpgsqlbackend.cc index d85ad45fc..257e43f8d 100644 --- a/modules/gpgsqlbackend/gpgsqlbackend.cc +++ b/modules/gpgsqlbackend/gpgsqlbackend.cc @@ -1,4 +1,4 @@ -// $Id: gpgsqlbackend.cc,v 1.2 2003/01/02 15:43:00 ahu Exp $ +// $Id: gpgsqlbackend.cc,v 1.3 2003/08/30 14:34:04 ahu Exp $ #include #include @@ -95,7 +95,7 @@ public: { BackendMakers().report(new gPgSQLFactory("gpgsql")); BackendMakers().report(new gPgSQLFactory("gpgsql2")); - L<&words, vector&rec) int left=words.size()-cpos; string content; - if(qtype=="MX" && left==2) { - int prio=atoi(words[cpos++].c_str()); - content=words[cpos]; + if((qtype=="MX" && left==2) || (qtype=="SRV" && left==4)){ + int prio=atoi(words[cpos++].c_str());left--; + content=words[cpos++];left--; + + while(left--) + content+=" "+words[cpos++]; + if(content=="@") content=d_origin; else diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index d9f1ed64e..165b09933 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -65,7 +65,7 @@ void declareArguments() arg().set("queue-limit","Maximum number of milliseconds to queue a query")="1500"; arg().set("recursor","If recursion is desired, IP address of a recursing nameserver")="no"; arg().set("lazy-recursion","Only recurse if question cannot be answered locally")="yes"; - arg().set("allow-recursion","List of netmasks that are allowed to recurse")=""; + arg().set("allow-recursion","List of subnets that are allowed to recurse")="0.0.0.0/0"; arg().set("disable-tcp","Do not listen to TCP queries")="no"; arg().set("disable-axfr","Do not allow zone transfers")="no"; @@ -75,7 +75,7 @@ void declareArguments() arg().set("load-modules","Load this module - supply absolute or relative path")=""; arg().set("launch","Which backends to launch and order to query them in")=""; arg().setSwitch("disable-axfr","Disable zonetransfers but do allow TCP queries")="no"; - arg().set("allow-axfr-ips","Allow zonetransfers only from these IP addresses")=""; + arg().set("allow-axfr-ips","Allow zonetransfers only to these subnets")="0.0.0.0/0"; arg().set("slave-cycle-interval","Reschedule failed SOA serial checks once every .. seconds")="60"; arg().setSwitch("slave","Act as a slave")="no"; @@ -257,7 +257,7 @@ void mainthread() pthread_t qtid; StatWebServer sws; - if(arg()["webserver"]!="no") + if(arg().mustDo("webserver")) sws.go(); if(arg().mustDo("slave") || arg().mustDo("master")) diff --git a/pdns/dnsproxy.cc b/pdns/dnsproxy.cc index 3366374da..675c299e3 100644 --- a/pdns/dnsproxy.cc +++ b/pdns/dnsproxy.cc @@ -94,7 +94,7 @@ void DNSProxy::onlyFrom(const string &ips) bool DNSProxy::recurseFor(DNSPacket* p) { - return d_ng.empty() || d_ng.match((struct sockaddr_in *)&p->remote); + return d_ng.match((struct sockaddr_in *)&p->remote); } /** returns false if p->remote is not allowed to recurse via us */ diff --git a/pdns/docs/pdns.sgml b/pdns/docs/pdns.sgml index 05e7a8cc6..91cf483fa 100644 --- a/pdns/docs/pdns.sgml +++ b/pdns/docs/pdns.sgml @@ -11,7 +11,7 @@ - v2.1 $Date: 2003/07/05 14:13:18 $ + v2.1 $Date: 2003/08/30 14:34:04 $ @@ -6933,7 +6933,7 @@ GRANT ALL ON records_id_seq TO pdns; - gmysql-host (only for MySQL!) + gmysql-socket (only for MySQL!) Filename where the MySQL connection socket resides. Often /tmp/mysql.sock or /var/run/mysqld/mysqld.sock. diff --git a/pdns/iputils.hh b/pdns/iputils.hh index 674c907f3..cf505bb4b 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -55,7 +55,7 @@ public: if((p=strchr(mask.c_str(),'/'))) bits=atoi(p+1); - d_mask=~((1<<(32-bits))-1); // 1<<16 0000 0000 0000 0000 0000 0000 0000 0000 + d_mask=~(0xFFFFFFFF>>bits); struct in_addr a; if(!Utility::inet_aton(mask.substr(0,p-mask.c_str()).c_str(), &a)) diff --git a/pdns/misc.cc b/pdns/misc.cc index a1bfafb7f..3d50ca46a 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -145,41 +145,6 @@ void parseService(const string &descr, ServiceTuple &st) st.port=atoi(parts[1].c_str()); } -int matchNetmask(const char *address, const char *omask) -{ - struct in_addr a,m; - int bits=32; - char *sep; - - char *mask=strdup(omask); - sep=strchr(mask,'/'); - - if(sep) { - bits=atoi(sep+1); - *sep=0; - } - - if(!Utility::inet_aton(address, &a) || !Utility::inet_aton(mask, &m)) - { - free(mask); - return -1; - } - - free(mask); - - // bits==32 -> 0xffffffff - // bits==16 -> 0xffff0000 - // bits==0 -> 0x00000000 - unsigned int bmask=~((1<<(32-bits))-1); // 1<<16 0000 0000 0000 0000 0000 0000 0000 0000 - - /* - fprintf(stderr,"%x\n",bmask); - fprintf(stderr,"%x\n",(htonl((unsigned int)a.s_addr) & bmask)); - fprintf(stderr,"%x\n",(htonl((unsigned int)m.s_addr) & bmask)); - */ - - return ((htonl((unsigned int)a.s_addr) & bmask) == (htonl((unsigned int)m.s_addr) & bmask)); -} int waitForData(int fd, int seconds) { diff --git a/pdns/misc.hh b/pdns/misc.hh index 708bc2ec5..8207cf803 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -45,7 +45,6 @@ bool chopOff(string &domain); bool endsOn(const string &domain, const string &suffix); string nowTime(); const string unquotify(const string &item); -int matchNetmask(const char *address, const char *omask); string humanDuration(time_t passed); void chomp(string &line, const string &delim); bool stripDomainSuffix(string *qname, const string &domain); diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index 34f70e427..1e040d4e9 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -53,6 +53,7 @@ pthread_mutex_t TCPNameserver::s_plock = PTHREAD_MUTEX_INITIALIZER; Semaphore *TCPNameserver::d_connectionroom_sem; PacketHandler *TCPNameserver::s_P; int TCPNameserver::s_timeout; +NetmaskGroup TCPNameserver::d_ng; int TCPNameserver::sendDelPacket(DNSPacket *p, int outsock) @@ -244,22 +245,14 @@ void *TCPNameserver::doConnection(void *data) return 0; } -static bool canDoAXFR(DNSPacket *q) +bool TCPNameserver::canDoAXFR(DNSPacket *q) { if(arg().mustDo("disable-axfr")) return false; - if(arg()["allow-axfr-ips"].empty()) + if( arg()["allow-axfr-ips"].empty() || d_ng.match( (struct sockaddr_in *) &q->remote ) ) return true; - - vectorparts; - stringtok(parts,arg()["allow-axfr-ips"],", "); // is this IP on the guestlist? - for(vector::const_iterator i=parts.begin();i!=parts.end();++i) { - if(matchNetmask(q->getRemote().c_str(),i->c_str())==1) - return true; - } - extern CommunicatorClass Communicator; if(Communicator.justNotified(q->qdomain, q->getRemote())) { // we just notified this ip @@ -408,6 +401,12 @@ TCPNameserver::TCPNameserver() d_highfd=0; + vector parts; + 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 ); + } + #ifndef WIN32 signal(SIGPIPE,SIG_IGN); #endif // WIN32 diff --git a/pdns/tcpreceiver.hh b/pdns/tcpreceiver.hh index 60684bb3a..af6e172e7 100644 --- a/pdns/tcpreceiver.hh +++ b/pdns/tcpreceiver.hh @@ -20,6 +20,7 @@ #define PDNS_TCPRECEIVER_HH #include "dns.hh" +#include "iputils.hh" #include "dnsbackend.hh" #include "packethandler.hh" #include @@ -50,6 +51,7 @@ private: static int readLength(int fd, struct sockaddr_in *remote); static void getQuestion(int fd, char *mesg, int pktlen, const struct sockaddr_in &remote); static int doAXFR(const string &target, DNSPacket *q, int outsock); + static bool canDoAXFR(DNSPacket *q); static void *doConnection(void *data); static void *launcher(void *data); void thread(void); @@ -57,6 +59,7 @@ private: static PacketHandler *s_P; pthread_t d_tid; static Semaphore *d_connectionroom_sem; + static NetmaskGroup d_ng; vectord_sockets; int d_highfd;