]> granicus.if.org Git - pdns/commitdiff
Implement "disabled" records for GSQL backends
authorChristian Hofstaedtler <christian@hofstaedtler.name>
Fri, 31 Jan 2014 17:23:00 +0000 (18:23 +0100)
committerChristian Hofstaedtler <christian@hofstaedtler.name>
Mon, 3 Feb 2014 21:50:19 +0000 (22:50 +0100)
39 files changed:
modules/bindbackend/bindbackend2.cc
modules/bindbackend/bindbackend2.hh
modules/geobackend/geobackend.cc
modules/geobackend/geobackend.hh
modules/gmysqlbackend/gmysqlbackend.cc
modules/gmysqlbackend/no-dnssec.schema.mysql.sql
modules/goraclebackend/goracle-schema.sql
modules/goraclebackend/goraclebackend.cc
modules/gpgsqlbackend/gpgsqlbackend.cc
modules/gpgsqlbackend/no-dnssec.schema.pgsql.sql
modules/gsqlite3backend/gsqlite3backend.cc
modules/gsqlite3backend/no-dnssec.schema.sqlite3.sql
modules/luabackend/luabackend.hh
modules/luabackend/minimal.cc
modules/mydnsbackend/mydnsbackend.cc
modules/mydnsbackend/mydnsbackend.hh
modules/opendbxbackend/odbxbackend.cc
modules/opendbxbackend/odbxbackend.hh
modules/oraclebackend/oraclebackend.cc
modules/pipebackend/pipebackend.cc
modules/pipebackend/pipebackend.hh
modules/randombackend/randombackend.cc
modules/remotebackend/remotebackend.cc
modules/remotebackend/remotebackend.hh
modules/tinydnsbackend/tinydnsbackend.cc
modules/tinydnsbackend/tinydnsbackend.hh
pdns/backends/gsql/gsqlbackend.cc
pdns/backends/gsql/gsqlbackend.hh
pdns/dns.hh
pdns/dnsbackend.hh
pdns/dnsrecords.cc
pdns/docs/pdns.xml
pdns/json.cc
pdns/json.hh
pdns/ueberbackend.cc
pdns/ueberbackend.hh
pdns/ws-auth.cc
pdns/zone2sql.cc
regression-tests.api/test_Zones.py

index 003ce9d76be0d636b52bc096de4f03cf4e1a19bc..eb8fbe98a8536a01b0ab0fe0a2cb33be40c55daf 100644 (file)
@@ -290,7 +290,7 @@ void Bind2Backend::getUpdatedMasters(vector<DomainInfo> *changedDomains)
   }
 }
 
