declare(suffix,"supermaster-query","", "select account from supermasters where ip='%s' and nameserver='%s'");
declare(suffix,"supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver='%s' and account='%s'");
- declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE','%s')");
+ declare(suffix,"insert-zone-query","", "insert into domains (type,name,account) values('NATIVE','%s','%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,disabled,name,auth) values ('%s',%d,%d,'%s',%d,%d,'%s','%d')");
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,"update-account-query","", "update domains set account='%s' where name='%s'");
declare(suffix,"update-serial-query","", "update domains set notified_serial=%d where id=%d");
declare(suffix,"update-lastcheck-query","", "update domains set last_check=%d where id=%d");
declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=%d");
declare(suffix,"supermaster-query","", "select account from supermasters where ip='%s' and nameserver=E'%s'");
declare(suffix,"supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=E'%s' and account=E'%s'");
- declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',E'%s')");
+ declare(suffix,"insert-zone-query","", "insert into domains (type,name,account) values('NATIVE',E'%s',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,disabled,name,auth) values (E'%s',%d,%d,'%s',%d,%d::bool,E'%s','%d')");
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,"update-account-query","", "update domains set account=E'%s' where name=E'%s'");
declare(suffix,"update-serial-query","", "update domains set notified_serial=%d where id=%d");
declare(suffix,"update-lastcheck-query","", "update domains set last_check=%d where id=%d");
declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=%d");
declare( suffix, "supermaster-query", "", "select account from supermasters where ip='%s' and nameserver='%s'");
declare( suffix, "supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver='%s' and account='%s'");
- declare( suffix, "insert-zone-query", "", "insert into domains (type,name) values('NATIVE','%s')");
+ declare( suffix, "insert-zone-query", "", "insert into domains (type,name,account) values('NATIVE','%s','%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,disabled,name,auth) values ('%s',%d,%d,'%s',%d,%d,'%s',%d)");
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, "update-account-query","", "update domains set account='%s' where name='%s'");
declare( suffix, "update-serial-query", "", "update domains set notified_serial=%d where id=%d");
declare( suffix, "update-lastcheck-query", "", "update domains set last_check=%d where id=%d");
declare (suffix, "zone-lastchange-query", "", "select max(change_date) from records where domain_id=%d");
return true;
}
+bool GSQLBackend::setAccount(const string &domain, const string &account)
+{
+ string query = (GSQLformat(d_UpdateAccountOfZoneQuery) % sqlEscape(account) % sqlEscape(toLower(domain))).str();
+
+ try {
+ d_db->doCommand(query);
+ }
+ 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_InsertEntQuery=getArg("insert-ent-query");
d_UpdateMasterOfZoneQuery=getArg("update-master-query");
d_UpdateKindOfZoneQuery=getArg("update-kind-query");
+ d_UpdateAccountOfZoneQuery=getArg("update-account-query");
d_UpdateSerialOfZoneQuery=getArg("update-serial-query");
d_UpdateLastCheckofZoneQuery=getArg("update-lastcheck-query");
d_ZoneLastChangeQuery=getArg("zone-lastchange-query");
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;
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 = [