From: Peter van Dijk Date: Thu, 11 Oct 2012 13:46:07 +0000 (+0000) Subject: make sure SSqlException does not escape from gsqlbackend X-Git-Tag: auth-3.2-rc1~79 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb6dd39e21eefef96eb34efd94ffa6a16454995d;p=thirdparty%2Fpdns.git make sure SSqlException does not escape from gsqlbackend git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2803 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 2ea3820a8c..bf826f464b 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -327,7 +327,12 @@ bool GSQLBackend::updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std snprintf(output, sizeof(output)-1, d_setOrderAuthQuery.c_str(), sqlEscape(ordername).c_str(), auth, sqlEscape(qname).c_str(), domain_id); // cerr<<"sql: '"<doCommand(output); + try { + d_db->doCommand(output); + } + catch(SSqlException &e) { + throw AhuException("GSQLBackend unable to update ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason()); + } return true; } @@ -338,7 +343,12 @@ bool GSQLBackend::nullifyDNSSECOrderName(uint32_t domain_id, const std::string& char output[1024]; snprintf(output, sizeof(output)-1, d_nullifyOrderNameQuery.c_str(), domain_id, sqlEscape(qname).c_str()); - d_db->doCommand(output); + try { + d_db->doCommand(output); + } + catch(SSqlException &e) { + throw AhuException("GSQLBackend unable to nullify ordername for domain_id "+itoa(domain_id)+": "+e.txtReason()); + } return true; } @@ -349,7 +359,12 @@ bool GSQLBackend::nullifyDNSSECOrderNameAndAuth(uint32_t domain_id, const std::s char output[1024]; snprintf(output, sizeof(output)-1, d_nullifyOrderNameAndAuthQuery.c_str(), sqlEscape(qname).c_str(), sqlEscape(type).c_str(), domain_id); - d_db->doCommand(output); + try { + d_db->doCommand(output); + } + catch(SSqlException &e) { + throw AhuException("GSQLBackend unable to nullify ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason()); + } return true; } @@ -414,7 +429,13 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& snprintf(output, sizeof(output)-1, d_afterOrderQuery.c_str(), sqlEscape(lcqname).c_str(), id); - d_db->doQuery(output); + try { + d_db->doQuery(output); + } + catch(SSqlException &e) { + throw AhuException("GSQLBackend unable to find before/after (after) for domain_id "+itoa(id)+": "+e.txtReason()); + } + while(d_db->getRow(row)) { after=row[0]; } @@ -422,14 +443,24 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& if(after.empty() && !lcqname.empty()) { snprintf(output, sizeof(output)-1, d_firstOrderQuery.c_str(), id); - d_db->doQuery(output); + try { + d_db->doQuery(output); + } + catch(SSqlException &e) { + throw AhuException("GSQLBackend unable to find before/after (first) for domain_id "+itoa(id)+": "+e.txtReason()); + } while(d_db->getRow(row)) { after=row[0]; } } snprintf(output, sizeof(output)-1, d_beforeOrderQuery.c_str(), sqlEscape(lcqname).c_str(), id); - d_db->doQuery(output); + try { + d_db->doQuery(output); + } + catch(SSqlException &e) { + throw AhuException("GSQLBackend unable to find before/after (before) for domain_id "+itoa(id)+": "+e.txtReason()); + } while(d_db->getRow(row)) { before=row[0]; unhashed=row[1]; @@ -442,7 +473,12 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& } snprintf(output, sizeof(output)-1, d_lastOrderQuery.c_str(), id); - d_db->doQuery(output); + try { + d_db->doQuery(output); + } + catch(SSqlException &e) { + throw AhuException("GSQLBackend unable to find before/after (last) for domain_id "+itoa(id)+": "+e.txtReason()); + } while(d_db->getRow(row)) { before=row[0]; unhashed=row[1]; @@ -836,7 +872,7 @@ bool GSQLBackend::feedRecord(const DNSResourceRecord &r) d_db->doCommand(output.c_str()); } catch (SSqlException &e) { - throw AhuException(e.txtReason()); + throw AhuException("GSQLBackend unable to feed record: "+e.txtReason()); } return true; // XXX FIXME this API should not return 'true' I think -ahu }