]> granicus.if.org Git - pdns/commitdiff
make sure getBeforeAndAfter passes references, plus add --gmysql-dnssec (not hooked...
authorBert Hubert <bert.hubert@netherlabs.nl>
Fri, 30 Apr 2010 20:50:37 +0000 (20:50 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Fri, 30 Apr 2010 20:50:37 +0000 (20:50 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1594 d19b8d6e-7fed-0310-83ef-9ca221ded41b

modules/gmysqlbackend/gmysqlbackend.cc
pdns/backends/bind/bindbackend2.cc
pdns/backends/bind/bindbackend2.hh
pdns/backends/gsql/gsqlbackend.cc
pdns/backends/gsql/gsqlbackend.hh
pdns/dnsbackend.hh

index e020677ba16921705c689bd27d2ed7c40583dbfb..eccdfb6ed5c2fc25521c6bc3d745e2ffbb29cce3 100644 (file)
@@ -50,6 +50,7 @@ public:
     declare(suffix,"port","Database backend port to connect to","0");
     declare(suffix,"socket","Pdns backend socket to connect to","");
     declare(suffix,"password","Pdns backend password to connect with","");
+    declare(suffix,"dnssec","Assume DNSSEC Schema is in place","false");
 
     declare(suffix,"basic-query","Basic query","select content,ttl,prio,type,domain_id,name from records where type='%s' and name='%s'");
     declare(suffix,"id-query","Basic with ID query","select content,ttl,prio,type,domain_id,name from records where type='%s' and name='%s' and domain_id=%d");
index 02c2f3f8b0093f014d38903d089b6d889ebb64d1..be9e7f95650c20aa325516fdcbd927820acfc276 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2002 - 2008  PowerDNS.COM BV
+    Copyright (C) 2002 - 2010  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 
@@ -789,7 +789,7 @@ string dotConcat(const std::string& a, const std::string &b)
     return a+"."+b;
 }
 
-bool Bind2Backend::getBeforeAndAfterNames(uint32_t id, const std::string qname, std::string& before, std::string& after)
+bool Bind2Backend::getBeforeAndAfterNames(uint32_t id, const std::string& qname, std::string& before, std::string& after)
 {
   shared_ptr<State> state = s_state;
 
index 6bc051a3ecfe48dd1d9ba7d1e67d1f055ee90bc0..624092c50418813c075fb8c51280a8561ed56cc6 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2002-2007  PowerDNS.COM BV
+    Copyright (C) 2002-2010  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 
@@ -108,7 +108,7 @@ public:
   void getUpdatedMasters(vector<DomainInfo> *changedDomains);
   bool getDomainInfo(const string &domain, DomainInfo &di);
   time_t getCtime(const string &fname);
-  virtual bool getBeforeAndAfterNames(uint32_t id, const std::string qname, std::string& before, std::string& after);
+  virtual bool getBeforeAndAfterNames(uint32_t id, const std::string& qname, std::string& before, std::string& after);
   void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1);
   bool list(const string &target, int id);
   bool get(DNSResourceRecord &);
index 032ff27d549cc8f0e682f27db5414f7f8106dcc1..f341779a0dfa3f4ece9d475aeb9dc512193c68a5 100644 (file)
@@ -24,8 +24,8 @@ void GSQLBackend::setNotified(uint32_t domain_id, uint32_t serial)
 {
   char output[1024];
   snprintf(output,sizeof(output)-1,
-           d_UpdateSerialOfZoneQuery.c_str(),
-           serial, domain_id);
+          d_UpdateSerialOfZoneQuery.c_str(),
+          serial, domain_id);
 
   try {
     d_db->doCommand(output);
@@ -39,8 +39,8 @@ void GSQLBackend::setFresh(uint32_t domain_id)
 {
   char output[1024];
   snprintf(output,sizeof(output)-1,d_UpdateLastCheckofZoneQuery.c_str(),
-           time(0),
-           domain_id);
+          time(0),
+          domain_id);
 
   try {
     d_db->doCommand(output);
@@ -54,8 +54,8 @@ bool GSQLBackend::isMaster(const string &domain, const string &ip)
 {
   char output[1024];
   snprintf(output,sizeof(output)-1,
-           d_MasterOfDomainsZoneQuery.c_str(),
-           sqlEscape(domain).c_str());
+          d_MasterOfDomainsZoneQuery.c_str(),
+          sqlEscape(domain).c_str());
   try {
     d_db->doQuery(output, d_result);
   }
@@ -75,7 +75,7 @@ bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di)
      id,name,master IP,serial */
   char output[1024];
   snprintf(output,sizeof(output)-1,d_InfoOfDomainsZoneQuery.c_str(),
-           sqlEscape(domain).c_str());
+          sqlEscape(domain).c_str());
   try {
     d_db->doQuery(output,d_result);
   }
@@ -99,9 +99,9 @@ bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di)
     try {
       SOAData sd;
       if(!getSOA(domain,sd)) 
-        L<<Logger::Notice<<"No serial for '"<<domain<<"' found - zone is missing?"<<endl;
+       L<<Logger::Notice<<"No serial for '"<<domain<<"' found - zone is missing?"<<endl;
       else
-        di.serial=sd.serial;
+       di.serial=sd.serial;
     }
     catch(AhuException &ae){
       L<<Logger::Error<<"Error retrieving serial for '"<<domain<<"': "<<ae.reason<<endl;
@@ -211,7 +211,7 @@ GSQLBackend::GSQLBackend(const string &mode, const string &suffix)
   setArgPrefix(mode+suffix);
   d_db=0;
   d_logprefix="["+mode+"Backend"+suffix+"] ";
-                 
+                 
   d_noWildCardNoIDQuery=getArg("basic-query");
   d_noWildCardIDQuery=getArg("id-query");
   d_wildCardNoIDQuery=getArg("wildcard-query");
@@ -237,6 +237,28 @@ GSQLBackend::GSQLBackend(const string &mode, const string &suffix)
   d_CheckACLQuery=getArg("check-acl-query");
 }
 
+bool GSQLBackend::getBeforeAndAfterNames(uint32_t id, const std::string& qname, std::string& before, std::string& after)
+{
+  cerr<<"gsql before/after called for id="<<id<<", qname="<<qname<<endl;
+  string lcqname=toLower(qname);
+  
+  lcqname=labelReverse(lcqname);
+
+  SSql::row_t row;
+
+  d_db->doQuery("select min(ordername) from records where ordername > '"+sqlEscape(lcqname)+"' and auth=1");
+  while(d_db->getRow(row)) {
+    after=labelReverse(row[0]);
+  }
+
+  d_db->doQuery("select max(ordername) from records where ordername < '"+sqlEscape(lcqname)+"' and auth=1");
+  while(d_db->getRow(row)) {
+    before=labelReverse(row[0]);
+  }
+
+  return false;
+}
+
 
 void GSQLBackend::lookup(const QType &qtype,const string &qname, DNSPacket *pkt_p, int domain_id)
 {
@@ -247,21 +269,23 @@ void GSQLBackend::lookup(const QType &qtype,const string &qname, DNSPacket *pkt_
 
   string lcqname=toLower(qname);
   
+  // lcqname=labelReverse(makeRelative(lcqname, "net"));
+
   if(qtype.getCode()!=QType::ANY) {
     // qtype qname domain_id
     if(domain_id<0) {
       if(qname[0]=='%')
-        format=d_wildCardNoIDQuery;
+       format=d_wildCardNoIDQuery;
       else
-        format=d_noWildCardNoIDQuery;
+       format=d_noWildCardNoIDQuery;
 
       snprintf(output,sizeof(output)-1, format.c_str(),sqlEscape(qtype.getName()).c_str(), sqlEscape(lcqname).c_str());
     }
     else {
       if(qname[0]!='%')
-        format=d_noWildCardIDQuery;
+       format=d_noWildCardIDQuery;
       else
-        format=d_wildCardIDQuery;
+       format=d_wildCardIDQuery;
       snprintf(output,sizeof(output)-1, format.c_str(),sqlEscape(qtype.getName()).c_str(),sqlEscape(lcqname).c_str(),domain_id);
     }
   }
@@ -270,17 +294,17 @@ void GSQLBackend::lookup(const QType &qtype,const string &qname, DNSPacket *pkt_
     // qname domain_id
     if(domain_id<0) {
       if(qname[0]=='%')
-        format=d_wildCardANYNoIDQuery;
+       format=d_wildCardANYNoIDQuery;
       else
-        format=d_noWildCardANYNoIDQuery;
+       format=d_noWildCardANYNoIDQuery;
 
       snprintf(output,sizeof(output)-1, format.c_str(),sqlEscape(lcqname).c_str());
     }
     else {
       if(qname[0]!='%')
-        format=d_noWildCardANYIDQuery;
+       format=d_noWildCardANYIDQuery;
       else
-        format=d_wildCardANYIDQuery;
+       format=d_wildCardANYIDQuery;
       snprintf(output,sizeof(output)-1, format.c_str(),sqlEscape(lcqname).c_str(),domain_id);
     }
   }
@@ -409,10 +433,10 @@ bool GSQLBackend::feedRecord(const DNSResourceRecord &r)
 {
   char output[1024];
   snprintf(output,sizeof(output)-1,d_InsertRecordQuery.c_str(),
-           sqlEscape(r.content).c_str(),
-           r.ttl, r.priority,
-           sqlEscape(r.qtype.getName()).c_str(),
-           r.domain_id, toLower(sqlEscape(r.qname)).c_str()); 
+          sqlEscape(r.content).c_str(),
+          r.ttl, r.priority,
+          sqlEscape(r.qtype.getName()).c_str(),
+          r.domain_id, toLower(sqlEscape(r.qname)).c_str()); 
   try {
     d_db->doCommand(output);
   }
index eaf75c46df9ffe324283ea5eb2107113c4b47cc1..b3199632b79e215910ef8df7c17b43a576610f94 100644 (file)
@@ -39,6 +39,7 @@ public:
   void getUpdatedMasters(vector<DomainInfo> *updatedDomains);
   bool getDomainInfo(const string &domain, DomainInfo &di);
   void setNotified(uint32_t domain_id, uint32_t serial);
+  bool getBeforeAndAfterNames(uint32_t id, const std::string& qname, std::string& before, std::string& after);
 private:
   string d_qname;
   QType d_qtype;
@@ -66,6 +67,6 @@ private:
   string d_UpdateSerialOfZoneQuery;
   string d_UpdateLastCheckofZoneQuery;
   string d_InfoOfAllMasterDomainsQuery;
-  string d_DeleteZoneQuery;            
+  string d_DeleteZoneQuery;            
   string d_CheckACLQuery;   
 };
index 53d712f103aca4d8e632c5d1dfa859fcd5e53b1b..1414542e779c2401912ce089297816cf69b4cf15 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2002-2007  PowerDNS.COM BV
+    Copyright (C) 2002-2010  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
@@ -74,7 +74,7 @@ public:
   virtual void lookup(const QType &qtype, const string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1)=0; 
   virtual bool get(DNSResourceRecord &)=0; //!< retrieves one DNSResource record, returns false if no more were available
 
-  virtual bool getBeforeAndAfterNames(uint32_t id, const std::string qname, std::string& before, std::string& after)
+  virtual bool getBeforeAndAfterNames(uint32_t id, const std::string& qname, std::string& before, std::string& after)
   {
     std::cerr<<"Default beforeAndAfter called!"<<std::endl;
     return false;