summaryrefslogtreecommitdiffstats
path: root/web/attachments/27407-nagios-plugins-check_smtp.patch
blob: be080388a9a0c5ab3aa66eb4077621aad279fcbd (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
--- nagios-plugins/plugins/check_smtp.c Thu Jun 13 13:49:38 2002
+++ nagios-plugins.patched/plugins/check_smtp.c Fri Jul 19 14:03:19 2002
@@ -50,8 +50,13 @@
  */
 #define SMTP_DUMMYCMD  "MAIL\r\n"
 #define SMTP_USE_DUMMYCMD 1
+#define SMTP_USE_HELOCMD 1
 #define SMTP_QUIT      "QUIT\r\n"
 
+#ifdef SMTP_USE_HELOCMD
+#undef SMTP_USE_DUMMYCMD
+#endif /* SMTP_USE_HELOCMD */
+
 int process_arguments (int, char **);
 int call_getopt (int, char **);
 int validate_arguments (void);
@@ -74,6 +79,10 @@
        int sd;
        int result;
        char buffer[MAX_INPUT_BUFFER] = "";
+#ifdef SMTP_USE_HELOCMD
+       char helocmd[255] = "HELO ";
+       char myhostname[248];
+#endif /* SMTP_USE_HELOCMD */
 
        if (process_arguments (argc, argv) != OK)
                usage ("Invalid command arguments supplied\n");
@@ -137,13 +146,22 @@
                        }
                }
 
-               /* close the connection */
+#ifdef SMTP_USE_HELOCMD
+               gethostname(myhostname, sizeof(myhostname));
+               strcat(helocmd,myhostname);
+               strcat(helocmd,"\r\n");
+               send(sd,helocmd,strlen(helocmd),0);
+               /* allow for response to helo command to reach us */
+               recv(sd,buffer,MAX_INPUT_BUFFER-1,0);
+#endif /* SMTP_USE_HELOCMD */
+
 #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 */
 
+               /* close the connection */
                send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0);
                close (sd);
        }