mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
Properly handle service downtime referencing a deleted host
Only two out of three cases were handled properly by the code: host downtimes referencing a deleted host and service downtimes referencing a deleted service worked fine. However, if a service downtime references a deleted host, `Host::GetByName()` returns `nullptr` which isn't accounted for. Use `Service::GetByNamePair()` instead as this performs a check for the host being null internally.
This commit is contained in:
parent
c6cf9c6279
commit
5b5efab847
@ -75,12 +75,10 @@ void Downtime::OnAllConfigLoaded()
|
|||||||
{
|
{
|
||||||
ObjectImpl<Downtime>::OnAllConfigLoaded();
|
ObjectImpl<Downtime>::OnAllConfigLoaded();
|
||||||
|
|
||||||
Host::Ptr host = Host::GetByName(GetHostName());
|
|
||||||
|
|
||||||
if (GetServiceName().IsEmpty())
|
if (GetServiceName().IsEmpty())
|
||||||
m_Checkable = host;
|
m_Checkable = Host::GetByName(GetHostName());
|
||||||
else
|
else
|
||||||
m_Checkable = host->GetServiceByShortName(GetServiceName());
|
m_Checkable = Service::GetByNamePair(GetHostName(), GetServiceName());
|
||||||
|
|
||||||
if (!m_Checkable)
|
if (!m_Checkable)
|
||||||
BOOST_THROW_EXCEPTION(ScriptError("Downtime '" + GetName() + "' references a host/service which doesn't exist.", GetDebugInfo()));
|
BOOST_THROW_EXCEPTION(ScriptError("Downtime '" + GetName() + "' references a host/service which doesn't exist.", GetDebugInfo()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user