event_handler pipe fd inheritation

Bastian Friedrich bf+develop.nagios-dev at collax.com
Fri Feb 27 12:26:49 CET 2009


Hi,

we are using a mechanism in our event_handlers that shall try to restart 
broken local services; eventually, normal init scripts (/etc/init.d/...) are 
started, which in turn start arbitrary daemons (say, mysql).

nagios creates a pipe to its event_handlers (and possibly other executables) 
in base/util.c for parent/child communication. The file descriptor to this 
pipe is (currently) not given the FD_CLOEXEC. This results in this fd being 
inherited by the event_handler (started by "popen()"), and, in our case, by 
the daemon (say, mysql). (The pipe is, e.g., visible in /proc/<whatever>/fd). 
As our daemons do not tend to close arbitrary fd's, this fd is never closed 
from the event_handler. As nagios waits for the file to be closed to continue 
its work, this results in a "denial of service" for the time that the daemon 
runs.

The pipe fd should be set the FD_CLOEXEC flag; it is then not inherited by the 
event_handler.

Patch attached.

Best regards
   Bastian

-- 
Collax GmbH . Burkheimer Straße 3 . 79111 Freiburg . Germany
p: +49 (0) 761-45684-28
f: +49 (0) 761-45684-10        www.collax.com

Geschäftsführer: Boris Nalbach
AG München HRB 158898 . Ust.-IdNr: DE 814464942
\ "I am two fools, I know, for loving, and for saying so."
\          John Donne
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cloexec-pipe-in-event_handler.patch
Type: text/x-diff
Size: 528 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20090227/30284d02/attachment.patch>
-------------- next part --------------
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
-------------- 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