[icinga-checkins] icinga.org: icinga-core/r1.3: 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 13:56:26 CET 2011

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

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 b5dedc3..3ec08a8 100644
--- a/Changelog
+++ b/Changelog
@@ -73,6 +73,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 d7cdda0..db9c2f5 100644
--- a/THANKS
+++ b/THANKS
@@ -132,6 +132,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 944265a..b890a8f 100644
--- a/base/commands.c
+++ b/base/commands.c
@@ -2528,6 +2528,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