summaryrefslogtreecommitdiffstats
path: root/web/attachments/417469-check_smtp.c.patch
blob: 3c6a81247754f58fa6d8c6cff7b7260441d0a64d (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
32
33
34
35
36
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index ed49163..80cc0eb 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -129,6 +129,9 @@ main (int argc, char **argv)
 	char *error_msg = "";
 	struct timeval tv;
 
+	/* catch pipe errors in read.write */
+	(void) signal (SIGPIPE, SIG_IGN);
+
 	setlocale (LC_ALL, "");
 	bindtextdomain (PACKAGE, LOCALEDIR);
 	textdomain (PACKAGE);
@@ -662,8 +665,20 @@ void
 smtp_quit(void)
 {
 	int bytes;
+    int n;
+
+	n = my_send(SMTP_QUIT, strlen(SMTP_QUIT));
+	if(n != 0) {
+		if(verbose) {
+			/* Not sure this is really an unknown state so just print out instead
+			die (STATE_UNKNOWN,
+			*/
+			printf(
+				_("Connection was closed by server before we could send QUIT command\n"));
+		}
+		return;
+	}
 
-	my_send(SMTP_QUIT, strlen(SMTP_QUIT));
 	if (verbose)
 		printf(_("sent %s\n"), "QUIT");