summaryrefslogtreecommitdiffstats
path: root/plugins/check_smtp.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_smtp.c')
-rw-r--r--plugins/check_smtp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 2000c620..2d2e2891 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -43,6 +43,8 @@
43 43
44#define SMTP_PORT 25 44#define SMTP_PORT 25
45#define SMTP_EXPECT "220" 45#define SMTP_EXPECT "220"
46#define SMTP_HELO "HELO "
47
46/* sendmail will syslog a "NOQUEUE" error if session does not attempt 48/* sendmail will syslog a "NOQUEUE" error if session does not attempt
47 * to do something useful. This can be prevented by giving a command 49 * to do something useful. This can be prevented by giving a command
48 * even if syntax is illegal (MAIL requires a FROM:<...> argument) 50 * even if syntax is illegal (MAIL requires a FROM:<...> argument)
@@ -74,10 +76,18 @@ main (int argc, char **argv)
74 int sd; 76 int sd;
75 int result; 77 int result;
76 char buffer[MAX_INPUT_BUFFER] = ""; 78 char buffer[MAX_INPUT_BUFFER] = "";
79 char helocmd[255] = SMTP_HELO ;
80 char myhostname[248];
81
77 82
78 if (process_arguments (argc, argv) != OK) 83 if (process_arguments (argc, argv) != OK)
79 usage ("Invalid command arguments supplied\n"); 84 usage ("Invalid command arguments supplied\n");
80 85
86 /* initalize the HELO command with the localhostname */
87 gethostname(myhostname, sizeof(myhostname));
88 strcat(helocmd, myhostname);
89 strcat(helocmd, "\r\n");
90
81 /* initialize alarm signal handling */ 91 /* initialize alarm signal handling */
82 signal (SIGALRM, socket_timeout_alarm_handler); 92 signal (SIGALRM, socket_timeout_alarm_handler);
83 93
@@ -138,12 +148,18 @@ main (int argc, char **argv)
138 } 148 }
139 149
140 /* close the connection */ 150 /* close the connection */
151 /* first send the HELO command */
152 send(sd,helocmd,strlen(helocmd),0);
153 /* allow for response to helo command to reach us */
154 recv(sd,buffer,MAX_INPUT_BUFFER-1,0);
155
141#ifdef SMTP_USE_DUMMYCMD 156#ifdef SMTP_USE_DUMMYCMD
142 send(sd,SMTP_DUMMYCMD,strlen(SMTP_DUMMYCMD),0); 157 send(sd,SMTP_DUMMYCMD,strlen(SMTP_DUMMYCMD),0);
143 /* allow for response to DUMMYCMD to reach us */ 158 /* allow for response to DUMMYCMD to reach us */
144 recv(sd,buffer,MAX_INPUT_BUFFER-1,0); 159 recv(sd,buffer,MAX_INPUT_BUFFER-1,0);
145#endif /* SMTP_USE_DUMMYCMD */ 160#endif /* SMTP_USE_DUMMYCMD */
146 161
162 /* finally close the connection */
147 send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0); 163 send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0);
148 close (sd); 164 close (sd);
149 } 165 }