This is a multi-part message in MIME format.
--------------020801050304000806000408
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hi there,
I had this quite long on my todo list but since I am now into porting
patches from Icinga to Nagios, I'll give it a go on this bug. I haven't
seen that reported on the tracker, so please excuse not opening an issue
but providing the diff straight ahead.
Something on the story...
A little while ago, the Icinga-Web implementation had a bug which was
sending a flexible scheduled downtime with no duration set and/or zero
duration set. According to the docs, this is not allowed to happen and
should be treated as an error by base/commands.c when setting up the
scheduled downtime.
As a matter of fact the Icinga user who reported that, told me that the
core runs into a race condition, 'thinks in an endless loop' and does
nothing. That was a bit irritating on stepping through the real cause on
the duration.
Neverthelesse, it happened to be a simplified bug to fix: If the
duration is NULL, strtoul return 0, so duration will be 0 either way. On
entering the downtime, and then scheduling an event in the future
(flexible, so now+duration) it then fails heavily because the calculated
event_time is not in the future.
The calculation happens on time(NULL)+duration so if duration 0, it's an
event_time which never gets triggered as the end_time of the downtime. I
did not dive deeper into that logic because preventing the initial
command to set flexible downtime with zero duration is the ideal fix in
this situation.
Mainly the patch checks if fixed disabled and duration zero, returning
an error.
Check the issue for a bit more details - https://dev.icinga.org/issues/1061
This is sufficient for fixing the bug, although I don't have any test
cases but a motivated user testing GIT diffs I provided on his
productive system.
Kind regards,
Michael
--
DI (FH) Michael Friedrich
Vienna University Computer Center
Universitaetsstrasse 7 A-1010 Vienna, Austria
email: [email protected]
phone: +43 1 4277 14359
fax: +43 1 4277 14338
web: http://www.univie.ac.at/zid
http://www.aco.net
Icinga Core& IDOUtils Developer
http://www.icinga.org
--------------020801050304000806000408
Content-Type: text/x-diff;
name="0001-core-fix-race-condition-on-flexible-downtime-command.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="0001-core-fix-race-condition-on-flexible-downtime-command.pa";
filename*1="tch"
From 2d3146017d59211396b3a09716d938c9bece8fbe Mon Sep 17 00:00:00 2001
From: Michael Friedrich
Date: Wed, 9 Feb 2011 17:58:55 +0100
Subject: [PATCH] core: fix race condition on flexible downtime commands when duration not set or zero
it may happen that an external command sets a
flexible downtime with duration not set or zero.
a flexible downtime is triggered between start and
end time and needs a duration to be set and non zero.
without the fix, the scheduled downtime starts and then
tries to calculate the end time out of the set duration
for the downtime and scheduling a new event.
the time passed over there is in the past, and causes the
core to get into a loop.
to prevent this misbehavior, a duration of null or zero is
not allowed and triggered as error in base/commands.c not
setting any flexible downtime.
---
base/commands.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/base/commands.c b/base/commands.c
index 46e45e1..592ada4 100644
--- a/base/commands.c
+++ b/base/commands.c
@@ -2487,6 +2487,17 @@ int cmd_schedule_downtime(int cmd, time_t entry_time, char *args){
if((comment_data=my_strtok(NULL,";"))==NULL)
return ERROR;
+ /* check if flexible downtime demanded and duration set
+ to non-zero.
+ according to the documentation, a flexible downtime is
+ started between start and end time and will last for
+ "duration" seconds. strtoul converts a NULL value to 0
+ so if set to 0, bail out as a duration>0 is needed. */
+
+ i
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]