[Nagiosplug-devel] check_smtp: Syntax bug?
seanius at seanius.net
Tue Aug 29 15:49:51 CEST 2006
On Mon, 2006-08-28 at 17:01 +0200, Saul, Markus wrote:
> Hello dear developers,
> today I faced a problem with the check_smtp plugin. I noticed that although I had given a wrong port number for a mail server the check returned an OK state and a normal response time. So I tried some things like placing characters in the command definition as the argument to the check command and it still said it was being ok.
> Together with a colleague he discovered that there was a difference between the normally defined check_smtp command the custom defined check_command we used, namely "check_smtp_port".
> The difference was:
> check_smtp -H $HOSTADDRESS$
> check_smtp_port $HOSTADDRESS$ -p $ARG1$
> I had overseen the missing "-H".
without actually looking at the code, i think i know what's happening.
we use getopt() for argument processing, which stops at the first
non-flag argument, which in this case would be HOSTADDRESS. then, it
checks to see if the hostname is set, and if it's not set and argv
is set, it takes argv as the hostname and continues along without
caring about the contents of argv and beyond.
so, a simple fix then ought to be to check the remaining value of argc
after processing arguments, and if it's > 2, exit STATE_UNKNOWN with an
"incorrect usage" error.
i don't have any time right now to actually dig into the code, so feel
free to do so to verify/patch it if you're feeling adventurous.
otherwise you should open a bug in the tracker and someone will get
to it eventually :)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 191 bytes
Desc: This is a digitally signed message part
More information about the Devel