reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to set master of domain '"+domain.toLogString()+"': "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to set master of domain '"+domain.toLogString()+"' to IP address " + ip + ": "+e.txtReason());
}
return true;
}
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to set kind of domain '"+domain.toLogString()+"': "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to set kind of domain '"+domain.toLogString()+"' to " + toUpper(DomainInfo::getKindString(kind)) + ": "+e.txtReason());
}
return true;
}
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to set account of domain '"+domain.toLogString()+"': "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to set account of domain '"+domain.toLogString()+"' to '" + account + "': "+e.txtReason());
}
return true;
}
reset();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend unable to retrieve information about a domain: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve information about domain '" + domain.toLogString() + "': "+e.txtReason());
}
int numanswers=d_result.size();
} catch (...) {
return false;
}
+ string type=d_result[0][5];
+ di.account=d_result[0][6];
+ di.kind = DomainInfo::stringToKind(type);
+
vector<string> masters;
stringtok(masters, d_result[0][2], " ,\t");
for(const auto& m : masters)
di.masters.emplace_back(m, 53);
di.last_check=pdns_stou(d_result[0][3]);
di.notified_serial = pdns_stou(d_result[0][4]);
- string type=d_result[0][5];
- di.account=d_result[0][6];
di.backend=this;
di.serial = 0;
}
}
- di.kind = DomainInfo::stringToKind(type);
-
return true;
}
}
vector<DomainInfo> allSlaves;
- int numanswers=d_result.size();
- for(int n=0;n<numanswers;++n) { // id,name,master,last_check
+
+ bool loggedAssertRowColumns = false;
+ for(const auto& row : d_result) { // id,name,master,last_check
DomainInfo sd;
- ASSERT_ROW_COLUMNS("info-all-slaves-query", d_result[n], 4);
- sd.id=pdns_stou(d_result[n][0]);
try {
- sd.zone= DNSName(d_result[n][1]);
- } catch (...) {
+ ASSERT_ROW_COLUMNS("info-all-slaves-query", row, 4);
+ } catch(const PDNSException &e) {
+ if (!loggedAssertRowColumns) {
+ g_log<<Logger::Warning<<e.reason<<endl;
+ }
+ loggedAssertRowColumns = true;
+ continue;
+ }
+
+ try {
+ sd.zone = DNSName(row[1]);
+ } catch(const std::runtime_error &e) {
+ g_log<<Logger::Warning<<"Domain name '"<<row[1]<<"' is not a valid DNS name: "<<e.what()<<endl;
+ continue;
+ }
+
+ try {
+ sd.id=pdns_stou(row[0]);
+ } catch (const std::exception &e) {
+ g_log<<Logger::Warning<<"Could not convert id ("<<row[0]<<") for domain '"<<sd.zone<<"' into an integer: "<<e.what()<<endl;
continue;
}
vector<string> masters;
- stringtok(masters, d_result[n][2], ", \t");
- for(const auto& m : masters)
- sd.masters.emplace_back(m, 53);
+ stringtok(masters, row[2], ", \t");
+ for(const auto& m : masters) {
+ try {
+ sd.masters.emplace_back(m, 53);
+ } catch(const PDNSException &e) {
+ g_log<<Logger::Warning<<"Could not parse master address ("<<m<<") for zone '"<<sd.zone<<"': "<<e.reason<<endl;
+ }
+ }
+ if (sd.masters.empty()) {
+ g_log<<Logger::Warning<<"No masters for slave zone '"<<sd.zone<<"' found in the database"<<endl;
+ continue;
+ }
+
+ try {
+ sd.last_check=pdns_stou(row[3]);
+ } catch (const std::exception &e) {
+ g_log<<Logger::Warning<<"Could not convert last_check ("<<row[3]<<") for domain '"<<sd.zone<<"' into an integer: "<<e.what()<<endl;
+ continue;
+ }
- sd.last_check=pdns_stou(d_result[n][3]);
sd.backend=this;
sd.kind=DomainInfo::Slave;
allSlaves.push_back(sd);
}
- for(vector<DomainInfo>::iterator i=allSlaves.begin();i!=allSlaves.end();++i) {
- SOAData sdata;
- sdata.serial=0;
- sdata.refresh=0;
- getSOA(i->zone,sdata);
- if((time_t)(i->last_check+sdata.refresh) < time(0)) {
- i->serial=sdata.serial;
- unfreshDomains->push_back(*i);
+ for (auto& slave : allSlaves) {
+ try {
+ SOAData sdata;
+ sdata.serial=0;
+ sdata.refresh=0;
+ getSOA(slave.zone, sdata);
+ if(static_cast<time_t>(slave.last_check + sdata.refresh) < time(nullptr)) {
+ slave.serial=sdata.serial;
+ unfreshDomains->push_back(slave);
+ }
+ }
+ catch(const std::exception& exp) {
+ g_log<<Logger::Warning<<"Error while parsing SOA data for slave zone '"<<slave.zone.toLogString()<<"': "<<exp.what()<<endl;
+ continue;
+ }
+ catch(...) {
+ g_log<<Logger::Warning<<"Error while parsing SOA data for slave zone '"<<slave.zone.toLogString()<<"', skipping"<<endl;
+ continue;
}
}
}
reset();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend unable to update ordername and auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to update ordername and auth for " + qname.toLogString() + " for domain_id "+itoa(domain_id)+", domain name '" + qname.toLogString() + "': "+e.txtReason());
}
} else {
try {
reset();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend unable to update ordername and auth per type for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to update ordername and auth for " + qname.toLogString() + "|" + QType(qtype).getName() + " for domain_id "+itoa(domain_id)+": "+e.txtReason());
}
}
} else {
reset();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend unable to nullify ordername and update auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to nullify ordername and update auth for " + qname.toLogString() + " for domain_id "+itoa(domain_id)+": "+e.txtReason());
}
} else {
try {
reset();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend unable to nullify ordername and update auth per type for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to nullify ordername and update auth for " + qname.toLogString() + "|" + QType(qtype).getName() + " for domain_id "+itoa(domain_id)+": "+e.txtReason());
}
}
}
d_afterOrderQuery_stmt->reset();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend unable to find before/after (after) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (after) for domain_id "+itoa(id)+" and qname '"+ qname.toLogString() +"': "+e.txtReason());
}
if(after.empty()) {
d_firstOrderQuery_stmt->reset();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend unable to find before/after (first) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (first) for domain_id "+itoa(id)+" and qname '"+ qname.toLogString() + "': "+e.txtReason());
}
}
d_beforeOrderQuery_stmt->reset();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend unable to find before/after (before) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (before) for domain_id "+itoa(id)+" and qname '"+ qname.toLogString() + ": "+e.txtReason());
}
if(! unhashed.empty())
d_lastOrderQuery_stmt->reset();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend unable to find before/after (last) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (last) for domain_id "+itoa(id)+" and qname '"+ qname.toLogString() + ": "+e.txtReason());
}
} else {
before=qname;
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to store key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to store key for domain '"+ name.toLogString() + "': "+e.txtReason());
}
try {
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to activate key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to activate key with id "+ std::to_string(id) + " for domain '" + name.toLogString() + "': "+e.txtReason());
}
return true;
}
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to deactivate key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to deactivate key with id "+ std::to_string(id) + " for domain '" + name.toLogString() + "': "+e.txtReason());
}
return true;
}
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to remove key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to remove key with id "+ std::to_string(id) + " for domain '" + name.toLogString() + "': "+e.txtReason());
}
return true;
}
d_getTSIGKeyQuery_stmt->reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to retrieve named TSIG key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve TSIG key with name '" + name.toLogString() + "': "+e.txtReason());
}
return !content->empty();
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to store named TSIG key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to store TSIG key with name '" + name.toLogString() + "' and algorithm '" + algorithm.toString() + "': "+e.txtReason());
}
return true;
}
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to store named TSIG key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to delete TSIG key with name '" + name.toLogString() + "': "+e.txtReason());
}
return true;
}
d_GetAllDomainMetadataQuery_stmt->nextRow(row);
ASSERT_ROW_COLUMNS("get-all-domain-metadata-query", row, 2);
- if (!isDnssecDomainMetadata(row[0]))
+ if (d_dnssecQueries || !isDnssecDomainMetadata(row[0]))
meta[row[0]].push_back(row[1]);
}
d_GetAllDomainMetadataQuery_stmt->reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to list metadata: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to list metadata for domain '" + name.toLogString() + "': "+e.txtReason());
}
return true;
d_GetDomainMetadataQuery_stmt->reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to list metadata: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to get metadata kind '" + kind + "' for domain '" + name.toLogString() + "': "+e.txtReason());
}
return true;
}
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to store metadata key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to set metadata kind '" + kind + "' for domain '" + name.toLogString() + "': "+e.txtReason());
}
return true;
execute();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend lookup query:"+e.txtReason());
+ throw PDNSException("GSQLBackend unable to lookup '" + qname.toLogString() + "|" + qtype.getName() + "':"+e.txtReason());
}
d_qname=qname;
execute();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend list query: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to list domain '" + target.toLogString() + "': "+e.txtReason());
}
d_qname.clear();
execute();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend listSubZone query: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to list SubZones for domain '" + zone.toLogString() + "': "+e.txtReason());
}
d_qname.clear();
return true;
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to search for a domain: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to search for a supermaster with IP " + ip + " and nameserver name '" + i->content + "' for domain '" + domain.toLogString() + "': "+e.txtReason());
}
if(!d_result.empty()) {
ASSERT_ROW_COLUMNS("supermaster-query", d_result[0], 1);
} catch (...) {
continue;
}
+
+ if (pdns_iequals(row[3], "MASTER")) {
+ di.kind = DomainInfo::Master;
+ } else if (pdns_iequals(row[3], "SLAVE")) {
+ di.kind = DomainInfo::Slave;
+ } else if (pdns_iequals(row[3], "NATIVE")) {
+ di.kind = DomainInfo::Native;
+ } else {
+ g_log<<Logger::Warning<<"Could not parse domain kind '"<<row[3]<<"' as one of 'MASTER', 'SLAVE' or 'NATIVE'. Setting zone kind to 'NATIVE'"<<endl;
+ di.kind = DomainInfo::Native;
+ }
if (!row[4].empty()) {
vector<string> masters;
stringtok(masters, row[4], " ,\t");
- for(const auto& m : masters)
- di.masters.emplace_back(m, 53);
+ for(const auto& m : masters) {
+ try {
+ di.masters.emplace_back(m, 53);
+ } catch(const PDNSException &e) {
+ g_log<<Logger::Warning<<"Could not parse master address ("<<m<<") for zone '"<<di.zone<<"': "<<e.reason;
+ }
+ }
}
SOAData sd;
di.last_check = pdns_stou(row[6]);
di.account = row[7];
- if (pdns_iequals(row[3], "MASTER"))
- di.kind = DomainInfo::Master;
- else if (pdns_iequals(row[3], "SLAVE"))
- di.kind = DomainInfo::Slave;
- else
- di.kind = DomainInfo::Native;
-
di.backend = this;
domains->push_back(di);
}
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to delete RRSet: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to delete RRSet " + qname.toLogString() + "|" + qt.getName() + ": "+e.txtReason());
}
if (rrset.empty()) {
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to delete comment: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to delete comment for RRSet " + qname.toLogString() + "|" + qt.getName() + ": "+e.txtReason());
}
}
for(const auto& rr: rrset) {
return true;
}
-bool GSQLBackend::feedRecord(const DNSResourceRecord &r, const DNSName &ordername)
+bool GSQLBackend::feedRecord(const DNSResourceRecord &r, const DNSName &ordername, bool ordernameIsNSEC3)
{
int prio=0;
string content(r.content);
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to feed record: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to feed record " + r.qname.toLogString() + "|" + r.qtype.getName() + ": "+e.txtReason());
}
return true; // XXX FIXME this API should not return 'true' I think -ahu
}
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to feed empty non-terminal with name '" + nt.first.toLogString() + "': "+e.txtReason());
}
}
return true;
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to feed empty non-terminal with name '" + nt.first.toLogString() + "' (hashed name '"+ toBase32Hex(hashQNameWithSalt(ns3prc, nt.first)) + "') : "+e.txtReason());
}
}
return true;
}
catch (SSqlException &e) {
d_inTransaction = false;
- throw PDNSException("Database failed to start transaction: "+e.txtReason());
+ throw PDNSException("Database failed to start transaction for domain '" + domain.toLogString() + "': "+e.txtReason());
}
return true;
execute();
}
catch(SSqlException &e) {
- throw PDNSException("GSQLBackend list comments query: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to list comments for domain id " + std::to_string(domain_id) + ": "+e.txtReason());
}
return true;
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to feed comment: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to feed comment for RRSet '" + comment.qname.toLogString() + "|" + comment.qtype.getName() + "': "+e.txtReason());
}
}
reset();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to delete comment: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to delete comment for RRSet '" + qname.toLogString() + "|" + qt.getName() + "': "+e.txtReason());
}
for(const auto& comment: comments) {
return out.str();
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to execute query: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to execute direct command query '" + query + "': "+e.txtReason());
}
}
bool GSQLBackend::searchRecords(const string &pattern, int maxResults, vector<DNSResourceRecord>& result)
{
d_qname.clear();
+ string escaped_pattern = pattern2SQLPattern(pattern);
try {
- string escaped_pattern = pattern2SQLPattern(pattern);
-
reconnectIfNeeded();
d_SearchRecordsQuery_stmt->
return true;
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to execute query: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to search for records with pattern '" + pattern + "' (escaped pattern '" + escaped_pattern + "'): "+e.txtReason());
}
return false;
bool GSQLBackend::searchComments(const string &pattern, int maxResults, vector<Comment>& result)
{
Comment c;
+ string escaped_pattern = pattern2SQLPattern(pattern);
try {
- string escaped_pattern = pattern2SQLPattern(pattern);
-
reconnectIfNeeded();
d_SearchCommentsQuery_stmt->
result.push_back(comment);
}
- d_SearchRecordsQuery_stmt->reset();
+ d_SearchCommentsQuery_stmt->reset();
return true;
}
catch (SSqlException &e) {
- throw PDNSException("GSQLBackend unable to execute query: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to search for comments with pattern '" + pattern + "' (escaped pattern '" + escaped_pattern + "'): "+e.txtReason());
}
return false;