Skip to content

Commit

Permalink
Prevent calls to command API while the configuration is reloading.
Browse files Browse the repository at this point in the history
Fixes #9840
  • Loading branch information
Mattia Codato committed Aug 9, 2023
1 parent 7ae91ce commit 41e21cb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/remote/consolehandler.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 41e21cb

Please sign in to comment.