From 41e21cb8cfaf0323fa33bba3866921a48c031c44 Mon Sep 17 00:00:00 2001 From: Mattia Codato Date: Thu, 3 Aug 2023 14:05:23 +0200 Subject: [PATCH] Prevent calls to command API while the configuration is reloading. Fixes #9840 --- lib/remote/consolehandler.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/remote/consolehandler.cpp b/lib/remote/consolehandler.cpp index e81533ce0..f5a470a9a 100644 --- a/lib/remote/consolehandler.cpp +++ b/lib/remote/consolehandler.cpp @@ -1,5 +1,6 @@ /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ +#include "remote/configobjectslock.hpp" #include "remote/consolehandler.hpp" #include "remote/httputility.hpp" #include "remote/filterutility.hpp" @@ -88,6 +89,13 @@ bool ConsoleHandler::HandleRequest( bool sandboxed = HttpUtility::GetLastParameter(params, "sandboxed"); + ConfigObjectsSharedLock lock (std::try_to_lock); + + if (!lock) { + HttpUtility::SendJsonError(response, params, 503, "Icinga is reloading."); + return true; + } + if (methodName == "execute-script") return ExecuteScriptHelper(request, response, params, command, session, sandboxed); else if (methodName == "auto-complete-script")