check_smtp: Abort on missing/unexpected greeting

This commit is contained in:
Jan Wagner 2011-02-09 17:55:12 +00:00
parent fb68dc19d1
commit 5c0f63e2fa
3 changed files with 43 additions and 1 deletions

6
debian/changelog vendored
View file

@ -1,6 +1,10 @@
nagios-plugins (1.4.15-4) UNRELEASED; urgency=low
* NOT RELEASED YET
* Add 13_check_smtp_greeting.dpatch (Closes: #611914), thanks Daniel Piddock
for spotting and Holger Weiss for providing a fix
- Abort immediately if we don't receive a server greeting or if the
greeting doesn't contain the "--expect"ed string (by default: "220")
instead of blindly sending the EHLO/HELO line.
-- Jan Wagner <waja@cyconet.org> Mon, 27 Dec 2010 22:13:48 +0100

View file

@ -5,3 +5,4 @@
10_check_disk_smb_spaces.dpatch
11_check_disk_smb_NT_STATUS_ACCESS_DENIED.dpatch
12_check_snmp_1.4.15_regression.dpatch
13_check_smtp_greeting.dpatch

View file

@ -0,0 +1,37 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 13_check_smtp_greeting.dpatch
## Holger Weiss <holger@zedat.fu-berlin.de>
##
## From: d16f3fb0a9bb37cc1ce73ef14b5de83e907ef23c Tue, 8 Feb 2011 16:07:52 +0000 (+0100)
## From: Holger Weiss <holger@zedat.fu-berlin.de>
## Date: Tue, 8 Feb 2011 16:07:52 +0000 (+0100)
## Subject: [PATCH] check_smtp: Abort on missing/unexpected greeting
## (Debian #611914)
## X-Git-Url: http://nagiosplug.git.sourceforge.net/git/gitweb.cgi?p=nagiosplug%2Fnagiosplug;a=commitdiff_plain;h=d16f3fb0a9bb37cc1ce73ef14b5de83e907ef23c
##
## DP: Abort on missing/unexpected greeting (http://bugs.debian.org/611914)
@DPATCH@
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 3da724b..ed49163 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -183,7 +183,7 @@ main (int argc, char **argv)
/* return a WARNING status if we couldn't read any data */
if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {
printf (_("recv() failed\n"));
- result = STATE_WARNING;
+ return STATE_WARNING;
}
else {
if (verbose)
@@ -197,7 +197,7 @@ main (int argc, char **argv)
else
printf (_("Invalid SMTP response received from host on port %d: %s\n"),
server_port, buffer);
- result = STATE_WARNING;
+ return STATE_WARNING;
}
}