ofconf << "# Generated by pdns-recursor REST API, DO NOT EDIT" << endl;
ofconf << yaml << endl;
ofconf.close();
+ if (ofconf.bad()) {
+ log->error(Logr::Error, "Error writing YAML", "to", Logging::Loggable(tmpfilename));
+ unlink(tmpfilename.c_str());
+ throw runtime_error("YAML Conversion");
+ }
if (rename(path.c_str(), (path + ".converted").c_str()) != 0) {
int err = errno;
log->error(Logr::Error, err, "Rename failed", "file", Logging::Loggable(path), "to", Logging::Loggable(path + ".converted"));
throw runtime_error("YAML Conversion");
}
}
- ofconf.close();
ifconf.close();
+ ofconf.close();
+ if (ofconf.bad()) {
+ log->error(Logr::Error, "Error writing YAML", "to", Logging::Loggable(dst));
+ throw runtime_error("YAML Conversion");
+ }
}
+
static void possiblyConvertForwardsandAuths(const std::string& includeDir, const std::string& apiDir, Logr::log_t log)
{
std::vector<std::string> forwAndAuthFiles{};