From 310278344c518fa35f48d7134f6649f6d4dab69d Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 20 Jan 2015 13:18:40 +0100 Subject: [PATCH] Make sure we don't include zones.d directories for zones which were removed fixes #8256 --- lib/cli/daemoncommand.cpp | 2 +- lib/remote/apilistener-sync.cpp | 14 +++++++++++--- lib/remote/apilistener.hpp | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/cli/daemoncommand.cpp b/lib/cli/daemoncommand.cpp index 55d147683..11401e8db 100644 --- a/lib/cli/daemoncommand.cpp +++ b/lib/cli/daemoncommand.cpp @@ -90,7 +90,7 @@ static void IncludeNonLocalZone(const String& zonePath) { String etcPath = Application::GetZonesDir() + "/" + Utility::BaseName(zonePath); - if (Utility::PathExists(etcPath)) + if (Utility::PathExists(etcPath) || Utility::PathExists(zonePath + "/.authoritative")) return; IncludeZoneDirRecursive(zonePath); diff --git a/lib/remote/apilistener-sync.cpp b/lib/remote/apilistener-sync.cpp index 8d019fc4a..aba5f48a7 100644 --- a/lib/remote/apilistener-sync.cpp +++ b/lib/remote/apilistener-sync.cpp @@ -58,7 +58,7 @@ Dictionary::Ptr ApiListener::LoadConfigDir(const String& dir) return config; } -bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictionary::Ptr& newConfig, const String& configDir) +bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictionary::Ptr& newConfig, const String& configDir, bool authoritative) { bool configChange = false; @@ -103,6 +103,14 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio fp.close(); } + if (authoritative) { + String authPath = configDir + "/.authoritative"; + if (!Utility::PathExists(tsPath)) { + std::ofstream fp(tsPath.CStr(), std::ofstream::out | std::ostream::trunc); + fp.close(); + } + } + return configChange; } @@ -127,7 +135,7 @@ void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const Dictionary::Ptr newConfig = LoadConfigDir(newDir); Dictionary::Ptr oldConfig = LoadConfigDir(oldDir); - UpdateConfigDir(oldConfig, newConfig, oldDir); + UpdateConfigDir(oldConfig, newConfig, oldDir, true); } void ApiListener::SyncZoneDirs(void) const @@ -239,7 +247,7 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin& origin, const Dictio Dictionary::Ptr newConfig = kv.second; Dictionary::Ptr oldConfig = LoadConfigDir(oldDir); - if (UpdateConfigDir(oldConfig, newConfig, oldDir)) + if (UpdateConfigDir(oldConfig, newConfig, oldDir, false)) configChange = true; } diff --git a/lib/remote/apilistener.hpp b/lib/remote/apilistener.hpp index ed303cb53..23561c354 100644 --- a/lib/remote/apilistener.hpp +++ b/lib/remote/apilistener.hpp @@ -103,7 +103,7 @@ private: void ReplayLog(const ApiClient::Ptr& client); static Dictionary::Ptr LoadConfigDir(const String& dir); - static bool UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictionary::Ptr& newConfig, const String& configDir); + static bool UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictionary::Ptr& newConfig, const String& configDir, bool authoritative); void SyncZoneDirs(void) const; void SyncZoneDir(const Zone::Ptr& zone) const; -- 2.40.0