[Nagiosplug-devel] check_smtp: Syntax bug?

sean finney seanius at seanius.net
Tue Aug 29 15:49:51 CEST 2006

hi markus,

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[1]
is set, it takes argv[1] as the hostname and continues along without
caring about the contents of argv[2] 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...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20060829/2ab02be3/attachment.sig>

More information about the Devel mailing list