[Nagios-devel] Race condition w/nagios.cmd

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Race condition w/nagios.cmd

Post by Guest »

This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to [email protected] for more info.

--2093892754-1920379050-1074899792=:28423
Content-Type: TEXT/PLAIN; charset=US-ASCII

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

There is a race condition regarding the external command fifo when Nagios
is shutting down. This is especially evident when using nsca in inetd
mode. The problem is that the reading end of the fifo closes prior to the
fifo file being removed. This means that on a busy system many nsca
processes will attempt to open the fifo in between the closing of the pipe
and the removal of the fifo. Those nsca processes will forever be blocked
on the open() of that fifo until they are manually killed.

The fix to this is to unlink the fifo file prior to closing the
reading end of the pipe. I've attached a patch to utils.c (from
nagios-1.1) that reverses the order of the close and unlink to effect
this.

Also, is there a particular reason the nagios.cmd file is removed
/ recreated at launch? I'd think it would prevent some problems to have it
check if an equivalent fifo (ie already has the necessary privs /
name / properties) already exists, plus remove an annoying
problem of failing to launch because that file exists from a previous
instance.

Thanks,
- -Jason Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.3.3 (GNU/Linux)
Comment: pgpenvelope 2.10.2 - http://pgpenvelope.sourceforge.net/

iD8DBQFAEatZl2ODWuqVSBMRAuUAAJ4k9GMOpTYKPC8URHepOYShIyACfgCffkEL
UHMAxbJjETYBXBREgDJbFmg=
=l6Wy
-----END PGP SIGNATURE-----
--2093892754-1920379050-1074899792=:28423
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="utils.c-patch"
Content-Transfer-Encoding: BASE64
Content-ID:
Content-Description:
Content-Disposition: attachment; filename="utils.c-patch"

LS0tIHV0aWxzLmMJVHVlIE5vdiAxOCAxNjoyODoxMCAyMDAzDQorKysgdXRp
bHMxLmMJRnJpIEphbiAyMyAxNDo1Mjo1MCAyMDA0DQpAQCAtMjE2MiwxMyAr
MjE2MiwxNyBAQA0KIAlpZihjaGVja19leHRlcm5hbF9jb21tYW5kcz09RkFM
U0UpDQogCQlyZXR1cm4gT0s7DQogDQorCS8qIGRlbGV0ZSB0aGUgbmFtZWQg
cGlwZSBwcmlvciB0byBjbG9zaW5nICovDQorCS8qIHNpbmNlIHRoZXJlIGlz
IGEgcmFjZSBjb25kaXRpb24gb2YgcHJvY2Vzc2VzICovDQorCS8qIG9wZW5p
bmcgdGhlIHBpcGUgYWZ0ZXIgd2UgY2xvc2UgYW5kIGJlZm9yZSBpdCBpcyAq
Lw0KKwkvKiByZW1vdmVkICovDQorCWlmKHVubGluayhjb21tYW5kX2ZpbGUp
IT0wKQ0KKwkJcmV0dXJuIEVSUk9SOw0KKw0KIAkvKiBjbG9zZSB0aGUgY29t
bWFuZCBmaWxlICovDQogCWZjbG9zZShjb21tYW5kX2ZpbGVfZnApOw0KIAlj
bG9zZShjb21tYW5kX2ZpbGVfZmQpOw0KIAkNCi0JLyogZGVsZXRlIHRoZSBu
YW1lZCBwaXBlICovDQotCWlmKHVubGluayhjb21tYW5kX2ZpbGUpIT0wKQ0K
LQkJcmV0dXJuIEVSUk9SOw0KIA0KICNpZmRlZiBERUJVRzANCiAJcHJpbnRm
KCJjbG9zZV9jb21tYW5kX2ZpbGUoKSBlbmRcbiIpOw0K

--2093892754-1920379050-1074899792=:28423--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked