[PATCH] core: fix race condition on flexible downtime commands when duration not set or zero

Michael Friedrich michael.friedrich at univie.ac.at
Wed Feb 9 18:17:42 CET 2011


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: 	michael.friedrich at univie.ac.at
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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-core-fix-race-condition-on-flexible-downtime-command.patch
Type: text/x-diff
Size: 1740 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20110209/aad6abf7/attachment.patch>
-------------- next part --------------
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list