}
}
-void Bind2Backend::getAllDomains(vector<DomainInfo> *domains) {
+void Bind2Backend::getAllDomains(vector<DomainInfo> *domains, bool include_disabled) {
SOAData soadata;
shared_ptr<State> state = getState();
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))
// 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;
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);
~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);
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'");
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'");
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="")
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
+ disabled INT DEFAULT NULL,
primary key(id)
) Engine=InnoDB;
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)
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'");
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'");
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="") {
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'");
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'");
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="")
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,
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'");
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'");
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.
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);
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.
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;
}
}
-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;
~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*);
-bool OdbxBackend::list( const string& target, int zoneid )
+bool OdbxBackend::list( const string& target, int zoneid, bool include_disabled )
{
try
{
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 );
}
bool
-OracleBackend::list (const string &domain, int zoneId)
+OracleBackend::list (const string &domain, int zoneId, bool include_disabled)
{
sword rc;
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;
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();
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
}
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;
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);
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;
}
}
-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"));
// 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);
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();
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());
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;
}
% r.priority
% sqlEscape(r.qtype.getName())
% r.domain_id
+ % (int)r.disabled
% toLower(sqlEscape(r.qname))
% sqlEscape(*ordername)
% (int)r.auth
% r.priority
% sqlEscape(r.qtype.getName())
% r.domain_id
+ % (int)r.disabled
% toLower(sqlEscape(r.qname))
% (int)r.auth
).str();
% r.priority
% sqlEscape(r.qtype.getName())
% r.domain_id
+ % (int)r.disabled
% toLower(sqlEscape(r.qname))
).str();
}
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);
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(){};
Place d_place; //!< This specifies where a record goes within the packet
bool auth;
+ bool disabled;
uint8_t scopeMask;
template<class Archive>
ar & last_modified;
ar & d_place;
ar & auth;
+ ar & disabled;
}
bool operator==(const DNSResourceRecord& rhs);
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(){};
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);
DNSResourceRecord::DNSResourceRecord(const DNSRecord &p) {
auth=true;
+ disabled=false;
qname = p.d_label;
if(!qname.empty())
boost::erase_tail(qname, 1); // strip .
</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>
<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 < 2.9.3</entry><entry>pgmysql</entry></row>
<row><entry>Module name > 2.9.2</entry><entry>gmysql and gpgsql</entry></row>
<row><entry>Launch name</entry><entry>gmysql and gpgsql2 and gpgsql</entry></row>
</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>
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>
<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>
</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.
}
}
+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;
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
{
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);
}
}
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);
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();
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
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());
throw HttpMethodNotAllowedException();
vector<DomainInfo> domains;
- B.getAllDomains(&domains);
+ B.getAllDomains(&domains, true); // incl. disabled
Document doc;
doc.SetArray();
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);
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;
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);
}
}
// 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");
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) {
"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
}
]
}
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)