[nagiosplug] check_smtp: Abort on missing/unexpected greeting

"Holger Weiss" <[email protected]> Tue, 8 Feb 2011 16:18:13 +0000
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
 Module: nagiosplug
 Branch: master
 Commit: d16f3fb0a9bb37cc1ce73ef14b5de83e907ef23c
 Author: Holger Weiss <[email protected]>
   Date: Tue Feb  8 17:07:52 2011 +0100
    URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=d16f3fb

check_smtp: Abort on missing/unexpected greeting

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.

Spotted by Daniel Piddock, see Debian bug report #611914.

---

 plugins/check_smtp.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

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;
 			}
 		}
 


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb