summaryrefslogtreecommitdiffstats
path: root/web/attachments/30350-check_smtp.c.diff
blob: aa1c86cfae2aa8cfa6a1afe377c3a78963dc7279 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
--- nagiosplug-1.3-beta1/plugins/check_smtp.c	Mon Jun 10 05:24:06 2002
+++ nagiosplug-1.3-beta1-BALU/plugins/check_smtp.c	Tue Sep  3 15:01:09 2002
@@ -49,7 +49,8 @@
  * You can disable sending DUMMYCMD by undefining SMTP_USE_DUMMYCMD.
  */
 #define SMTP_DUMMYCMD  "MAIL\n"
-#define SMTP_USE_DUMMYCMD 1
+// BALU 20020903: added "--sendmail", so it is not needed anymore
+// #define SMTP_USE_DUMMYCMD 1 
 #define SMTP_QUIT	"QUIT\n"
 
 int process_arguments (int, char **);
@@ -67,6 +68,7 @@
 int critical_time = 0;
 int check_critical_time = FALSE;
 int verbose = FALSE;
+int sendmail = FALSE;
 
 int
 main (int argc, char **argv)
@@ -138,11 +140,11 @@
 		}
 
 		/* close the connection */
-#ifdef SMTP_USE_DUMMYCMD
-               send(sd,SMTP_DUMMYCMD,strlen(SMTP_DUMMYCMD),0);
-               /* allow for response to DUMMYCMD to reach us */
-               recv(sd,buffer,MAX_INPUT_BUFFER-1,0);
-#endif /* SMTP_USE_DUMMYCMD */
+               if (sendmail == TRUE) {
+		       send(sd,SMTP_DUMMYCMD,strlen(SMTP_DUMMYCMD),0);
+		       /* allow for response to DUMMYCMD to reach us */
+		       recv(sd,buffer,MAX_INPUT_BUFFER-1,0);
+               }
 
 		send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0);
 		close (sd);
@@ -225,17 +227,17 @@
 		{"verbose", no_argument, 0, 'v'},
 		{"version", no_argument, 0, 'V'},
 		{"help", no_argument, 0, 'h'},
+		{"sendmail", no_argument, 0, 's'},
 		{0, 0, 0, 0}
 	};
 #endif
 
 	while (1) {
 #ifdef HAVE_GETOPT_H
-		c =
-			getopt_long (argc, argv, "+hVvt:p:e:c:w:H:", long_options,
+		c = getopt_long (argc, argv, "+?hVvst:p:e:c:w:H:", long_options,
 									 &option_index);
 #else
-		c = getopt (argc, argv, "+?hVvt:p:e:c:w:H:");
+		c = getopt (argc, argv, "+?hVvst:p:e:c:w:H:");
 #endif
 
 		i++;
@@ -250,6 +252,7 @@
 		case 'c':
 		case 'w':
 		case 'H':
+		case 's':
 			i++;
 		}
 
@@ -302,6 +305,9 @@
 				usage ("Time interval must be a nonnegative integer\n");
 			}
 			break;
+		case 's':									/* sendmail-quirk? */
+			sendmail = TRUE;
+			break;
 		case 'V':									/* version */
 			print_revision (PROGNAME, "$Revision: 1.2 $");
 			exit (STATE_OK);
@@ -356,7 +362,9 @@
 		 " -h, --help\n"
 		 "   Print detailed help screen\n"
 		 " -V, --version\n"
-		 "   Print version information\n\n",
+		 "   Print version information\n"
+		 " -s, --sendmail\n"
+		 "   Enable dummy command to stop sendmail from logging NOQUEUE\n\n",
 		 SMTP_PORT, SMTP_EXPECT, DEFAULT_SOCKET_TIMEOUT);
 	support ();
 }
@@ -369,7 +377,7 @@
 print_usage (void)
 {
 	printf
-		("Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit] [-t timeout] [-v]\n"
+		("Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit] [-t timeout] [-v] [-s]\n"
 		 "       %s --help\n"
 		 "       %s --version\n", PROGNAME, PROGNAME, PROGNAME);
 }