-void Bind2Backend::getAllDomains(vector<DomainInfo> *domains) {
+void Bind2Backend::getAllDomains(vector<DomainInfo> *domains, bool include_disabled) {
   SOAData soadata;
 
   shared_ptr<State> state = getState(); 
@@ -1215,7 +1215,7 @@ bool Bind2Backend::handle::get_normal(DNSResourceRecord &r)
   return true;
 }
 
-bool Bind2Backend::list(const string &target, int id)
+bool Bind2Backend::list(const string &target, int id, bool include_disabled)
 {
   shared_ptr<State> state = s_state;
   if(!state->id_zone_map.count(id))
index 31853be346b73563f59249272591f57976f636c0..0c7eba68f784bfc071e33d24b63318e39178b2b4 100644 (file)
@@ -134,9 +134,9 @@ public:
   // DNSSEC
   virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, 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 list(const string &target, int id, bool include_disabled=false);
   bool get(DNSResourceRecord &);
-  void getAllDomains(vector<DomainInfo> *domains);
+  void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false);
 
   static DNSBackend *maker();
   static pthread_mutex_t s_startup_lock;
index 08bd27d2c67cfacd07418378fd5d2cb482cc3836..c3d27b2ed167de3ffbbf4a27ff26f8a8b3fbd833 100644 (file)
@@ -118,7 +118,7 @@ void GeoBackend::lookup(const QType &qtype, const string &qdomain, DNSPacket *pk
                i_answers = answers.begin();            
 }
 
-bool GeoBackend::list(const string &target, int domain_id) {
+bool GeoBackend::list(const string &target, int domain_id, bool include_disabled) {
         answers.clear();
         queueNSRecords(zoneName);
         answerLocalhostRecord("localhost."+zoneName, NULL);
index 4170f8bde307ead9529764a8cc640160af6d8c2d..5509982cbe59c74f240a65ff7a9ea6e39b0fd889 100644 (file)
@@ -34,7 +34,7 @@ public:
         ~GeoBackend();
         
         virtual void lookup(const QType &qtype, const string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1);
-        virtual bool list(const string &target, int domain_id);
+        virtual bool list(const string &target, int domain_id, bool include_disabled=false);
         virtual bool get(DNSResourceRecord &r);
         virtual bool getSOA(const string &name, SOAData &soadata, DNSPacket *p=0);
         
index 30b1292794c603919a4521be14c918018f949628..f96adffb98605973369cd437f20c294d71c0275a 100644 (file)
@@ -50,41 +50,41 @@ public:
 
     declare(suffix,"dnssec","Assume DNSSEC Schema is in place","no");
 
-    string record_query = "SELECT content,ttl,prio,type,domain_id,name FROM records WHERE 1";
-    string record_auth_query = "SELECT content,ttl,prio,type,domain_id,name,auth FROM records WHERE 1";
+    string record_query = "SELECT content,ttl,prio,type,domain_id,disabled,name FROM records WHERE";
+    string record_auth_query = "SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE";
 
-    declare(suffix, "basic-query", "Basic query", record_query+" and type='%s' and name='%s'");
-    declare(suffix, "id-query", "Basic with ID query", record_query+" and type='%s' and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-query", "Wildcard query", record_query+" and type='%s' and name like '%s'");
-    declare(suffix, "wildcard-id-query", "Wildcard with ID query", record_query+" and type='%s' and name like '%s' and domain_id='%d'");
+    declare(suffix, "basic-query", "Basic query", record_query+" disabled=0 and type='%s' and name='%s'");
+    declare(suffix, "id-query", "Basic with ID query", record_query+" disabled=0 and type='%s' and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-query", "Wildcard query", record_query+" disabled=0 and type='%s' and name like '%s'");
+    declare(suffix, "wildcard-id-query", "Wildcard with ID query", record_query+" disabled=0 and type='%s' and name like '%s' and domain_id='%d'");
 
-    declare(suffix, "any-query", "Any query", record_query+" and name='%s'");
-    declare(suffix, "any-id-query", "Any with ID query", record_query+" and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-any-query", "Wildcard ANY query", record_query+" and name like '%s'");
-    declare(suffix, "wildcard-any-id-query", "Wildcard ANY with ID query", record_query+" and name like '%s' and domain_id='%d'");
+    declare(suffix, "any-query", "Any query", record_query+" disabled=0 and name='%s'");
+    declare(suffix, "any-id-query", "Any with ID query", record_query+" disabled=0 and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-any-query", "Wildcard ANY query", record_query+" disabled=0 and name like '%s'");
+    declare(suffix, "wildcard-any-id-query", "Wildcard ANY with ID query", record_query+" disabled=0 and name like '%s' and domain_id='%d'");
 
-    declare(suffix, "list-query", "AXFR query", record_query+" and domain_id='%d'");
-    declare(suffix, "list-subzone-query", "Subzone listing", record_query+" and (name='%s' OR name like '%s') and domain_id='%d'");
+    declare(suffix, "list-query", "AXFR query", record_query+" (disabled=0 OR %d) and domain_id='%d'");
+    declare(suffix, "list-subzone-query", "Subzone listing", record_query+" disabled=0 and (name='%s' OR name like '%s') and domain_id='%d'");
 
     declare(suffix,"remove-empty-non-terminals-from-zone-query", "remove all empty non-terminals from zone", "delete from records where domain_id='%d' and type is null");
-    declare(suffix,"insert-empty-non-terminal-query", "insert empty non-terminal in zone", "insert into records (domain_id,name,type) values ('%d','%s',null)");
+    declare(suffix,"insert-empty-non-terminal-query", "insert empty non-terminal in zone", "insert into records (domain_id,name,type,disabled) values ('%d','%s',null,0)");
     declare(suffix,"delete-empty-non-terminal-query", "delete empty non-terminal from zone", "delete from records where domain_id='%d' and name='%s' and type is null");
 
     // and now with auth
-    declare(suffix, "basic-query-auth", "Basic query", record_auth_query+" and type='%s' and name='%s'");
-    declare(suffix, "id-query-auth", "Basic with ID query", record_auth_query+" and type='%s' and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-query-auth", "Wildcard query", record_auth_query+" and type='%s' and name like '%s'");
-    declare(suffix, "wildcard-id-query-auth", "Wildcard with ID query", record_auth_query+" and type='%s' and name like '%s' and domain_id='%d'");
+    declare(suffix, "basic-query-auth", "Basic query", record_auth_query+" disabled=0 and type='%s' and name='%s'");
+    declare(suffix, "id-query-auth", "Basic with ID query", record_auth_query+" disabled=0 and type='%s' and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-query-auth", "Wildcard query", record_auth_query+" disabled=0 and type='%s' and name like '%s'");
+    declare(suffix, "wildcard-id-query-auth", "Wildcard with ID query", record_auth_query+" disabled=0 and type='%s' and name like '%s' and domain_id='%d'");
 
-    declare(suffix, "any-query-auth", "Any query", record_auth_query+" and name='%s'");
-    declare(suffix, "any-id-query-auth", "Any with ID query", record_auth_query+" and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-any-query-auth", "Wildcard ANY query", record_auth_query+" and name like '%s'");
-    declare(suffix, "wildcard-any-id-query-auth", "Wildcard ANY with ID query", record_auth_query+" and name like '%s' and domain_id='%d'");
+    declare(suffix, "any-query-auth", "Any query", record_auth_query+" disabled=0 and name='%s'");
+    declare(suffix, "any-id-query-auth", "Any with ID query", record_auth_query+" disabled=0 and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-any-query-auth", "Wildcard ANY query", record_auth_query+" disabled=0 and name like '%s'");
+    declare(suffix, "wildcard-any-id-query-auth", "Wildcard ANY with ID query", record_auth_query+" disabled=0 and name like '%s' and domain_id='%d'");
 
-    declare(suffix, "list-query-auth", "AXFR query", record_auth_query+" and domain_id='%d' order by name, type");
-    declare(suffix, "list-subzone-query-auth", "Subzone listing", record_auth_query+" and (name='%s' OR name like '%s') and domain_id='%d'");
+    declare(suffix, "list-query-auth", "AXFR query", record_auth_query+" (disabled=0 OR %d) and domain_id='%d' order by name, type");
+    declare(suffix, "list-subzone-query-auth", "Subzone listing", record_auth_query+" disabled=0 and (name='%s' OR name like '%s') and domain_id='%d'");
 
-    declare(suffix,"insert-empty-non-terminal-query-auth", "insert empty non-terminal in zone", "insert into records (domain_id,name,type,auth) values ('%d','%s',null,'1')");
+    declare(suffix, "insert-empty-non-terminal-query-auth", "insert empty non-terminal in zone", "insert into records (domain_id,name,type,disabled,auth) values ('%d','%s',null,0,'1')");
 
     declare(suffix,"master-zone-query","Data", "select master from domains where name='%s' and type='SLAVE'");
 
@@ -97,22 +97,22 @@ public:
     declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE','%s')");
     declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE','%s','%s','%s')");
 
-    declare(suffix,"insert-record-query","", "insert into records (content,ttl,prio,type,domain_id,name) values ('%s',%d,%d,'%s',%d,'%s')");
-    declare(suffix,"insert-record-query-auth","", "insert into records (content,ttl,prio,type,domain_id,name,auth) values ('%s',%d,%d,'%s',%d,'%s','%d')");
-    declare(suffix,"insert-record-order-query-auth","", "insert into records (content,ttl,prio,type,domain_id,name,ordername,auth) values ('%s',%d,%d,'%s',%d,'%s','%s','%d')");
-    declare(suffix,"insert-ent-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,name) values (null,'%d','%s')");
-    declare(suffix,"insert-ent-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,name,auth) values (null,'%d','%s','1')");
-    declare(suffix,"insert-ent-order-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,name,ordername,auth) values (null,'%d','%s','%s','1')");
+    declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name) values ('%s',%d,%d,'%s',%d,%d,'%s')");
+    declare(suffix, "insert-record-query-auth", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values ('%s',%d,%d,'%s',%d,%d,'%s','%d')");
+    declare(suffix, "insert-record-order-query-auth", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values ('%s',%d,%d,'%s',%d,%d,'%s','%s','%d')");
+    declare(suffix, "insert-ent-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name) values (null,'%d',0,'%s')");
+    declare(suffix, "insert-ent-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,auth) values (null,'%d',0,'%s','1')");
+    declare(suffix, "insert-ent-order-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth) values (null,'%d',0,'%s','%s','1')");
 
-    declare(suffix,"get-order-first-query","DNSSEC Ordering Query, first", "select ordername, name from records where domain_id=%d and ordername is not null order by 1 asc limit 1");
-    declare(suffix,"get-order-before-query","DNSSEC Ordering Query, before", "select ordername, name from records where ordername <= '%s' and domain_id=%d and ordername is not null order by 1 desc limit 1");
-    declare(suffix,"get-order-after-query","DNSSEC Ordering Query, after", "select min(ordername) from records where ordername > '%s' and domain_id=%d and ordername is not null");
-    declare(suffix,"get-order-last-query","DNSSEC Ordering Query, last", "select ordername, name from records where ordername != '' and domain_id=%d and ordername is not null order by 1 desc limit 1");
-    declare(suffix,"set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s',auth=%d where name='%s' and domain_id='%d'");
-    declare(suffix,"set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=1 where domain_id='%d' and name='%s' and type='DS'");
+    declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, first", "select ordername, name from records where domain_id=%d and disabled=0 and ordername is not null order by 1 asc limit 1");
+    declare(suffix, "get-order-before-query", "DNSSEC Ordering Query, before", "select ordername, name from records where ordername <= '%s' and domain_id=%d and disabled=0 and ordername is not null order by 1 desc limit 1");
+    declare(suffix, "get-order-after-query", "DNSSEC Ordering Query, after", "select min(ordername) from records where ordername > '%s' and domain_id=%d and disabled=0 and ordername is not null");
+    declare(suffix, "get-order-last-query", "DNSSEC Ordering Query, last", "select ordername, name from records where ordername != '' and domain_id=%d and disabled=0 and ordername is not null order by 1 desc limit 1");
+    declare(suffix, "set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s',auth=%d where name='%s' and domain_id='%d' and disabled=0");
+    declare(suffix, "set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=1 where domain_id='%d' and name='%s' and type='DS' and disabled=0");
 
-    declare(suffix,"nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d where domain_id='%d' and name='%s'");
-    declare(suffix,"nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=0 where name='%s' and type='%s' and domain_id='%d'");
+    declare(suffix, "nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d where domain_id='%d' and name='%s' and disabled=0");
+    declare(suffix, "nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=0 where name='%s' and type='%s' and domain_id='%d' and disabled=0");
 
     declare(suffix,"update-master-query","", "update domains set master='%s' where name='%s'");
     declare(suffix,"update-kind-query","", "update domains set type='%s' where name='%s'");
@@ -140,7 +140,7 @@ public:
     declare(suffix,"delete-tsig-key-query","", "delete from tsigkeys where name='%s'");
     declare(suffix,"get-tsig-keys-query","", "select name,algorithm, secret from tsigkeys");
 
-    declare(suffix,"get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA'");
+    declare(suffix, "get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA' and (records.disabled=0 OR %d)");
   }
 
   DNSBackend *make(const string &suffix="")
index d2ed72cdc76ddc6f42cfc5477c508fdc796b6dfc..c58283c248d2f7589f62fb2b0eac71dffe257699 100644 (file)
@@ -20,6 +20,7 @@ CREATE TABLE records (
   ttl             INT DEFAULT NULL,
   prio            INT DEFAULT NULL,
   change_date     INT DEFAULT NULL,
+  disabled        INT DEFAULT NULL,
   primary key(id)
 ) Engine=InnoDB;
 
index 981cb84a416f893bbb9b484173f89dfb30f8a966..31796f30016d01283dfa135bec4c6c89f695e1eb 100644 (file)
@@ -22,6 +22,7 @@ CREATE TABLE records (
   ttl             INT DEFAULT NULL,
   prio            INT DEFAULT NULL,
   change_date     INT DEFAULT NULL,
+  disabled        INT DEFAULT NULL,
   ordername       VARCHAR(255) DEFAULT NULL,
   auth            INT DEFAULT NULL,
   primary key (id)
index bb99d53f463d5bd51e6c841b09e85817b7639f4d..d7c8c2c550df61678c28d3dcc62a2f1950079828 100644 (file)
@@ -57,41 +57,41 @@ public:
 
     declare(suffix,"dnssec","Assume DNSSEC Schema is in place","no");
 
-    string record_query = "SELECT content,ttl,prio,type,domain_id,name FROM records WHERE 1";
-    string record_auth_query = "SELECT content,ttl,prio,type,domain_id,name,auth FROM records WHERE 1";
+    string record_query = "SELECT content,ttl,prio,type,domain_id,name FROM records WHERE";
+    string record_auth_query = "SELECT content,ttl,prio,type,domain_id,name,auth FROM records WHERE";
 
-    declare(suffix, "basic-query", "Basic query", record_query+" and type='%s' and name='%s'");
-    declare(suffix, "id-query", "Basic with ID query", record_query+" and type='%s' and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-query", "Wildcard query", record_query+" and type='%s' and name like '%s'");
-    declare(suffix, "wildcard-id-query", "Wildcard with ID query", record_query+" and type='%s' and name like '%s' and domain_id='%d'");
+    declare(suffix, "basic-query", "Basic query", record_query+" disabled=0 and type='%s' and name='%s'");
+    declare(suffix, "id-query", "Basic with ID query", record_query+" disabled=0 and type='%s' and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-query", "Wildcard query", record_query+" disabled=0 and type='%s' and name like '%s'");
+    declare(suffix, "wildcard-id-query", "Wildcard with ID query", record_query+" disabled=0 and type='%s' and name like '%s' and domain_id='%d'");
 
-    declare(suffix, "any-query", "Any query", record_query+" and name='%s'");
-    declare(suffix, "any-id-query", "Any with ID query", record_query+" and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-any-query", "Wildcard ANY query", record_query+" and name like '%s'");
-    declare(suffix, "wildcard-any-id-query", "Wildcard ANY with ID query", record_query+" and name like '%s' and domain_id='%d'");
+    declare(suffix, "any-query", "Any query", record_query+" disabled=0 and name='%s'");
+    declare(suffix, "any-id-query", "Any with ID query", record_query+" disabled=0 and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-any-query", "Wildcard ANY query", record_query+" disabled=0 and name like '%s'");
+    declare(suffix, "wildcard-any-id-query", "Wildcard ANY with ID query", record_query+" disabled=0 and name like '%s' and domain_id='%d'");
 
-    declare(suffix, "list-query", "AXFR query",  record_query+" and domain_id='%d'");
-    declare(suffix, "list-subzone-query", "Subzone listing", record_query+" and (name='%s' OR name like '%s') and domain_id='%d'");
+    declare(suffix, "list-query", "AXFR query", record_query+" (disabled=0 OR %d) and domain_id='%d'");
+    declare(suffix, "list-subzone-query", "Subzone listing", record_query+" disabled=0 and (name='%s' OR name like '%s') and domain_id='%d'");
 
     declare(suffix,"remove-empty-non-terminals-from-zone-query", "remove all empty non-terminals from zone", "delete from records where domain_id='%d' and type is null");
-    declare(suffix,"insert-empty-non-terminal-query", "insert empty non-terminal in zone", "insert into records (id,domain_id,name,type) values (records_id_sequence.nextval,'%d','%s',null)");
+    declare(suffix,"insert-empty-non-terminal-query", "insert empty non-terminal in zone", "insert into records (id,domain_id,name,type,disabled) values (records_id_sequence.nextval,'%d','%s',null,0)");
     declare(suffix,"delete-empty-non-terminal-query", "delete empty non-terminal from zone", "delete from records where domain_id='%d' and name='%s' and type is null");
 
     // and now with auth
-    declare(suffix, "basic-query-auth", "Basic query", record_auth_query+" and type='%s' and name='%s'");
-    declare(suffix, "id-query-auth", "Basic with ID query", record_auth_query+" and type='%s' and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-query-auth", "Wildcard query", record_auth_query+" and type='%s' and name like '%s'");
-    declare(suffix, "wildcard-id-query-auth", "Wildcard with ID query", record_auth_query+" and type='%s' and name like '%s' and domain_id='%d'");
+    declare(suffix, "basic-query-auth", "Basic query", record_auth_query+" disabled=0 and type='%s' and name='%s'");
+    declare(suffix, "id-query-auth", "Basic with ID query", record_auth_query+" disabled=0 and type='%s' and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-query-auth", "Wildcard query", record_auth_query+" disabled=0 and type='%s' and name like '%s'");
+    declare(suffix, "wildcard-id-query-auth", "Wildcard with ID query", record_auth_query+" disabled=0 and type='%s' and name like '%s' and domain_id='%d'");
 
-    declare(suffix, "any-query-auth", "Any query", record_auth_query+" and name='%s'");
-    declare(suffix, "any-id-query-auth", "Any with ID query", record_auth_query+" and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-any-query-auth", "Wildcard ANY query", record_auth_query+" and name like '%s'");
-    declare(suffix, "wildcard-any-id-query-auth", "Wildcard ANY with ID query", record_auth_query+" and name like '%s' and domain_id='%d'");
+    declare(suffix, "any-query-auth", "Any query", record_auth_query+" disabled=0 and name='%s'");
+    declare(suffix, "any-id-query-auth", "Any with ID query", record_auth_query+" disabled=0 and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-any-query-auth", "Wildcard ANY query", record_auth_query+" disabled=0 and name like '%s'");
+    declare(suffix, "wildcard-any-id-query-auth", "Wildcard ANY with ID query", record_auth_query+" disabled=0 and name like '%s' and domain_id='%d'");
 
-    declare(suffix, "list-query-auth", "AXFR query", record_auth_query+" and domain_id='%d' order by name, type");
-    declare(suffix, "list-subzone-query-auth", "Subzone listing", record_auth_query+" and (name='%s' OR name like '%s') and domain_id='%d'");
+    declare(suffix, "list-query-auth", "AXFR query", record_auth_query+" (disabled=0 OR %d) and domain_id='%d' order by name, type");
+    declare(suffix, "list-subzone-query-auth", "Subzone listing", record_query+" disabled=0 and (name='%s' OR name like '%s') and domain_id='%d'");
 
-    declare(suffix,"insert-empty-non-terminal-query-auth", "insert empty non-terminal in zone", "insert into records (id,domain_id,name,type,auth) values (records_id_sequence.nextval,'%d','%s',null,'1')");
+    declare(suffix, "insert-empty-non-terminal-query-auth", "insert empty non-terminal in zone", "insert into records (id,domain_id,name,type,disabled,auth) values (records_id_sequence.nextval,'%d','%s',null,0,'1')");
 
     declare(suffix,"master-zone-query","Data", "select master from domains where name='%s' and type='SLAVE'");
 
@@ -103,22 +103,22 @@ public:
     declare(suffix,"insert-zone-query","", "insert into domains (id, type, name) values(domain_id_sequence.nextval, 'NATIVE','%s')");
     declare(suffix,"insert-slave-query","", "insert into domains (id, type,name,master,account) values(domain_id_sequence.nextval, 'SLAVE','%s','%s','%s')");
 
-    declare(suffix,"insert-record-query","", "insert into records (id, content,ttl,prio,type,domain_id,name) values (records_id_sequence.nextval, '%s',%d,%d,'%s',%d,'%s')");
-    declare(suffix,"insert-record-query-auth","", "insert into records (id, content,ttl,prio,type,domain_id,name,auth) values (records_id_sequence.nextval, '%s',%d,%d,'%s',%d,'%s','%d')");
-    declare(suffix,"insert-record-order-query-auth","", "insert into records (id, content,ttl,prio,type,domain_id,name,ordername,auth) values (records_id_sequence.nextval, '%s',%d,%d,'%s',%d,'%s','%s ','%d')");
-    declare(suffix,"insert-ent-query", "insert empty non-terminal in zone", "insert into records (id, type,domain_id,name) values (records_id_sequence.nextval, null,'%d','%s')");
-    declare(suffix,"insert-ent-query-auth", "insert empty non-terminal in zone", "insert into records (id, type,domain_id,name,auth) values (records_id_sequence.nextval, null,'%d','%s','1')");
-    declare(suffix,"insert-ent-order-query-auth", "insert empty non-terminal in zone", "insert into records (id, type,domain_id,name,ordername,auth) values (records_id_sequence.nextval, null,'%d','%s','%s','1')");
+    declare(suffix, "insert-record-query", "", "insert into records (id, content,ttl,prio,type,domain_id,disabled,name) values (records_id_sequence.nextval, '%s',%d,%d,'%s',%d,%d,'%s')");
+    declare(suffix, "insert-record-query-auth", "", "insert into records (id, content,ttl,prio,type,domain_id,disabled,name,auth) values (records_id_sequence.nextval, '%s',%d,%d,'%s',%d,%d,'%s','%d')");
+    declare(suffix, "insert-record-order-query-auth", "", "insert into records (id, content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (records_id_sequence.nextval, '%s',%d,%d,'%s',%d,%d,'%s','%s ','%d')");
+    declare(suffix, "insert-ent-query", "insert empty non-terminal in zone", "insert into records (id, type,domain_id,disabled,name) values (records_id_sequence.nextval, null,'%d',0,'%s')");
+    declare(suffix, "insert-ent-query-auth", "insert empty non-terminal in zone", "insert into records (id, type,domain_id,disabled,name,auth) values (records_id_sequence.nextval, null,'%d',0,'%s','1')");
+    declare(suffix, "insert-ent-order-query-auth", "insert empty non-terminal in zone", "insert into records (id, type,domain_id,disabled,name,ordername,auth) values (records_id_sequence.nextval, null,'%d',0,'%s','%s','1')");
 
-    declare(suffix,"get-order-first-query","DNSSEC Ordering Query, first", "select trim(ordername),name from records where domain_id=%d and ordername is not null and rownum=1 order by ordername asc");
-    declare(suffix,"get-order-before-query","DNSSEC Ordering Query, before", "select trim(ordername), name from records where ordername <= '%s ' and domain_id=%d and ordername is not null and rownum=1 order by ordername desc");
-    declare(suffix,"get-order-after-query","DNSSEC Ordering Query, after", "select trim(min(ordername)) from records where ordername > '%s ' and domain_id=%d and ordername is not null");
-    declare(suffix,"get-order-last-query","DNSSEC Ordering Query, last", "select trim(ordername), name from records where ordername != ' ' and domain_id=%d and ordername is not null and rownum=1 order by ordername desc");
-    declare(suffix,"set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s ',auth=%d where name='%s' and domain_id='%d'");
-    declare(suffix,"set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=1 where domain_id='%d' and name='%s' and type='DS'");
+    declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, first", "select trim(ordername),name from records where disabled=0 and domain_id=%d and ordername is not null and rownum=1 order by ordername asc");
+    declare(suffix, "get-order-before-query", "DNSSEC Ordering Query, before", "select trim(ordername), name from records where disabled=0 and ordername <= '%s ' and domain_id=%d and ordername is not null and rownum=1 order by ordername desc");
+    declare(suffix, "get-order-after-query", "DNSSEC Ordering Query, after", "select trim(min(ordername)) from records where disabled=0 and ordername > '%s ' and domain_id=%d and ordername is not null");
+    declare(suffix, "get-order-last-query", "DNSSEC Ordering Query, last", "select trim(ordername), name from records where disabled=0 and ordername != ' ' and domain_id=%d and ordername is not null and rownum=1 order by ordername desc");
+    declare(suffix, "set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s ',auth=%d where name='%s' and domain_id='%d' and disabled=0");
+    declare(suffix, "set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=1 where domain_id='%d' and name='%s' and type='DS' and disabled=0");
 
-    declare(suffix,"nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d where domain_id='%d' and name='%s'");
-    declare(suffix,"nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=0 where name='%s' and type='%s' and domain_id='%d'");
+    declare(suffix, "nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d where domain_id='%d' and name='%s' and disabled=0");
+    declare(suffix, "nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=0 where name='%s' and type='%s' and domain_id='%d' and disabled=0");
 
     declare(suffix,"update-master-query","", "update domains set master='%s' where name='%s'");
     declare(suffix,"update-kind-query","", "update domains set type='%s' where name='%s'");
@@ -146,7 +146,7 @@ public:
     declare(suffix,"delete-tsig-key-query","", "delete from tsigkeys where name='%s'");
     declare(suffix,"get-tsig-keys-query","", "select name,algorithm, secret from tsigkeys");
 
-    declare(suffix,"get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA'");
+    declare(suffix, "get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA' and (records.disabled=0 OR %d)");
   }
 
   DNSBackend* make(const string &suffix="") {
index 5f389a05e46da2ade18fe90d5030613797f61c4f..7f20221e12196088160cf4e49589e914be7afa88 100644 (file)
@@ -46,41 +46,41 @@ public:
 
     declare(suffix,"dnssec","Assume DNSSEC Schema is in place","no");
 
-    string record_query = "SELECT content,ttl,prio,type,domain_id,name FROM records WHERE 1";
-    string record_auth_query = "SELECT content,ttl,prio,type,domain_id,name,auth::int FROM records WHERE 1";
+    string record_query = "SELECT content,ttl,prio,type,domain_id,disabled::int,name FROM records WHERE";
+    string record_auth_query = "SELECT content,ttl,prio,type,domain_id,disabled::int,name,auth::int FROM records WHERE";
 
-    declare(suffix, "basic-query", "Basic query", record_query+" and type='%s' and name=E'%s'");
-    declare(suffix, "id-query", "Basic with ID query", record_query+" and type='%s' and name=E'%s' and domain_id=%d");
-    declare(suffix, "wildcard-query", "Wildcard query", record_query+" and type='%s' and name like E'%s'");
-    declare(suffix, "wildcard-id-query", "Wildcard with ID query", record_query+" and type='%s' and name like E'%s' and domain_id='%d'");
+    declare(suffix, "basic-query", "Basic query", record_query+" disabled=false and type='%s' and name=E'%s'");
+    declare(suffix, "id-query", "Basic with ID query", record_query+" disabled=false and type='%s' and name=E'%s' and domain_id=%d");
+    declare(suffix, "wildcard-query", "Wildcard query", record_query+" disabled=false and type='%s' and name like E'%s'");
+    declare(suffix, "wildcard-id-query", "Wildcard with ID query", record_query+" disabled=false and type='%s' and name like E'%s' and domain_id='%d'");
 
-    declare(suffix, "any-query", "Any query", record_query+" and name=E'%s'");
-    declare(suffix, "any-id-query", "Any with ID query", record_query+" and name=E'%s' and domain_id=%d");
-    declare(suffix, "wildcard-any-query", "Wildcard ANY query", record_query+" and name like E'%s'");
-    declare(suffix, "wildcard-any-id-query", "Wildcard ANY with ID query", record_query+" and name like E'%s' and domain_id='%d'");
+    declare(suffix, "any-query", "Any query", record_query+" disabled=false and name=E'%s'");
+    declare(suffix, "any-id-query", "Any with ID query", record_query+" disabled=false and name=E'%s' and domain_id=%d");
+    declare(suffix, "wildcard-any-query", "Wildcard ANY query", record_query+" disabled=false and name like E'%s'");
+    declare(suffix, "wildcard-any-id-query", "Wildcard ANY with ID query", record_query+" disabled=false and name like E'%s' and domain_id='%d'");
 
-    declare(suffix, "list-query", "AXFR query", record_query+" and domain_id='%d'");
-    declare(suffix, "list-subzone-query", "Subzone listing", record_query+" and (name=E'%s' OR name like E'%s') and domain_id='%d'");
+    declare(suffix, "list-query", "AXFR query", record_query+" (disabled=false OR %d::bool) and domain_id='%d'");
+    declare(suffix, "list-subzone-query", "Subzone listing", record_query+" disabled=false and (name=E'%s' OR name like E'%s') and domain_id='%d'");
 
     declare(suffix,"remove-empty-non-terminals-from-zone-query", "remove all empty non-terminals from zone", "delete from records where domain_id='%d' and type is null");
-    declare(suffix,"insert-empty-non-terminal-query", "insert empty non-terminal in zone", "insert into records (domain_id,name,type) values ('%d','%s',null)");
+    declare(suffix,"insert-empty-non-terminal-query", "insert empty non-terminal in zone", "insert into records (domain_id,name,type,disabled) values ('%d','%s',null,false)");
     declare(suffix,"delete-empty-non-terminal-query", "delete empty non-terminal from zone", "delete from records where domain_id='%d' and name='%s' and type is null");
 
     // and now with auth
-    declare(suffix, "basic-query-auth", "Basic query", record_auth_query+" and type='%s' and name=E'%s'");
-    declare(suffix, "id-query-auth", "Basic with ID query", record_auth_query+" and type='%s' and name=E'%s' and domain_id=%d");
-    declare(suffix, "wildcard-query-auth", "Wildcard query", record_auth_query+" and type='%s' and name like E'%s'");
-    declare(suffix, "wildcard-id-query-auth", "Wildcard with ID query", record_auth_query+" and type='%s' and name like E'%s' and domain_id='%d'");
+    declare(suffix, "basic-query-auth", "Basic query", record_auth_query+" disabled=false and type='%s' and name=E'%s'");
+    declare(suffix, "id-query-auth", "Basic with ID query", record_auth_query+" disabled=false and type='%s' and name=E'%s' and domain_id=%d");
+    declare(suffix, "wildcard-query-auth", "Wildcard query", record_auth_query+" disabled=false and type='%s' and name like E'%s'");
+    declare(suffix, "wildcard-id-query-auth", "Wildcard with ID query", record_auth_query+" disabled=false and type='%s' and name like E'%s' and domain_id='%d'");
 
-    declare(suffix, "any-query-auth", "Any query", record_auth_query+" and name=E'%s'");
-    declare(suffix, "any-id-query-auth", "Any with ID query", record_auth_query+" and name=E'%s' and domain_id=%d");
-    declare(suffix, "wildcard-any-query-auth", "Wildcard ANY query", record_auth_query+" and name like E'%s'");
-    declare(suffix, "wildcard-any-id-query-auth", "Wildcard ANY with ID query", record_auth_query+" and name like E'%s' and domain_id='%d'");
+    declare(suffix, "any-query-auth", "Any query", record_auth_query+" disabled=false and name=E'%s'");
+    declare(suffix, "any-id-query-auth", "Any with ID query", record_auth_query+" disabled=false and name=E'%s' and domain_id=%d");
+    declare(suffix, "wildcard-any-query-auth", "Wildcard ANY query", record_auth_query+" disabled=false and name like E'%s'");
+    declare(suffix, "wildcard-any-id-query-auth", "Wildcard ANY with ID query", record_auth_query+" disabled=false and name like E'%s' and domain_id='%d'");
 
-    declare(suffix, "list-query-auth", "AXFR query", record_auth_query+" and domain_id='%d' order by name, type");
-    declare(suffix, "list-subzone-query-auth", "Subzone listing", record_auth_query+" and (name=E'%s' OR name like E'%s') and domain_id='%d'");
+    declare(suffix, "list-query-auth", "AXFR query", record_auth_query+" (disabled=false OR %d::bool) and domain_id='%d' order by name, type");
+    declare(suffix, "list-subzone-query-auth", "Subzone listing", record_auth_query+" disabled=false and (name=E'%s' OR name like E'%s') and domain_id='%d'");
 
-    declare(suffix,"insert-empty-non-terminal-query-auth", "insert empty non-terminal in zone", "insert into records (domain_id,name,type,auth) values ('%d','%s',null,true)");
+    declare(suffix, "insert-empty-non-terminal-query-auth", "insert empty non-terminal in zone", "insert into records (domain_id,name,type,disabled,auth) values ('%d','%s',null,false,true)");
 
     declare(suffix,"master-zone-query","Data", "select master from domains where name=E'%s' and type='SLAVE'");
 
@@ -92,22 +92,22 @@ public:
     declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',E'%s')");
     declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',E'%s',E'%s',E'%s')");
 
-    declare(suffix,"insert-record-query","", "insert into records (content,ttl,prio,type,domain_id,name) values (E'%s',%d,%d,'%s',%d,E'%s')");
-    declare(suffix,"insert-record-query-auth","", "insert into records (content,ttl,prio,type,domain_id,name,auth) values (E'%s',%d,%d,'%s',%d,E'%s','%d')");
-    declare(suffix,"insert-record-order-query-auth","", "insert into records (content,ttl,prio,type,domain_id,name,ordername,auth) values (E'%s',%d,%d,'%s',%d,E'%s',E'%s','%d')");
-    declare(suffix,"insert-ent-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,name) values (null,'%d',E'%s')");
-    declare(suffix,"insert-ent-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,name,auth) values (null,'%d',E'%s',true)");
-    declare(suffix,"insert-ent-order-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,name,ordername,auth) values (null,'%d',E'%s',E'%s',true)");
+    declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name) values (E'%s',%d,%d,'%s',%d,%d::bool,E'%s')");
+    declare(suffix, "insert-record-query-auth", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values (E'%s',%d,%d,'%s',%d,%d::bool,E'%s','%d')");
+    declare(suffix, "insert-record-order-query-auth", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (E'%s',%d,%d,'%s',%d,%d::bool,E'%s',E'%s','%d')");
+    declare(suffix, "insert-ent-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name) values (null,'%d',false,E'%s')");
+    declare(suffix, "insert-ent-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,auth) values (null,'%d',false,E'%s',true)");
+    declare(suffix, "insert-ent-order-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth) values (null,'%d',false,E'%s',E'%s',true)");
 
-    declare(suffix,"get-order-first-query","DNSSEC Ordering Query, last", "select ordername, name from records where domain_id=%d and ordername is not null order by 1 using ~<~ limit 1");
-    declare(suffix,"get-order-before-query","DNSSEC Ordering Query, before", "select ordername, name from records where ordername ~<=~ E'%s' and domain_id=%d and ordername is not null order by 1 using ~>~ limit 1");
-    declare(suffix,"get-order-after-query","DNSSEC Ordering Query, after", "select ordername from records where ordername ~>~ E'%s' and domain_id=%d and ordername is not null order by 1 using ~<~ limit 1");
-    declare(suffix,"get-order-last-query","DNSSEC Ordering Query, last", "select ordername, name from records where ordername != '' and domain_id=%d and ordername is not null order by 1 using ~>~ limit 1");
-    declare(suffix,"set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername=E'%s',auth=%d::bool where name=E'%s' and domain_id='%d'");
-    declare(suffix,"set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=true where domain_id='%d' and name='%s' and type='DS'");
+    declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, last", "select ordername, name from records where disabled=false and domain_id=%d and ordername is not null order by 1 using ~<~ limit 1");
+    declare(suffix, "get-order-before-query", "DNSSEC Ordering Query, before", "select ordername, name from records where disabled=false and ordername ~<=~ E'%s' and domain_id=%d and ordername is not null order by 1 using ~>~ limit 1");
+    declare(suffix, "get-order-after-query", "DNSSEC Ordering Query, after", "select ordername from records where disabled=false and ordername ~>~ E'%s' and domain_id=%d and ordername is not null order by 1 using ~<~ limit 1");
+    declare(suffix, "get-order-last-query", "DNSSEC Ordering Query, last", "select ordername, name from records where disabled=false and ordername != '' and domain_id=%d and ordername is not null order by 1 using ~>~ limit 1");
+    declare(suffix, "set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername=E'%s',auth=%d::bool where name=E'%s' and domain_id='%d' and disabled=false");
+    declare(suffix, "set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=true where domain_id='%d' and name='%s' and type='DS' and disabled=false");
 
-    declare(suffix,"nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d::bool where domain_id='%d' and name='%s'");
-    declare(suffix,"nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=false where name=E'%s' and type=E'%s' and domain_id='%d'");
+    declare(suffix, "nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d::bool where domain_id='%d' and name='%s' and disabled=false");
+    declare(suffix, "nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=false where name=E'%s' and type=E'%s' and domain_id='%d' and disabled=false");
 
     declare(suffix,"update-master-query","", "update domains set master='%s' where name='%s'");
     declare(suffix,"update-kind-query","", "update domains set type='%s' where name='%s'");
@@ -135,7 +135,7 @@ public:
     declare(suffix,"delete-tsig-key-query","", "delete from tsigkeys where name='%s'");
     declare(suffix,"get-tsig-keys-query","", "select name,algorithm, secret from tsigkeys");
 
-    declare(suffix,"get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA'");
+    declare(suffix, "get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA' and (records.disabled=false OR %d::bool)");
   }
 
   DNSBackend *make(const string &suffix="")
index c48e1d76978a0818b73ac10617ecf5c3cd36f99c..53d9ec56a158eace5a6ce0b0d4dac31434a71354 100644 (file)
@@ -19,6 +19,7 @@ CREATE TABLE records (
         ttl             INT DEFAULT NULL,
         prio            INT DEFAULT NULL,
         change_date     INT DEFAULT NULL,
+        disabled        BOOL DEFAULT NULL,
         CONSTRAINT domain_exists
         FOREIGN KEY(domain_id) REFERENCES domains(id)
         ON DELETE CASCADE,
index f1de2080b84b7e5ca6456ba61a22d2131f265c1d..0c3336b81a3c52ae9fc0a06ed4bc19130888cb9c 100644 (file)
@@ -58,51 +58,51 @@ public:
     declare( suffix, "database", "Filename of the SQLite3 database", "powerdns.sqlite" );
     declare( suffix, "pragma-synchronous", "Set this to 0 for blazing speed", "" );
 
-    string record_query = "SELECT content,ttl,prio,type,domain_id,name FROM records WHERE 1";
-    string record_auth_query = "SELECT content,ttl,prio,type,domain_id,name,auth FROM records WHERE 1";
+    string record_query = "SELECT content,ttl,prio,type,domain_id,disabled,name FROM records WHERE";
+    string record_auth_query = "SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE";
 
-    declare(suffix, "basic-query", "Basic query", record_query+" and type='%s' and name='%s'");
-    declare(suffix, "id-query", "Basic with ID query", record_query+" and type='%s' and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-query", "Wildcard query", record_query+" and type='%s' and name like '%s'");
-    declare(suffix, "wildcard-id-query", "Wildcard with ID query", record_query+" and type='%s' and name like '%s' and domain_id=%d");
+    declare(suffix, "basic-query", "Basic query", record_query+" disabled=0 and type='%s' and name='%s'");
+    declare(suffix, "id-query", "Basic with ID query", record_query+" disabled=0 and type='%s' and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-query", "Wildcard query", record_query+" disabled=0 and type='%s' and name like '%s'");
+    declare(suffix, "wildcard-id-query", "Wildcard with ID query", record_query+" disabled=0 and type='%s' and name like '%s' and domain_id=%d");
 
-    declare(suffix, "any-query", "Any query", record_query+" and name='%s'");
-    declare(suffix, "any-id-query", "Any with ID query", record_query+" and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-any-query", "Wildcard ANY query", record_query+" and name like '%s'");
-    declare(suffix, "wildcard-any-id-query", "Wildcard ANY with ID query", record_query+" and name like '%s' and domain_id=%d");
+    declare(suffix, "any-query", "Any query", record_query+" disabled=0 and name='%s'");
+    declare(suffix, "any-id-query", "Any with ID query", record_query+" disabled=0 and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-any-query", "Wildcard ANY query", record_query+" disabled=0 and name like '%s'");
+    declare(suffix, "wildcard-any-id-query", "Wildcard ANY with ID query", record_query+" disabled=0 and name like '%s' and domain_id=%d");
 
-    declare(suffix, "list-query", "AXFR query", record_query+" and domain_id=%d");
-    declare(suffix, "list-subzone-query", "Subzone listing", record_query+" and (name='%s' OR name like '%s') and domain_id=%d");
+    declare(suffix, "list-query", "AXFR query", record_query+" (disabled=0 OR %d) and domain_id=%d");
+    declare(suffix, "list-subzone-query", "Subzone listing", record_query+" disabled=0 and (name='%s' OR name like '%s') and domain_id=%d");
 
     declare(suffix,"remove-empty-non-terminals-from-zone-query", "remove all empty non-terminals from zone", "delete from records where domain_id='%d' and type is null");
-    declare(suffix,"insert-empty-non-terminal-query", "insert empty non-terminal in zone", "insert into records (domain_id,name,type) values ('%d','%s',null)");
+    declare(suffix,"insert-empty-non-terminal-query", "insert empty non-terminal in zone", "insert into records (domain_id,name,type,disabled) values ('%d','%s',null,0)");
     declare(suffix,"delete-empty-non-terminal-query", "delete empty non-terminal from zone", "delete from records where domain_id='%d' and name='%s' and type is null");
     
     // and now with auth
-    declare(suffix, "basic-query-auth", "Basic query", record_auth_query+" and type='%s' and name='%s'");
-    declare(suffix, "id-query-auth", "Basic with ID query", record_auth_query+" and type='%s' and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-query-auth", "Wildcard query", record_auth_query+" and type='%s' and name like '%s'");
-    declare(suffix, "wildcard-id-query-auth", "Wildcard with ID query", record_auth_query+" and type='%s' and name like '%s' and domain_id='%d'");
+    declare(suffix, "basic-query-auth", "Basic query", record_auth_query+" disabled=0 and type='%s' and name='%s'");
+    declare(suffix, "id-query-auth", "Basic with ID query", record_auth_query+" disabled=0 and type='%s' and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-query-auth", "Wildcard query", record_auth_query+" disabled=0 and type='%s' and name like '%s'");
+    declare(suffix, "wildcard-id-query-auth", "Wildcard with ID query", record_auth_query+" disabled=0 and type='%s' and name like '%s' and domain_id='%d'");
 
-    declare(suffix, "any-query-auth", "Any query", record_auth_query+" and name='%s'");
-    declare(suffix, "any-id-query-auth", "Any with ID query", record_auth_query+" and name='%s' and domain_id=%d");
-    declare(suffix, "wildcard-any-query-auth", "Wildcard ANY query", record_auth_query+" and name like '%s'");
-    declare(suffix, "wildcard-any-id-query-auth", "Wildcard ANY with ID query", record_auth_query+" and name like '%s' and domain_id='%d'");
+    declare(suffix, "any-query-auth", "Any query", record_auth_query+" disabled=0 and name='%s'");
+    declare(suffix, "any-id-query-auth", "Any with ID query", record_auth_query+" disabled=0 and name='%s' and domain_id=%d");
+    declare(suffix, "wildcard-any-query-auth", "Wildcard ANY query", record_auth_query+" disabled=0 and name like '%s'");
+    declare(suffix, "wildcard-any-id-query-auth", "Wildcard ANY with ID query", record_auth_query+" disabled=0 and name like '%s' and domain_id='%d'");
 
-    declare(suffix, "list-query-auth", "AXFR query", record_auth_query+" and domain_id='%d' order by name, type");
-    declare(suffix, "list-subzone-query-auth", "Subzone listing", record_auth_query+" and (name='%s' OR name like '%s') and domain_id=%d");
+    declare(suffix, "list-query-auth", "AXFR query", record_auth_query+" (disabled=0 OR %d) and domain_id='%d' order by name, type");
+    declare(suffix, "list-subzone-query-auth", "Subzone listing", record_auth_query+" disabled=0 and (name='%s' OR name like '%s') and domain_id=%d");
 
-    declare(suffix,"insert-empty-non-terminal-query-auth", "insert empty non-terminal in zone", "insert into records (domain_id,name,type,auth) values ('%d','%s',null,'1')");
+    declare(suffix, "insert-empty-non-terminal-query-auth", "insert empty non-terminal in zone", "insert into records (domain_id,name,type,disabled,auth) values ('%d','%s',null,0,'1')");
     
-    declare(suffix,"get-order-first-query","DNSSEC Ordering Query, first", "select ordername, name from records where domain_id=%d and ordername is not null order by 1 asc limit 1");
-    declare(suffix,"get-order-before-query","DNSSEC Ordering Query, before", "select ordername, name from records where ordername <= '%s' and domain_id=%d and ordername is not null order by 1 desc limit 1");
-    declare(suffix,"get-order-after-query","DNSSEC Ordering Query, after", "select min(ordername) from records where ordername > '%s' and domain_id=%d and ordername is not null");
-    declare(suffix,"get-order-last-query","DNSSEC Ordering Query, last", "select ordername, name from records where ordername != '' and domain_id=%d and ordername is not null order by 1 desc limit 1");
-    declare(suffix,"set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s',auth=%d where name='%s' and domain_id='%d'");
-
-    declare(suffix,"nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d where domain_id='%d' and name='%s'");
-    declare(suffix,"nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=0 where name='%s' and type='%s' and domain_id='%d'");
-    declare(suffix,"set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=1 where domain_id='%d' and name='%s' and type='DS'");
+    declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, first", "select ordername, name from records where disabled=0 and domain_id=%d and ordername is not null order by 1 asc limit 1");
+    declare(suffix, "get-order-before-query", "DNSSEC Ordering Query, before", "select ordername, name from records where disabled=0 and ordername <= '%s' and domain_id=%d and ordername is not null order by 1 desc limit 1");
+    declare(suffix, "get-order-after-query", "DNSSEC Ordering Query, after", "select min(ordername) from records where disabled=0 and ordername > '%s' and domain_id=%d and ordername is not null");
+    declare(suffix, "get-order-last-query", "DNSSEC Ordering Query, last", "select ordername, name from records where disabled=0 and ordername != '' and domain_id=%d and ordername is not null order by 1 desc limit 1");
+    declare(suffix, "set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s',auth=%d where name='%s' and domain_id='%d' and disabled=0");
+
+    declare(suffix, "nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d where domain_id='%d' and name='%s' and disabled=0");
+    declare(suffix, "nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=0 where name='%s' and type='%s' and domain_id='%d' and disabled=0");
+    declare(suffix, "set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=1 where domain_id='%d' and name='%s' and type='DS' and disabled=0");
     
     declare( suffix, "master-zone-query", "Data", "select master from domains where name='%s' and type='SLAVE'");
 
@@ -114,12 +114,12 @@ public:
     declare( suffix, "insert-zone-query", "", "insert into domains (type,name) values('NATIVE','%s')");
     declare( suffix, "insert-slave-query", "", "insert into domains (type,name,master,account) values('SLAVE','%s','%s','%s')");
 
-    declare( suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,name) values ('%s',%d,%d,'%s',%d,'%s')");
-    declare( suffix, "insert-record-query-auth", "", "insert into records (content,ttl,prio,type,domain_id,name,auth) values ('%s',%d,%d,'%s',%d,'%s',%d)");
-    declare( suffix, "insert-record-order-query-auth","", "insert into records (content,ttl,prio,type,domain_id,name,ordername,auth) values ('%s',%d,%d,'%s',%d,'%s','%s','%d')");
-    declare( suffix, "insert-ent-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,name) values (null,'%d','%s')");
-    declare( suffix, "insert-ent-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,name,auth) values (null,'%d','%s','1')");
-    declare( suffix, "insert-ent-order-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,name,ordername,auth) values (null,'%d','%s','%s','1')");
+    declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name) values ('%s',%d,%d,'%s',%d,%d,'%s')");
+    declare(suffix, "insert-record-query-auth", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values ('%s',%d,%d,'%s',%d,%d,'%s',%d)");
+    declare(suffix, "insert-record-order-query-auth", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values ('%s',%d,%d,%d,'%s','%s',%d,'%s','%d')");
+    declare(suffix, "insert-ent-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name) values (null,'%d',0,'%s')");
+    declare(suffix, "insert-ent-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,auth) values (null,'%d',0,'%s','1')");
+    declare(suffix, "insert-ent-order-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth) values (null,'%d',0,'%s','%s','1')");
 
     declare( suffix, "update-master-query", "", "update domains set master='%s' where name='%s'");
     declare( suffix, "update-kind-query", "", "update domains set type='%s' where name='%s'");
@@ -148,7 +148,7 @@ public:
     declare(suffix,"delete-tsig-key-query","", "delete from tsigkeys where name='%s'");
     declare(suffix,"get-tsig-keys-query","", "select name,algorithm, secret from tsigkeys");
 
-    declare(suffix,"get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA'");
+    declare(suffix, "get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA' and (records.disabled=0 OR %d)");
   }
   
   //! Constructs a new gSQLite3Backend object.
index a6f13b966ba3050f93946c33a42b6d5e624a025d..81aed15bc58018db43254fc2f19213394f21564a 100644 (file)
@@ -18,7 +18,8 @@ CREATE TABLE records (
   content         VARCHAR(65535) DEFAULT NULL,
   ttl             INTEGER DEFAULT NULL,
   prio            INTEGER DEFAULT NULL,
-  change_date     INTEGER DEFAULT NULL
+  change_date     INTEGER DEFAULT NULL,
+  disabled        BOOLEAN DEFAULT NULL
 );
 
 CREATE INDEX rec_name_index ON records(name);
index 0e8654d55eb36b036ff0a442fa5fcd28cb4dff27..5409ebee3fc11c7020020f792da64413a04f1c0e 100644 (file)
@@ -33,7 +33,7 @@ public:
 
     LUABackend(const string &suffix="");
     ~LUABackend();
-    bool list(const string &target, int domain_id);
+    bool list(const string &target, int domain_id, bool include_disabled=false);
     void lookup(const QType &qtype, const string &qname, DNSPacket *p, int domain_id);
     bool get(DNSResourceRecord &rr);
     //! fills the soadata struct with the SOA details. Returns false if there is no SOA.
index 3229b3d939782318bb200a9fd578e7a255c006c5..3c7072331f18909ecaa303cea30f79b4e4832b1d 100644 (file)
@@ -58,7 +58,7 @@ LUABackend::~LUABackend() {
     lua_close(lua);
 }
 
-bool LUABackend::list(const string &target, int domain_id) {
+bool LUABackend::list(const string &target, int domain_id, bool include_disabled) {
     if (logging)
        L << Logger::Info << backend_name << "(list) BEGIN" << endl;
 
index 12bb07984b0e06373102740312287030e00edc40..e4e6d769ea6152315b51a9b47591b38c82d579f1 100644 (file)
@@ -81,7 +81,7 @@ void MyDNSBackend::Query(const string &query) {
         }
 }
 
-bool MyDNSBackend::list(const string &target, int zoneId) {
+bool MyDNSBackend::list(const string &target, int zoneId, bool include_disabled) {
         string query;
         string sname;
         SSql::row_t rrow;
index 1d9f867d9e40f397e23e74f0bc32b3524ecc6904..5caa80be9e2466500a865a994c23fb1f5d049086 100644 (file)
@@ -15,7 +15,7 @@ public:
         ~MyDNSBackend();
         
         void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1);
-        bool list(const string &target, int domain_id);
+        bool list(const string &target, int domain_id, bool include_disabled=false);
         bool get(DNSResourceRecord &r);
         bool getSOA(const string& name, SOAData& soadata, DNSPacket*);
           
index 1361dd2d132b548aad8c4da362db90621c34290c..a098f9ff0ac7d0ccf1e422973f355f74b04f358c 100644 (file)
@@ -231,7 +231,7 @@ bool OdbxBackend::getSOA( const string& domain, SOAData& sd, DNSPacket* p )
 
 
 
-bool OdbxBackend::list( const string& target, int zoneid )
+bool OdbxBackend::list( const string& target, int zoneid, bool include_disabled )
 {
         try
         {
index bc9a29aa2f8e28031217ce302c219cddddf96db3..54d016d76684e131b25ecd5523a7dc9b134bd9bb 100644 (file)
@@ -77,7 +77,7 @@ public:
 
         void lookup( const QType& qtype, const string& qdomain, DNSPacket* p = 0, int zoneid = -1 );
         bool getSOA( const string& domain, SOAData& sd, DNSPacket* p );
-        bool list( const string& target, int domain_id );
+        bool list( const string& target, int domain_id, bool include_disabled=false );
         bool get( DNSResourceRecord& rr );
 
         bool startTransaction( const string& domain, int domain_id );
index 524e725dd1e8b3ddaa88ee5e8c2b115159ef2967..f07eecc0b067d76414c0a33107d34075972acb5c 100644 (file)
@@ -931,7 +931,7 @@ OracleBackend::setNotified (uint32_t zoneId, uint32_t serial)
 }
 
 bool
-OracleBackend::list (const string &domain, int zoneId)
+OracleBackend::list (const string &domain, int zoneId, bool include_disabled)
 {
   sword rc;
 
index 4b5ee77bb897017aea53bf58bc13b303cd148233..00a14f62163aacb72882aad8aaf4071fda20cfb2 100644 (file)
@@ -146,7 +146,7 @@ void PipeBackend::lookup(const QType &qtype,const string &qname, DNSPacket *pkt_
    d_qname=qname;
 }
 
-bool PipeBackend::list(const string &target, int inZoneId)
+bool PipeBackend::list(const string &target, int inZoneId, bool include_disabled)
 {
    try {
       d_disavow=false;
index 6123d27715517bcf68debcd094f3ad3feca802ed..07bc3995cc8b8b99eab8965062ea227776e49d74 100644 (file)
@@ -37,7 +37,7 @@ public:
   PipeBackend(const string &suffix="");
   ~PipeBackend();
   void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1);
-  bool list(const string &target, int domain_id);
+  bool list(const string &target, int domain_id, bool include_disabled=false);
   bool get(DNSResourceRecord &r);
   
   static DNSBackend *maker();
index 43395673f52a9665ed5672b19335a5f88007d3e3..3dc25ff7a284ada96c88ca69f941b67d7d5276e1 100644 (file)
@@ -38,7 +38,7 @@ public:
     d_ourname=getArg("hostname");
   }
 
-  bool list(const string &target, int id) {
+  bool list(const string &target, int id, bool include_disabled) {
     return false; // we don't support AXFR
   }
     
index 7a63d94b6a2529ecefe2d7ff426cac00595744ee..36cdc5b03840509fd250e84c4cd0e379cc5e15e4 100644 (file)
@@ -207,7 +207,7 @@ void RemoteBackend::lookup(const QType &qtype, const std::string &qdomain, DNSPa
    d_index = 0;
 }
 
-bool RemoteBackend::list(const std::string &target, int domain_id) {
+bool RemoteBackend::list(const std::string &target, int domain_id, bool include_disabled) {
    rapidjson::Document query;
    rapidjson::Value parameters;
 
index b2ed5209837a1d459dcb3b2a40f45838697ede64..bcbd4290831f6e2f779ffef72c50f41bff44814e 100644 (file)
@@ -130,7 +130,7 @@ class RemoteBackend : public DNSBackend
 
   void lookup(const QType &qtype, const std::string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1);
   bool get(DNSResourceRecord &rr);
-  bool list(const std::string &target, int domain_id);
+  bool list(const std::string &target, int domain_id, bool include_disabled=false);
 
   virtual bool getDomainMetadata(const std::string& name, const std::string& kind, std::vector<std::string>& meta);
   virtual bool getDomainKeys(const std::string& name, unsigned int kind, std::vector<DNSBackend::KeyData>& keys);
index 34091386ec4cb19082c1d440bb3c43aa58e4ff63..8d7274f8a1a0264fae6a522a63bbc927bbab3328 100644 (file)
@@ -126,7 +126,7 @@ void TinyDNSBackend::setNotified(uint32_t id, uint32_t serial) {
        s_domainInfo[d_suffix] = *domains;
 }
 
-void TinyDNSBackend::getAllDomains(vector<DomainInfo> *domains) {
+void TinyDNSBackend::getAllDomains(vector<DomainInfo> *domains, bool include_disabled) {
        d_isAxfr=true;
        d_dnspacket = NULL;
 
@@ -152,7 +152,7 @@ void TinyDNSBackend::getAllDomains(vector<DomainInfo> *domains) {
        }
 }
 
-bool TinyDNSBackend::list(const string &target, int domain_id) {
+bool TinyDNSBackend::list(const string &target, int domain_id, bool include_disabled) {
        d_isAxfr=true;
        string key = simpleCompress(target);
        d_cdbReader=new CDB(getArg("dbfile"));
index 390c7f51432c0764a926100e3c4f323ca3a5f0d9..526b759fcffcb00dfc83be1a2624a628d325aca5 100644 (file)
@@ -48,9 +48,9 @@ public:
        // Methods for simple operation
        TinyDNSBackend(const string &suffix);
        void lookup(const QType &qtype, const string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1);
-       bool list(const string &target, int domain_id);
+       bool list(const string &target, int domain_id, bool include_disabled=false);
        bool get(DNSResourceRecord &rr);
-       void getAllDomains(vector<DomainInfo> *domains);
+       void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false);
 
        //Master mode operation
        void getUpdatedMasters(vector<DomainInfo>* domains);
index 8f8f816ca5ccb8e71f0157fa4b695326abc5888e..8805e407d236c99ac60b76f3bb8ae56edec834dd 100644 (file)
@@ -838,11 +838,12 @@ void GSQLBackend::lookup(const QType &qtype,const string &qname, DNSPacket *pkt_
   d_qname=qname;
 }
 
-bool GSQLBackend::list(const string &target, int domain_id )
+bool GSQLBackend::list(const string &target, int domain_id, bool include_disabled)
 {
   DLOG(L<<"GSQLBackend constructing handle for list of domain id '"<<domain_id<<"'"<<endl);
 
   string query = (boost::format(d_listQuery)
+                  % (int)include_disabled
                   % domain_id
     ).str();
 
@@ -979,12 +980,13 @@ bool GSQLBackend::deleteDomain(const string &domain)
   return true;
 }
 
-void GSQLBackend::getAllDomains(vector<DomainInfo> *domains
+void GSQLBackend::getAllDomains(vector<DomainInfo> *domains, bool include_disabled)
 {
   DLOG(L<<"GSQLBackend retrieving all domains."<<endl);
+  string query = (boost::format(d_getAllDomainsQuery) % (int)include_disabled).str();
 
   try {
-    d_db->doQuery(d_getAllDomainsQuery.c_str()); 
+    d_db->doQuery(query);
   }
   catch (SSqlException &e) {
     throw PDNSException("Database error trying to retrieve all domains:" + e.txtReason());
@@ -1036,15 +1038,17 @@ bool GSQLBackend::get(DNSResourceRecord &r)
     if(!d_qname.empty())
       r.qname=d_qname;
     else
-      r.qname=row[5];
+      r.qname=row[6];
     r.qtype=row[3];
     r.last_modified=0;
     
     if(d_dnssecQueries)
-      r.auth = !row[6].empty() && row[6][0]=='1';
+      r.auth = !row[7].empty() && row[7][0]=='1';
     else
       r.auth = 1; 
-    
+
+    r.disabled = !row[5].empty() && row[5][0]=='1';
+
     r.domain_id=atoi(row[4].c_str());
     return true;
   }
@@ -1086,6 +1090,7 @@ bool GSQLBackend::feedRecord(const DNSResourceRecord &r, string *ordername)
                % r.priority
                % sqlEscape(r.qtype.getName())
                % r.domain_id
+               % (int)r.disabled
                % toLower(sqlEscape(r.qname))
                % sqlEscape(*ordername)
                % (int)r.auth
@@ -1097,6 +1102,7 @@ bool GSQLBackend::feedRecord(const DNSResourceRecord &r, string *ordername)
                % r.priority
                % sqlEscape(r.qtype.getName())
                % r.domain_id
+               % (int)r.disabled
                % toLower(sqlEscape(r.qname))
                % (int)r.auth
         ).str();
@@ -1107,6 +1113,7 @@ bool GSQLBackend::feedRecord(const DNSResourceRecord &r, string *ordername)
              % r.priority
              % sqlEscape(r.qtype.getName())
              % r.domain_id
+             % (int)r.disabled
              % toLower(sqlEscape(r.qname))
       ).str();
   }
index efc417512672d873bbbee0fd633894b84372882a..9049571c7119b5ed2596e4b2e9785b3214bfd1f6 100644 (file)
@@ -28,9 +28,9 @@ public:
   
   virtual string sqlEscape(const string &name);
   void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1);
-  bool list(const string &target, int domain_id);
+  bool list(const string &target, int domain_id, bool include_disabled=false);
   bool get(DNSResourceRecord &r);
-  void getAllDomains(vector<DomainInfo> *domains);
+  void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false);
   bool isMaster(const string &domain, const string &ip);
   void alsoNotifies(const string &domain, set<string> *ips);
   bool startTransaction(const string &domain, int domain_id=-1);
index 47ec216cc5098f437aeb536e156ee4fb4f67fab4..f0099aa592db9f0f68f0d97f4d62e52c68be0724 100644 (file)
@@ -73,7 +73,7 @@ public:
 class DNSResourceRecord
 {
 public:
-  DNSResourceRecord() : qclass(1), priority(0), signttl(0), last_modified(0), d_place(ANSWER), auth(1), scopeMask(0) {};
+  DNSResourceRecord() : qclass(1), priority(0), signttl(0), last_modified(0), d_place(ANSWER), auth(1), disabled(0), scopeMask(0) {};
   DNSResourceRecord(const struct DNSRecord&);
   ~DNSResourceRecord(){};
 
@@ -96,6 +96,7 @@ public:
   Place d_place; //!< This specifies where a record goes within the packet
 
   bool auth;
+  bool disabled;
   uint8_t scopeMask;
 
   template<class Archive>
@@ -112,6 +113,7 @@ public:
     ar & last_modified;
     ar & d_place;
     ar & auth;
+    ar & disabled;
   }
 
   bool operator==(const DNSResourceRecord& rhs);
index f279e02c65d8bff8dd93608bf48c166c43b51eef..c305cfba6065dde008d07343c0aee9644bdaa9a8 100644 (file)
@@ -112,7 +112,7 @@ public:
       if the backend does not consider itself responsible for the id passed.
       \param domain_id ID of which a list is requested
   */
-  virtual bool list(const string &target, int domain_id)=0;  
+  virtual bool list(const string &target, int domain_id, bool include_disabled=false)=0;
 
   virtual ~DNSBackend(){};
 
@@ -136,7 +136,7 @@ public:
   virtual bool getDomainMetadata(const string& name, const std::string& kind, std::vector<std::string>& meta) { return false; }
   virtual bool setDomainMetadata(const string& name, const std::string& kind, const std::vector<std::string>& meta) {return false;}
 
-  virtual void getAllDomains(vector<DomainInfo> *domains) { }
+  virtual void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false) { }
 
   /** Determines if we are authoritative for a zone, and at what level */
   virtual bool getAuth(DNSPacket *p, SOAData *sd, const string &target, int *zoneId, const int best_match_len);
index 66e4f5b628fd23ce48c8cf01c6bc99415b09b223..798db95e2b1dbcf40b2b6a18d0548101734d0dde 100644 (file)
@@ -84,6 +84,7 @@ bool DNSResourceRecord::operator==(const DNSResourceRecord& rhs)
 
 DNSResourceRecord::DNSResourceRecord(const DNSRecord &p) {
   auth=true;
+  disabled=false;
   qname = p.d_label;
   if(!qname.empty())
     boost::erase_tail(qname, 1); // strip .
index 296986b629046d6e42c5d2d9549e924f86dab7ea..2ae16212d8239e7800f624ca75a1f46feb4c7247 100644 (file)
@@ -12473,6 +12473,37 @@ create index recordorder on records (domain_id, ordername text_pattern_ops);
     </para>
   </sect1>
 
+  <sect1 id="from3.3.1to3.4"><title>From PowerDNS Authoritative Server 3.3.1 to 3.4</title>
+    <note>
+      <para>
+        If you are coming from 2.9.x, please also read <xref linkend="from2.9to3.0" />, <xref linkend="from3.0to3.1" />, <xref linkend="from3.1to3.2" /> and <xref linkend="from3.2to3.3" /> and <xref linkend="from3.3to3.3.1" />.
+      </para>
+    </note>
+    <para>
+      An GSQL Backend schema change is necessary for new features.
+      For MySQL:
+      <screen>
+ALTER TABLE records ADD disabled BOOLEAN;
+UPDATE records SET disabled=0;
+</screen>
+      For PostgreSQL:
+      <screen>
+ALTER TABLE records ADD disabled BOOLEAN;
+UPDATE records SET disabled=false;
+</screen>
+      For SQLite 3:
+      <screen>
+ALTER TABLE records ADD disabled BOOLEAN;
+UPDATE records SET disabled=0;
+</screen>
+      For Oracle:
+      <screen>
+ALTER TABLE records ADD disabled INT;
+UPDATE records SET disabled=0;
+</screen>
+    </para>
+  </sect1>
+
   </chapter>
   <chapter id="powerdnssec-auth">
   <title>Serving authoritative DNSSEC data</title>
@@ -17661,6 +17692,7 @@ authoritative).
              <row><entry>Autoserial</entry><entry>Yes (v3.1 and up)</entry></row>
              <row><entry>Case</entry><entry>All lower</entry></row>
              <row><entry>DNSSEC</entry><entry>Yes (set gmysql-dnssec or gpgsql-dnssec)</entry></row>
+             <row><entry>Disabled data</entry><entry>Yes (v3.4 and up)</entry></row>
              <row><entry>Module name &lt; 2.9.3</entry><entry>pgmysql</entry></row>
              <row><entry>Module name &gt; 2.9.2</entry><entry>gmysql and gpgsql</entry></row>
              <row><entry>Launch name</entry><entry>gmysql and gpgsql2 and gpgsql</entry></row>
@@ -17833,6 +17865,14 @@ insert into domains (id,name,type) values (domains_id_sequence.nextval,'example.
                </para>
              </listitem>
            </varlistentry>
+           <varlistentry>
+             <term>disabled</term>
+             <listitem>
+               <para>
+                 If set to true, this record is hidden from DNS clients, but can still be modified from the REST API. See <xref linkend="gsql-disableddata" />. (Available since version 3.4.)
+               </para>
+             </listitem>
+           </varlistentry>
          </variablelist>
          Please note that the names of the fields are not relevant, but the order is!
        </para>
@@ -18230,6 +18270,16 @@ insert into domains (id,name,type) values (domains_id_sequence.nextval,'example.
          Make sure that the assigned id in the domains table matches the domain_id field in the records table!
        </para>
       </sect2>
+      <sect2 id="gsql-disableddata"><title>Disabled data</title>
+        <para>
+          PowerDNS understands the notion of disabled records. They are marked by setting "disabled" to 1 (for PostgreSQL: true).
+          By extension, when the SOA record for a domain is disabled, the entire domain is considered to be disabled.
+        </para>
+        <para>
+          Effects: the record (or domain, respectively) will not be visible to DNS clients. The REST API will still see the record (or domain).
+          Even if a domain is disabled, slaving still works. Slaving considers a disabled domain to have a serial of 0; this implies that a slaved domain will not stay disabled.
+        </para>
+      </sect2>
     </sect1>
     
     <sect1 id="oracle"><title>Oracle backend</title>
@@ -22265,6 +22315,9 @@ static RandomLoader randomloader;
              <row>
                <entry>bool auth</entry><entry>Used for DNSSEC operations. See <xref linkend="powerdnssec-auth" /> and more specifically <xref linkend="dnssec-migration" />. It is also useful to check out the <function>rectifyZone()</function> in pdnssec.cc</entry>
              </row>
+             <row>
+               <entry>bool disabled</entry><entry>If set, this record is not to be served to DNS clients. Backends should not make these records available to PowerDNS unless indicated otherwise.</entry>
+             </row>
            </tbody>
          </tgroup>
        </table>
@@ -22345,11 +22398,12 @@ static RandomLoader randomloader;
            </varlistentry>
          
          <varlistentry>
-           <term>bool list(int domain_id)</term>
+           <term>bool list(int domain_id, bool include_disabled=false)</term>
            <listitem>
              <para>
                Initiates a list of the indicated domain. Records should then be made available via the <function>get()</function> method. 
                Need not include the SOA record. If it is, PDNS will not get confused.
+                If include_disabled is given as true, records that are configured but should not be served to DNS clients must also be made available.
              </para>
              <para>
                Should return false if the backend does not consider itself authoritative for this zone.
index de37bcf626ef48bdceedaacdd07c996c0574323a..b60cf2e3a269fd2dcd2c335d30122c99355dce63 100644 (file)
@@ -54,6 +54,16 @@ string stringFromJson(const Value& container, const char* key, const string& def
   }
 }
 
+bool boolFromJson(const rapidjson::Value& container, const char* key)
+{
+  const Value& val = container[key];
+  if (val.IsBool()) {
+    return val.GetBool();
+  } else {
+    throw JsonException("Key '" + string(key) + "' not present or not a Bool");
+  }
+}
+
 string makeStringFromDocument(const Document& doc)
 {
   StringBuffer output;
index 17021b850532776a315c20bd9ee5306b78358352..b79503938d77a8934cb0d4b5c51cc58ce03f1696 100644 (file)
@@ -33,6 +33,7 @@ int intFromJson(const rapidjson::Value& container, const char* key);
 int intFromJson(const rapidjson::Value& container, const char* key, const int default_value);
 std::string stringFromJson(const rapidjson::Value& container, const char* key);
 std::string stringFromJson(const rapidjson::Value& container, const char* key, const std::string& default_value);
+bool boolFromJson(const rapidjson::Value& container, const char* key);
 
 class JsonException : public std::runtime_error
 {
index 4206931638ffe596d0045a72ac0ff99b916c7976..603159444ead3d72bad6e1b1ba8753fc6329d7c7 100644 (file)
@@ -617,11 +617,11 @@ void UeberBackend::lookup(const QType &qtype,const string &qname, DNSPacket *pkt
   d_handle.parent=this;
 }
 
-void UeberBackend::getAllDomains(vector<DomainInfo> *domains) {
+void UeberBackend::getAllDomains(vector<DomainInfo> *domains, bool include_disabled) {
   check_op_requests();
   for (vector<DNSBackend*>::iterator i = backends.begin(); i != backends.end(); ++i )
   {
-    (*i)->getAllDomains(domains);
+    (*i)->getAllDomains(domains, include_disabled);
   }
 }
 
@@ -653,7 +653,7 @@ bool UeberBackend::get(DNSResourceRecord &rr)
   return true;
 }
 
-bool UeberBackend::list(const string &target, int domain_id)
+bool UeberBackend::list(const string &target, int domain_id, bool include_disabled)
 {
   L<<Logger::Error<<"UeberBackend::list called, should NEVER EVER HAPPEN"<<endl;
   exit(1);
index f3c086c38f4b57c2025144fd2892c67a2eafbd43..3b7b74183b9dc5a97d924881e4ffaa3e478c0bd6 100644 (file)
@@ -122,9 +122,9 @@ public:
 
   bool getAuth(DNSPacket *p, SOAData *sd, const string &target, int *zoneId);
   bool getSOA(const string &domain, SOAData &sd, DNSPacket *p=0);
-  bool list(const string &target, int domain_id);
+  bool list(const string &target, int domain_id, bool include_disabled=false);
   bool get(DNSResourceRecord &r);
-  void getAllDomains(vector<DomainInfo> *domains);
+  void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false);
 
   static DNSBackend *maker(const map<string,string> &);
   static void closeDynListener();
index 1db1a30f6319d4a808cde724d73282639ccb6f61..6935601533e853397f37770085388f820ac5537c 100644 (file)
@@ -302,7 +302,7 @@ static void fillZone(const string& zonename, HttpResponse* resp) {
   DNSResourceRecord rr;
   Value records;
   records.SetArray();
-  di.backend->list(zonename, di.id);
+  di.backend->list(zonename, di.id, true); // incl. disabled
   while(di.backend->get(rr)) {
     if (!rr.qtype.getCode())
       continue; // skip empty non-terminals
@@ -315,6 +315,7 @@ static void fillZone(const string& zonename, HttpResponse* resp) {
     object.AddMember("type", jtype, doc.GetAllocator());
     object.AddMember("ttl", rr.ttl, doc.GetAllocator());
     object.AddMember("priority", rr.priority, doc.GetAllocator());
+    object.AddMember("disabled", rr.disabled, doc.GetAllocator());
     Value jcontent(rr.content.c_str(), doc.GetAllocator()); // copy
     object.AddMember("content", jcontent, doc.GetAllocator());
     records.PushBack(object, doc.GetAllocator());
@@ -412,7 +413,7 @@ static void apiServerZones(HttpRequest* req, HttpResponse* resp) {
     throw HttpMethodNotAllowedException();
 
   vector<DomainInfo> domains;
-  B.getAllDomains(&domains);
+  B.getAllDomains(&domains, true); // incl. disabled
 
   Document doc;
   doc.SetArray();
@@ -500,11 +501,6 @@ static void apiServerZoneRRset(HttpRequest* req, HttpResponse* resp) {
   if(!B.getDomainInfo(zonename, di))
     throw ApiException("Could not find domain '"+zonename+"'");
 
-  SOAData sd;
-  sd.db = (DNSBackend*)-1;
-  if(!B.getSOA(zonename, sd) || !sd.db)
-    throw ApiException("Could not find domain '"+zonename+"'");
-
   Document document;
   req->json(document);
 
@@ -516,7 +512,7 @@ static void apiServerZoneRRset(HttpRequest* req, HttpResponse* resp) {
 
   if (changetype == "DELETE") {
     // delete all matching qname/qtype RRs
-    sd.db->replaceRRSet(sd.domain_id, qname, qtype, vector<DNSResourceRecord>());
+    di.backend->replaceRRSet(di.id, qname, qtype, vector<DNSResourceRecord>());
   }
   else if (changetype == "REPLACE") {
     DNSResourceRecord rr;
@@ -527,10 +523,11 @@ static void apiServerZoneRRset(HttpRequest* req, HttpResponse* resp) {
       rr.qname = stringFromJson(record, "name");
       rr.content = stringFromJson(record, "content");
       rr.qtype = stringFromJson(record, "type");
-      rr.domain_id = sd.domain_id;
+      rr.domain_id = di.id;
       rr.auth = 1;
       rr.ttl = intFromJson(record, "ttl");
       rr.priority = intFromJson(record, "priority");
+      rr.disabled = boolFromJson(record, "disabled");
 
       rrset.push_back(rr);
 
@@ -547,9 +544,9 @@ static void apiServerZoneRRset(HttpRequest* req, HttpResponse* resp) {
       }
     }
     // Actually store the change.
-    sd.db->startTransaction(qname);
-    sd.db->replaceRRSet(sd.domain_id, qname, qtype, rrset);
-    sd.db->commitTransaction();
+    di.backend->startTransaction(qname);
+    di.backend->replaceRRSet(di.id, qname, qtype, rrset);
+    di.backend->commitTransaction();
   }
   else
     throw ApiException("Changetype not understood");
index 3d554607123d43b4bad6ec2123e970d7b5155b4c..5bcf7fbfc4d8cd3f1e9f359987821e22728c444f 100644 (file)
@@ -166,50 +166,50 @@ static void emitRecord(const string& zoneName, const string &qname, const string
 
   if(g_mode==MYSQL || g_mode==SQLITE) {
     if(!g_doDNSSEC) {
-      cout<<"insert into records (domain_id, name,type,content,ttl,prio) select id ,"<<
+      cout<<"insert into records (domain_id, name, type,content,ttl,prio,disabled) select id ,"<<
         sqlstr(toLower(stripDot(qname)))<<", "<<
         sqlstr(qtype)<<", "<<
-        sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<< 
+        sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", 0"<<
         " from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
     } else
     {
-      cout<<"insert into records (domain_id, name, ordername, auth, type,content,ttl,prio) select id ,"<<
+      cout<<"insert into records (domain_id, name, ordername, auth, type,content,ttl,prio,disabled) select id ,"<<
         sqlstr(toLower(stripDot(qname)))<<", "<<
         sqlstr(toLower(labelReverse(makeRelative(stripDot(qname), zoneName))))<<", "<<auth<<", "<<
         sqlstr(qtype)<<", "<<
-        sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<< 
+        sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", 0"<<
         " from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
     }
   }
   else if(g_mode==POSTGRES) {
     if(!g_doDNSSEC) {
-      cout<<"insert into records (domain_id, name,type,content,ttl,prio) select id ,"<<
+      cout<<"insert into records (domain_id, name,type,content,ttl,prio,disabled) select id ,"<<
         sqlstr(toLower(stripDot(qname)))<<", "<<
         sqlstr(qtype)<<", "<<
-        sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<< 
+        sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", 'f'"<<
         " from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
     } else
     {
-      cout<<"insert into records (domain_id, name, ordername, auth, type,content,ttl,prio) select id ,"<<
+      cout<<"insert into records (domain_id, name, ordername, auth, type,content,ttl,prio,disabled) select id ,"<<
         sqlstr(toLower(stripDot(qname)))<<", "<<
         sqlstr(toLower(labelReverse(makeRelative(stripDot(qname), zoneName))))<<", '"<< (auth  ? 't' : 'f') <<"', "<<
         sqlstr(qtype)<<", "<<
-        sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<< 
+        sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", 'f'"<<
         " from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
     }
   }
   else if(g_mode==GORACLE) {
-    cout<<"insert into Records (id, domain_id, name, type, content, ttl, prio) select RECORDS_ID_SEQUENCE.nextval,id ,"<<
+    cout<<"insert into Records (id, domain_id, name, type, content, ttl, prio, disabled) select RECORDS_ID_SEQUENCE.nextval,id ,"<<
       sqlstr(toLower(stripDot(qname)))<<", "<<
       sqlstr(qtype)<<", "<<
-      sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<< 
+      sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", 0"
       " from Domains where name="<<toLower(sqlstr(zoneName))<<";\n";
   }
   else if(g_mode==ORACLE) {
-    cout<<"INSERT INTO Records (id, zone_id, fqdn, ttl, type, content) SELECT records_id_seq.nextval, id, "<<
+    cout<<"INSERT INTO Records (id, zone_id, fqdn, ttl, type, content, disabled) SELECT records_id_seq.nextval, id, "<<
       sqlstr(toLower(stripDot(qname)))<<", "<<
       ttl<<", "<<sqlstr(qtype)<<", "<<
-      sqlstr(stripDotContent(content))<<
+      sqlstr(stripDotContent(content))<<", 0"<<
       " FROM Zones WHERE name="<<toLower(sqlstr(zoneName))<<";"<<endl;
   }
   else if (g_mode == MYDNS) {
index a0b33efe614c5de57a192a2a9590ab6883f40c15..aa5a2a8b73e109537db7afe6b37a7cd250b16bbf 100644 (file)
@@ -108,7 +108,16 @@ class Servers(ApiTestCase):
                     "type": "NS",
                     "priority": 0,
                     "ttl": 3600,
-                    "content": "ns1.bar.com"
+                    "content": "ns1.bar.com",
+                    "disabled": False
+                },
+                {
+                    "name": name,
+                    "type": "NS",
+                    "priority": 0,
+                    "ttl": 1800,
+                    "content": "ns2-disabled.bar.com",
+                    "disabled": True
                 }
             ]
         }
@@ -148,3 +157,39 @@ class Servers(ApiTestCase):
         data = r.json()['records']
         recs = [rec for rec in data if rec['type'] == payload['type'] and rec['name'] == payload['name']]
         self.assertEquals(recs, [])
+
+    def test_ZoneDisableReenable(self):
+        payload, zone = self.create_zone()
+        name = payload['name']
+        # disable zone by disabling SOA
+        payload = {
+            'changetype': 'replace',
+            'name': name,
+            'type': 'SOA',
+            'records': [
+                {
+                    "name": name,
+                    "type": "SOA",
+                    "priority": 0,
+                    "ttl": 3600,
+                    "content": "ns1.bar.com hostmaster.foo.org 1 1 1 1 1",
+                    "disabled": True
+                }
+            ]
+        }
+        r = self.session.patch(
+            self.url("/servers/localhost/zones/" + name + "/rrset"),
+            data=json.dumps(payload),
+            headers={'content-type': 'application/json'})
+        self.assertSuccessJson(r)
+        # make sure it's still in zone list
+        r = self.session.get(self.url("/servers/localhost/zones"))
+        domains = r.json()
+        self.assertEquals(len([domain for domain in domains if domain['name'] == name]), 1)
+        # verify that modifying it still works
+        payload['records'][0]['disabled'] = False
+        r = self.session.patch(
+            self.url("/servers/localhost/zones/" + name + "/rrset"),
+            data=json.dumps(payload),
+            headers={'content-type': 'application/json'})
+        self.assertSuccessJson(r)