summaryrefslogtreecommitdiffstats
path: root/web/attachments/401743-check_smtp.patch
blob: bf9811e0b1f6d79e433e8abfc2449891d995c987 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
diff -ru nagios-plugins-1.4.15/plugins/check_smtp.c mine/plugins/check_smtp.c
--- nagios-plugins-1.4.15/plugins/check_smtp.c	2010-07-27 21:47:16.000000000 +0100
+++ mine/plugins/check_smtp.c	2011-02-03 16:17:29.000000000 +0000
@@ -190,14 +190,19 @@
 				printf ("%s", buffer);
 			/* strip the buffer of carriage returns */
 			strip (buffer);
-			/* make sure we find the response we are looking for */
-			if (!strstr (buffer, server_expect)) {
-				if (server_port == SMTP_PORT)
-					printf (_("Invalid SMTP response received from host: %s\n"), buffer);
-				else
-					printf (_("Invalid SMTP response received from host on port %d: %s\n"),
-									server_port, buffer);
-				result = STATE_WARNING;
+			/* make sure we got a valid connect response */
+			if (!strstr (buffer, "220")) {
+				/* make sure we find the response we are looking for */
+				if (!strstr (buffer, server_expect)) {
+					if (server_port == SMTP_PORT)
+						printf (_("Invalid SMTP response received from host: %s\n"), buffer);
+					else
+						printf (_("Invalid SMTP response received from host on port %d: %s\n"),
+										server_port, buffer);
+					result = STATE_WARNING;
+				}
+				/* Failed to connect, so bail */
+				return result;
 			}
 		}