[Nagiosplug-devel] BUG Report with Patch (check_smtp)
Subhendu Ghosh
sghosh at sghosh.org
Tue Mar 4 21:59:06 CET 2003
On Tue, 4 Mar 2003, Stephen Carpenter wrote:
> Ok...well I guess I can browse the bugs through the sourceforge
> interface but I am not 37337 enough to actually file bugs. Fine...
> well I found one and I fixed it.
>
> Anyway... there is a race condition in check_smtp
>
> Here goes... check_smtp connects to the server and gets the banner.
> At this point it sends back its OK and sets its return code to
> be STATE_OK...
>
> Then it procedes to close down the connection. However the alarm
> signal counter is still counting down. So if the HELO takes too
> long, then the signal handler wins the race and exits with
> a 2 (note the 2...look at the signal handler code... naughty
> not following your own coding standards its hard coded as a 2 :P )
> and a message that says "SMTP OK"
>
> I solved this by moving the print statment down to the end
> AFTER the "alarm(0)" that resets the alarm counter, thus removing
> the race condition.
>
> I chose to solve it this way because it catches the condition of the
> mail server being horked but still giving a banner (at least for some
> definitions of horked) we actually had this problem recently.
>
> The diff is attached
>
> -Steve
>
Thanks for the bug report. I couldn't find anywhere in netutils.c where
the signal handler exits with a 2. line number ??
I modified the patch to leave the Verbose print statement in place and
only move the actual output to right after alarm(0)
Otherwise I'd need another var to carry the banner to the end.
--
-sg
More information about the Devel
mailing list