return false;
}
-bool DNSSECKeeper::rectifyZone(const DNSName& zone, string& error) {
+/* Rectifies the zone
+ *
+ * \param zone The zone to rectify
+ * \param error& A string where error messages are added
+ * \param doTransaction Whether or not to wrap the rectify in a transaction
+ */
+bool DNSSECKeeper::rectifyZone(const DNSName& zone, string& error, bool doTransaction) {
if (isPresigned(zone)) {
error = "Rectify presigned zone '"+zone.toLogString()+"' is not allowed/necessary.";
return false;
}
}
- sd.db->startTransaction(zone, -1);
+ if (doTransaction)
+ sd.db->startTransaction(zone, -1);
bool realrr=true;
bool doent=true;
}
}
- sd.db->commitTransaction();
+ if (doTransaction)
+ sd.db->commitTransaction();
return true;
}
void getFromMeta(const DNSName& zname, const std::string& key, std::string& value);
void getSoaEdit(const DNSName& zname, std::string& value);
- bool rectifyZone(const DNSName& zone, std::string& error);
+ bool rectifyZone(const DNSName& zone, std::string& error, bool doTransaction);
private:
bool rectifyZone(DNSSECKeeper& dk, const DNSName& zone)
{
string error;
- bool ret = dk.rectifyZone(zone, error);
+ bool ret = dk.rectifyZone(zone, error, true);
if (!ret) {
cerr<<error<<endl;
}
di.backend->getDomainMetadataOne(zonename, "API-RECTIFY", api_rectify);
if (shouldRectify && dk.isSecuredZone(zonename) && !dk.isPresigned(zonename) && api_rectify == "1") {
string error_msg = "";
- if (!dk.rectifyZone(zonename, error_msg))
+ if (!dk.rectifyZone(zonename, error_msg, true))
throw ApiException("Failed to rectify '" + zonename.toString() + "' " + error_msg);
}
}
throw ApiException("Zone '" + zonename.toString() + "' is a slave zone, not rectifying.");
string error_msg = "";
- if (!dk.rectifyZone(zonename, error_msg))
+ if (!dk.rectifyZone(zonename, error_msg, true))
throw ApiException("Failed to rectify '" + zonename.toString() + "' " + error_msg);
resp->setSuccessResult("Rectified");
di.backend->getDomainMetadataOne(zonename, "API-RECTIFY", api_rectify);
if (dk.isSecuredZone(zonename) && !dk.isPresigned(zonename) && api_rectify == "1") {
string error_msg = "";
- if (!dk.rectifyZone(zonename, error_msg))
+ if (!dk.rectifyZone(zonename, error_msg, false))
throw ApiException("Failed to rectify '" + zonename.toString() + "' " + error_msg);
}