[icinga-checkins] icinga.org: icinga-core/r1.2: core: fix race condition on flexible downtime commands when duration not set or zero #1061

git at icinga.org git at icinga.org
Wed Jan 26 14:01:57 CET 2011

Module: icinga-core
Branch: r1.2
Commit: bf2a1380b478e3f1f202ff007204b47b0c737867
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=bf2a1380b478e3f1f202ff007204b47b0c737867

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed Jan 26 12:52:34 2011 +0100

core: fix race condition on flexible downtime commands when duration not set or zero #1061

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.

thanks to Daniel Heule for reporting the issue and testing
my proposed fix ok.

fixes #1061


 Changelog       |    1 +
 THANKS          |    1 +
 base/commands.c |   10 ++++++++++
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/Changelog b/Changelog
index 3aa8f45..67aa705 100644
--- a/Changelog
+++ b/Changelog
@@ -30,6 +30,7 @@ FIXES
 * core: fix bug with passive host checks being incorrectly sent to event brokers as active checks (Ethan Galstad) #1133
 * core: fix bug where passive host check status updates were not being propagated to event brokers (Ethan Galstad) #1134
 * core: fix first_notification_delay logic (GalaxyMaster) #1145
+* core: fix race condition on flexible downtime commands when duration not set or zero #1061
 * classic ui: change servicestatus letter color to default black, not grey #946
 * classic ui: fix waste of cpu in status summary (TomTom) #933
diff --git a/THANKS b/THANKS
index a38552d..a43cb88 100644
--- a/THANKS
+++ b/THANKS
@@ -130,6 +130,7 @@ in various ways.  If we missed your name, let us know.
 * Karl Hegbloom
 * Thomas Hepper
 * Bret Hermsen
+* Daniel Heule
 * Marcus Hildenbrand
 * Arne Hinrichsen
 * Ronald Ho
diff --git a/base/commands.c b/base/commands.c
index 64ed286..e300772 100644
--- a/base/commands.c
+++ b/base/commands.c
@@ -2527,6 +2527,16 @@ int cmd_schedule_downtime(int cmd, time_t entry_time, char *args){
 		return ERROR;
+	/* MF 26-01-2011: 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. 	   */
+	if(fixed==0 && duration==0)
+		return ERROR;
 	/* duration should be auto-calculated, not user-specified */
 		duration=(unsigned long)(end_time-start_time);

More information about the icinga-checkins mailing list