]> granicus.if.org Git - pdns/commitdiff
lots
authorBert Hubert <bert.hubert@netherlabs.nl>
Mon, 27 Oct 2003 14:58:22 +0000 (14:58 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Mon, 27 Oct 2003 14:58:22 +0000 (14:58 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@195 d19b8d6e-7fed-0310-83ef-9ca221ded41b

12 files changed:
ChangeLog
build-scripts/rpm-build-instruction
debian/changelog
modules/ldapbackend/Makefile.am
modules/ldapbackend/ldapbackend.cc
modules/ldapbackend/ldapbackend.hh
modules/ldapbackend/utils.hh [new file with mode: 0644]
pdns.spec
pdns/dnsbackend.cc
pdns/dnspacket.cc
pdns/docs/pdns.sgml
pdns/syncres.cc

index e9f50486e5db89384826ca29500e5a3f063d65e3..c9e6643dfa7ce766b384d95d777cf19668ba48d6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,8 @@ changes since 2.9.11:
        - slave communicator more robust against misconfiguration (empty
          master field) 
        - postgresql backend gains error checking support
+//     - soa serial autocalculation now also honours soa-serial-offset (Steve Sobol)
+       - we now shuffle answers 
 
 changes since 2.9.10:
        - pdns_recursor now cleans its cache
index 6099d1aa9d957fcab51139cc5f568a2d69ec1bdb..5d916796fb729557f349c86de53ee953ea452907 100755 (executable)
@@ -1,7 +1,8 @@
 #!/bin/sh
-./configure --with-modules="mysql gmysql gpgsql pipe pdns xdb" --with-dynmodules="" \
-       --enable-static-binaries --enable-mysql --enable-pgsql \
-       --with-pgsql-lib=/opt/postgresql-with-3.2/lib/ --prefix=/usr \
+LIBS="-lkrb5 -lkrb -lcrypto -lroken -lcom_err -lasn1 -lresolv" \./configure --with-modules="mysql gmysql gpgsql gsqlite pipe pdns xdb" \
+       --with-dynmodules="" \
+       --enable-static-binaries --enable-recursor \
+       --prefix=/usr \
        --sysconfdir=/etc/powerdns \
 && make clean && make && \
 sudo /bin/sh -c "rm -rf /tmp/pdns ; DESTDIR=/tmp/pdns make install-strip" &&
index d64077f6a639a145312d3972dc5b7941be7c1015..d85b4ccfc9d4c62a749584ddea2c4b299f9f746d 100644 (file)
@@ -1,5 +1,8 @@
 pdns (2.9.12-1) unstable; urgency=low
-  * release
+
+  * New upstream release
+  * Fix dependency generation. Closes: Bug#210256
+
  -- Wichert Akkerman <wakkerma@debian.org>  Sun,  21 Sep 2003 14:59:46 +0200
 
 pdns (2.9.11-2) unstable; urgency=low
index f12bd8378adefc4b7d0168d1cb1adcc831cedb37..c37f3bde67e7761a502c210cc3cd35d7d0602e0e 100644 (file)
@@ -3,7 +3,7 @@ lib_LTLIBRARIES = libldapbackend.la
 EXTRA_DIST=OBJECTFILES OBJECTLIBS
 
 libldapbackend_la_SOURCES=ldapbackend.cc ldapbackend.hh \
-               powerldap.hh powerldap.cc
+               powerldap.hh powerldap.cc utils.hh
 
 
 libldapbackend_la_LIBADD=-lldap
index 23b0731307df4a8e03332bfccae5429b66a68773..6c845c6e6450e29ede7e59d1f31c5f6b12c74092 100644 (file)
@@ -65,40 +65,18 @@ LdapBackend::~LdapBackend()
 
 bool LdapBackend::list( const string &target, int domain_id )
 {
-       string filter, dn;
-       char* attributes[] = { "associatedDomain", NULL };
+       string filter;
 
 
        try
        {
-               // search for DN of SOA record which is SOA for target zone
-
-               filter = "(&(associatedDomain=" + target + ")(SOARecord=*))";
-               m_msgid = m_pldap->search( getArg("basedn"), LDAP_SCOPE_SUBTREE, filter, (const char**) attributes );
-
-               if( m_pldap->getSearchEntry( m_msgid, m_result, true ) == false )
-               {
-                       L << Logger::Error << backendname << " Unable to get SOA record for " << target << endl;
-                       return false;
-               }
-
-               if( m_result.empty() || !m_result.count( "dn" ) || m_result["dn"].empty() )
-               {
-                       L << Logger::Error << backendname << " No SOA record for " << target << endl;
-                       return false;
-               }
-
-               dn = m_result["dn"].front();
-               m_result.clear();
-
-               // list all records one level below but not entries containing SOA records (these are seperate zones)
-
-               DLOG( L << Logger::Debug << backendname << " List = target: " << target << ", basedn: = " << dn << endl );
-
-               m_qname = "";
+               m_qname = target;
+               m_axfrqlen = target.length();
                m_adomain = m_adomains.end();   // skip loops in get() first time
-               filter = "(&(associatedDomain=*" + target + ")(!(SOARecord=*)))";
-               m_msgid = m_pldap->search( dn, LDAP_SCOPE_ONELEVEL, filter, (const char**) attrany );
+
+               DLOG( L << Logger::Debug << backendname << " List = target: " << target << endl );
+               filter = "(|(associatedDomain=" + target + ")(associatedDomain=*." + target + "))";
+               m_msgid = m_pldap->search( getArg("basedn"), LDAP_SCOPE_SUBTREE, filter, (const char**) attrany );
        }
        catch( LDAPTimeout &lt )
        {
@@ -136,24 +114,25 @@ void LdapBackend::lookup( const QType &qtype, const string &qname, DNSPacket *dn
 
        try
        {
+               m_axfrqlen = 0;
                m_qtype = qtype;
                m_qname = qname;
                qesc = toLower( m_pldap->escape( qname ) );
 
-               if( mustDo( "disable-ptrrecord" ) )  // PTRRecords will be derived from ARecords
+               if( mustDo( "disable-ptrrecord" ) )  // PTRRecords will be derived from aRecords or aAAARecords
                {
                        stringtok( parts, qesc, "." );
                        len = qesc.length();
 
                         if( parts.size() == 6 && len > 13 && qesc.substr( len - 13, 13 ) == ".in-addr.arpa" )   // IPv4 reverse lookups
                        {
-                               filter = name2filter( parts, "aRecord", "." );
+                               filter = "(aRecord=" + ptr2ip4( parts ) + ")";
                                attronly[0] = "associatedDomain";
                                attributes = attronly;
                        }
-                       else if( parts.size() == 10 && len > 9 && ( qesc.substr( len - 8, 8 ) == ".ip6.int" ) )   // IPv6 reverse lookups
+                       else if( parts.size() == 34 && len > 9 && ( qesc.substr( len - 9, 9 ) == ".ip6.arpa" ) )   // IPv6 reverse lookups
                        {
-                               filter = name2filter( parts, "aAAARecord", ":" );
+                               filter = "(aAAARecord=" + ptr2ip6( parts ) + ")";
                                attronly[0] = "associatedDomain";
                                attributes = attronly;
                        }
@@ -293,25 +272,6 @@ bool LdapBackend::get( DNSResourceRecord &rr )
 }
 
 
-inline string LdapBackend::name2filter( vector<string>& parts, string record, string separator )
-{
-       string filter;
-       parts.pop_back();
-       parts.pop_back();
-
-       filter = "(" + record + "=" + parts.back();
-       parts.pop_back();
-       while( !parts.empty() )
-       {
-               filter += separator + parts.back();
-               parts.pop_back();
-       }
-       filter += ")";
-
-       return filter;
-}
-
-
 inline bool LdapBackend::prepareEntry()
 {
        m_adomains.clear();
@@ -323,7 +283,7 @@ inline bool LdapBackend::prepareEntry()
                m_result.erase( "dNSTTL" );
        }
 
-       if( !m_qname.empty() )   // request was a normal lookup()
+       if( !m_axfrqlen )   // request was a normal lookup()
        {
                m_adomains.push_back( m_qname );
                if( m_result.count( "associatedDomain" ) )
@@ -336,7 +296,12 @@ inline bool LdapBackend::prepareEntry()
        {
                if( m_result.count( "associatedDomain" ) )
                {
-                       m_adomains = m_result["associatedDomain"];
+                       vector<string>::iterator i;
+                       for( i = m_result["associatedDomain"].begin(); i != m_result["associatedDomain"].end(); i++ ) {
+                               if( i->substr( i->length() - m_axfrqlen, m_axfrqlen ) == m_qname ) {
+                                       m_adomains.push_back( *i );
+                               }
+                       }
                        m_result.erase( "associatedDomain" );
                }
        }
index b03a3ecc920a23845cff39259d60e5bfac4f7891..9ce7b0b0e58ab96b39a717cfc3cd796713e7de4b 100644 (file)
 #include <sstream>
 #include <utility>
 #include <string>
-#include <ldap.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <unistd.h>
+#include <cstdlib>
+#include <cctype>
 #include <pdns/dns.hh>
 #include <pdns/utility.hh>
 #include <pdns/dnspacket.hh>
 #include <pdns/arguments.hh>
 #include <pdns/logger.hh>
 #include "powerldap.hh"
+#include "utils.hh"
 
 
 #ifndef LDAPBACKEND_HH
 #define LDAPBACKEND_HH
 
-using namespace std;
+using std::string;
+using std::vector;
 
 
 
@@ -72,6 +72,7 @@ class LdapBackend : public DNSBackend
 private:
 
        int m_msgid;
+       int m_axfrqlen;
        u_int32_t m_ttl;
        u_int32_t m_default_ttl;
        string m_qname;
@@ -83,7 +84,6 @@ private:
        vector<string> m_adomains;
 
        bool prepareEntry();
-       string name2filter( vector<string>& parts, string record, string separator );
 
 public:
 
diff --git a/modules/ldapbackend/utils.hh b/modules/ldapbackend/utils.hh
new file mode 100644 (file)
index 0000000..adfc807
--- /dev/null
@@ -0,0 +1,113 @@
+#include <string>
+#include <vector>
+#include <pdns/misc.hh>
+
+
+#ifndef LDAPBACKEND_UTILS_HH
+#define LDAPBACKEND_UTILS_HH
+
+using std::string;
+using std::vector;
+
+
+inline string ptr2ip4( vector<string>& parts )
+{
+       string ip;
+       parts.pop_back();
+       parts.pop_back();
+
+
+       ip = parts.back();
+       parts.pop_back();
+
+       while( !parts.empty() )
+       {
+               ip += "." + parts.back();
+               parts.pop_back();
+       }
+
+       return ip;
+}
+
+
+inline string ptr2ip6( vector<string>& parts )
+{
+       int i = 0;
+       string ip;
+
+
+       parts.pop_back();
+       parts.pop_back();
+
+       while( i < 3 && parts.size() > 1 )
+       {
+               if( parts.back() != "0" ) { ip += parts.back(); }
+               parts.pop_back();
+               i++;
+       }
+       ip += parts.back();
+       parts.pop_back();
+
+       while( !parts.empty() )
+       {
+               i = 0;
+               ip += ":";
+
+               while( i < 3 && parts.size() > 1 )
+               {
+                       if( parts.back() != "0" ) { ip += parts.back(); }
+                       parts.pop_back();
+                       i++;
+               }
+               ip += parts.back();
+               parts.pop_back();
+       }
+
+       return ip;
+}
+
+
+inline string ip2ptr4( string ip )
+{
+       string ptr;
+       vector<string> parts;
+
+       stringtok( parts, ip, "." );
+       while( !parts.empty() )
+       {
+               ptr += parts.back() +  ".";
+               parts.pop_back();
+       }
+
+       return ptr + "in-addr.arpa";
+}
+
+
+inline string ip2ptr6( string ip )
+{
+       string ptr, part, defstr;
+       vector<string> parts;
+
+       stringtok( parts, ip, ":" );
+       while( !parts.empty() )
+       {
+               defstr = "0.0.0.0.";
+               part = parts.back();
+
+               while( part.length() < 4 )
+               {
+                       part = "0" + part;
+               }
+
+               defstr[0] = part[3];
+               defstr[2] = part[2];
+               defstr[4] = part[1];
+               defstr[6] = part[0];
+               ptr += defstr;
+               parts.pop_back();
+       }
+
+       return ptr + "ip6.arpa";
+}
+
+#endif
index 491455be6a32d64d44e4060cb7ef004594d97c4b..bdb0490cac98aa52119a4e7c489241e60e623633 100644 (file)
--- a/pdns.spec
+++ b/pdns.spec
@@ -1,6 +1,6 @@
 Buildroot: /tmp/pdns
 Name: pdns-static
-Version: 2.9.11
+Version: 2.9.12
 Release: 1
 Summary: extremely powerful and versatile nameserver
 Copyright: see /usr/doc/pdns/copyright
index 18926a6d4d50472afd62e2c906b6fdf4195af8cb..594e576c6ee81dc34f8070b0fc7c8b2ee1f9e3ae 100644 (file)
@@ -247,7 +247,7 @@ bool DNSBackend::getSOA(const string &domain, SOAData &sd)
        newest=i.last_modified;
     }
 
-    sd.serial=newest;
+    sd.serial=newest; // +arg().asNum("soa-serial-offset");
     DLOG(L<<"autocalculated soa serialnumber for "<<rr.qname<<" is "<<newest<<endl);
 
   }
index 3c3eaedf1e2fbbd8e2cf1d07d02821cb90b67d0e..7420cb14dbd544e85d0995ac400987aceb3ded00 100644 (file)
@@ -16,7 +16,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-// $Id: dnspacket.cc,v 1.21 2003/10/04 14:15:45 ahu Exp $
+// $Id: dnspacket.cc,v 1.22 2003/10/27 14:58:22 ahu Exp $
 #include "utility.hh"
 #include <cstdio>
 
@@ -969,6 +969,29 @@ void DNSPacket::wrapup(void)
 
   stable_sort(rrs.begin(),rrs.end(),rrcomp);
 
+  // now shuffle! start out with the ANSWER records  
+  vector<DNSResourceRecord>::iterator first, second;
+  for(first=rrs.begin();first!=rrs.end();++first) 
+    if(first->d_place==DNSResourceRecord::ANSWER && first->qtype.getCode() != QType::CNAME) // CNAME must come first
+      break;
+  for(second=first;second!=rrs.end();++second)
+    if(second->d_place!=DNSResourceRecord::ANSWER)
+      break;
+
+  if(second-first>1)
+    random_shuffle(first,second);
+
+  // now shuffle the additional records
+  for(first=second;first!=rrs.end();++first) 
+    if(first->d_place==DNSResourceRecord::ADDITIONAL && first->qtype.getCode() != QType::CNAME) // CNAME must come first
+      break;
+  for(second=first;second!=rrs.end();++second)
+    if(second->d_place!=DNSResourceRecord::ADDITIONAL)
+      break;
+
+  if(second-first>1)
+    random_shuffle(first,second);
+
   d_wrapped=true;
 
 
index 0a50f6bc15b04f6b43ea178698eeb56d492e6c94..58f62145e1d97dad5aaefc2e725a514e436562fe 100644 (file)
@@ -11,7 +11,7 @@
       </affiliation>
     </author>
     
-    <PubDate>v2.1 $Date: 2003/09/21 16:06:45 $</PubDate>
+    <PubDate>v2.1 $Date: 2003/10/27 14:58:22 $</PubDate>
     
     <Abstract>
        <para>  
                Recursor now actually purges its cache, saving memory.
              </para>
            </listitem>
+           <listitem>
+             <para>
+               Slave configuration now no longer falls over when presented with a NULL master
+             </para>
+           </listitem>
+           <listitem>
+             <para>
+               Bindbackend2 now has supermaster support (Mark Bergsma, untested)
+             </para>
+           </listitem>
+           <listitem>
+             <para>
+               Answers are now shuffled! It turns out a few recursors don't do shuffling (pdns_recursor, djbdns), so we do it now. Requested by Jorn of ISP-Services.
+             </para>
+           </listitem>
          </itemizedlist>
        </para>
        <para>
                An AXFR from a zone hosted on the LDAP backend no longer transmits all the reverse entries too (Norbert Sendetzky)
              </para>
            </listitem>
+           <listitem>
+             <para>
+               PostgreSQL backend now does error checking. It would be a bit too trusting before.
+             </para>
+           </listitem>
          </itemizedlist>
        </para>
        <para>
index fe80458cc755d11e2179f7f85869f6908e8b1963..5ad642e50cc8377d2e8c3bdb77a357c908059159 100644 (file)
@@ -112,7 +112,7 @@ void SyncRes::getBestNSFromCache(const string &qname, set<DNSResourceRecord>&bes
          if(!endsOn(k->content,subdomain) || getCache(k->content,QType(QType::A),&aset) > 5) {
            bestns.insert(*k);
            LOG<<prefix<<qname<<": NS (with ip, or non-glue) in cache for '"<<subdomain<<"' -> '"<<k->content<<"'"<<endl;
-           LOG<<prefix<<qname<<": endson: "<<endsOn(k->content,subdomain)<<endl;
+           LOG<<prefix<<qname<<": endson: "<<endsOn(k->content,subdomain);
            if(!aset.empty())
              LOG<<", in cache, ttl="<<((time_t)aset.begin()->ttl-time(0))<<endl;
            else