declare(suffix,"supermaster-query","", "select account from supermasters where ip=? and nameserver=?");
declare(suffix,"supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=? and account=?");
- declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',?)");
+ declare(suffix,"insert-zone-query","", "insert into domains (type,name,account) values('NATIVE',?,?)");
declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',?,?,?)");
declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values (?,?,?,?,?,?,?,?)");
declare(suffix,"update-master-query","", "update domains set master=? where name=?");
declare(suffix,"update-kind-query","", "update domains set type=? where name=?");
+ declare(suffix,"update-account-query","", "update domains set account=? where name=?");
declare(suffix,"update-serial-query","", "update domains set notified_serial=? where id=?");
declare(suffix,"update-lastcheck-query","", "update domains set last_check=? where id=?");
declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=?");
declare(suffix,"supermaster-query","", "select account from supermasters where ip=$1 and nameserver=$2");
declare(suffix,"supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=$1 and account=$2");
- declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',$1)");
+ declare(suffix,"insert-zone-query","", "insert into domains (type,name,account) values('NATIVE',$1,$2)");
declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',$1,$2,$3)");
declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values ($1,$2,$3,$4,$5,$6,$7,$8)");
declare(suffix,"update-master-query","", "update domains set master=$1 where name=$2");
declare(suffix,"update-kind-query","", "update domains set type=$1 where name=$2");
+ declare(suffix,"update-account-query","", "update domains set account=$1 where name=$2");
declare(suffix,"update-serial-query","", "update domains set notified_serial=$1 where id=$2");
declare(suffix,"update-lastcheck-query","", "update domains set last_check=$1 where id=$2");
declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=$1");
declare(suffix, "supermaster-query", "", "select account from supermasters where ip=:ip and nameserver=:nameserver");
declare(suffix, "supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=:nameserver and account=:account");
- declare(suffix, "insert-zone-query", "", "insert into domains (type,name) values('NATIVE',:domain)");
+ declare(suffix, "insert-zone-query", "", "insert into domains (type,name,account) values('NATIVE',:domain,:account)");
declare(suffix, "insert-slave-query", "", "insert into domains (type,name,master,account) values('SLAVE',:domain,:masters,:account)");
declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values (:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:auth)");
declare(suffix, "update-master-query", "", "update domains set master=:master where name=:domain");
declare(suffix, "update-kind-query", "", "update domains set type=:kind where name=:domain");
+ declare(suffix, "update-account-query","", "update domains set account=:account where name=:domain");
declare(suffix, "update-serial-query", "", "update domains set notified_serial=:serial where id=:domain_id");
declare(suffix, "update-lastcheck-query", "", "update domains set last_check=:last_check where id=:domain_id");
declare(suffix, "zone-lastchange-query", "", "select max(change_date) from records where domain_id=:domain_id");
d_UpdateKindOfZoneQuery=getArg("update-kind-query");
d_UpdateSerialOfZoneQuery=getArg("update-serial-query");
d_UpdateLastCheckofZoneQuery=getArg("update-lastcheck-query");
+ d_UpdateAccountOfZoneQuery=getArg("update-account-query");
d_ZoneLastChangeQuery=getArg("zone-lastchange-query");
d_InfoOfAllMasterDomainsQuery=getArg("info-all-master-query");
d_DeleteDomainQuery=getArg("delete-domain-query");
d_UpdateKindOfZoneQuery_stmt = NULL;
d_UpdateSerialOfZoneQuery_stmt = NULL;
d_UpdateLastCheckofZoneQuery_stmt = NULL;
+ d_UpdateAccountOfZoneQuery_stmt = NULL;
d_InfoOfAllMasterDomainsQuery_stmt = NULL;
d_DeleteDomainQuery_stmt = NULL;
d_DeleteZoneQuery_stmt = NULL;
return true;
}
+bool GSQLBackend::setAccount(const string &domain, const string &account)
+{
+ try {
+ d_UpdateAccountOfZoneQuery_stmt->
+ bind("account", account)->
+ bind("domain", toLower(domain))->
+ execute()->
+ reset();
+ }
+ catch (SSqlException &e) {
+ throw PDNSException("GSQLBackend unable to set account of domain \""+domain+"\": "+e.txtReason());
+ }
+ return true;
+}
+
bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di)
{
/* fill DomainInfo from database info:
d_InfoOfAllSlaveDomainsQuery_stmt = d_db->prepare(d_InfoOfAllSlaveDomainsQuery, 0);
d_SuperMasterInfoQuery_stmt = d_db->prepare(d_SuperMasterInfoQuery, 2);
d_GetSuperMasterIPs_stmt = d_db->prepare(d_GetSuperMasterIPs, 2);
- d_InsertZoneQuery_stmt = d_db->prepare(d_InsertZoneQuery, 1);
+ d_InsertZoneQuery_stmt = d_db->prepare(d_InsertZoneQuery, 2);
d_InsertSlaveZoneQuery_stmt = d_db->prepare(d_InsertSlaveZoneQuery, 3);
d_InsertRecordQuery_stmt = d_db->prepare(d_InsertRecordQuery, 8);
d_InsertEntQuery_stmt = d_db->prepare(d_InsertEntQuery, 3);
d_InsertEntOrderQuery_stmt = d_db->prepare(d_InsertEntOrderQuery, 4);
d_UpdateMasterOfZoneQuery_stmt = d_db->prepare(d_UpdateMasterOfZoneQuery, 2);
d_UpdateKindOfZoneQuery_stmt = d_db->prepare(d_UpdateKindOfZoneQuery, 2);
+ d_UpdateAccountOfZoneQuery_stmt = d_db->prepare(d_UpdateAccountOfZoneQuery, 2);
d_UpdateSerialOfZoneQuery_stmt = d_db->prepare(d_UpdateSerialOfZoneQuery, 2);
d_UpdateLastCheckofZoneQuery_stmt = d_db->prepare(d_UpdateLastCheckofZoneQuery, 2);
d_InfoOfAllMasterDomainsQuery_stmt = d_db->prepare(d_InfoOfAllMasterDomainsQuery, 0);
release(&d_InsertEntOrderQuery_stmt);
release(&d_UpdateMasterOfZoneQuery_stmt);
release(&d_UpdateKindOfZoneQuery_stmt);
+ release(&d_UpdateAccountOfZoneQuery_stmt);
release(&d_UpdateSerialOfZoneQuery_stmt);
release(&d_UpdateLastCheckofZoneQuery_stmt);
release(&d_InfoOfAllMasterDomainsQuery_stmt);
void setNotified(uint32_t domain_id, uint32_t serial);
bool setMaster(const string &domain, const string &ip);
bool setKind(const string &domain, const DomainInfo::DomainKind kind);
+ bool setAccount(const string &domain, const string &account);
virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after);
bool updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& zonename, const std::string& qname, bool auth);
string d_InsertEntOrderQuery;
string d_UpdateMasterOfZoneQuery;
string d_UpdateKindOfZoneQuery;
+ string d_UpdateAccountOfZoneQuery;
string d_UpdateSerialOfZoneQuery;
string d_UpdateLastCheckofZoneQuery;
string d_InfoOfAllMasterDomainsQuery;
SSqlStatement* d_InsertEntOrderQuery_stmt;
SSqlStatement* d_UpdateMasterOfZoneQuery_stmt;
SSqlStatement* d_UpdateKindOfZoneQuery_stmt;
+ SSqlStatement* d_UpdateAccountOfZoneQuery_stmt;
SSqlStatement* d_UpdateSerialOfZoneQuery_stmt;
SSqlStatement* d_UpdateLastCheckofZoneQuery_stmt;
SSqlStatement* d_InfoOfAllMasterDomainsQuery_stmt;
return false;
}
+ //! Called when the Account of a domain should be changed
+ virtual bool setAccount(const string &domain, const string &account)
+ {
+ return false;
+ }
+
//! Can be called to seed the getArg() function with a prefix
void setArgPrefix(const string &prefix);
if (document["soa_edit"].IsString()) {
di.backend->setDomainMetadataOne(zonename, "SOA-EDIT", document["soa_edit"].GetString());
}
+ if (document["account"].IsString()) {
+ di.backend->setAccount(zonename, document["account"].GetString());
+ }
}
static void apiZoneCryptokeys(HttpRequest* req, HttpResponse* resp) {
self.assertGreater(soa_serial, payload['serial'])
self.assertEquals(soa_serial, data['serial'])
+ def test_create_zone_with_account(self):
+ # soa_edit_api wins over serial
+ payload, data = self.create_zone(account='anaccount', serial=10)
+ print data
+ for k in ('account', ):
+ self.assertIn(k, data)
+ if k in payload:
+ self.assertEquals(data[k], payload[k])
+
def test_create_zone_with_records(self):
name = unique_zone_name()
records = [