aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_smtp.c
diff options
context:
space:
mode:
authorGravatar Subhendu Ghosh <sghosh@users.sourceforge.net> 2002-08-14 19:04:56 +0000
committerGravatar Subhendu Ghosh <sghosh@users.sourceforge.net> 2002-08-14 19:04:56 +0000
commit325e642ae83045f15a3b19e9f8754a46a0d68ac0 (patch)
treeb9b23484892d1f86920ab2cf1dda380fe1df08ff /plugins/check_smtp.c
parentc62d37646b45b0a67bb4b3a0bf509ec898942075 (diff)
downloadmonitoring-plugins-325e642ae83045f15a3b19e9f8754a46a0d68ac0.tar.gz
added HELO command
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@77 f882894a-f735-0410-b71e-b25c423dba1c
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 @@
#define SMTP_PORT 25
#define SMTP_EXPECT "220"
+#define SMTP_HELO "HELO "
+
/* sendmail will syslog a "NOQUEUE" error if session does not attempt
* to do something useful. This can be prevented by giving a command
* even if syntax is illegal (MAIL requires a FROM:<...> argument)
@@ -74,10 +76,18 @@ main (int argc, char **argv)
int sd;
int result;
char buffer[MAX_INPUT_BUFFER] = "";
+ char helocmd[255] = SMTP_HELO ;
+ char myhostname[248];
+
if (process_arguments (argc, argv) != OK)
usage ("Invalid command arguments supplied\n");
+ /* initalize the HELO command with the localhostname */
+ gethostname(myhostname, sizeof(myhostname));
+ strcat(helocmd, myhostname);
+ strcat(helocmd, "\r\n");
+
/* initialize alarm signal handling */
signal (SIGALRM, socket_timeout_alarm_handler);
@@ -138,12 +148,18 @@ main (int argc, char **argv)
}
/* close the connection */
+ /* first send the HELO command */
+ send(sd,helocmd,strlen(helocmd),0);
+ /* allow for response to helo command to reach us */
+ recv(sd,buffer,MAX_INPUT_BUFFER-1,0);
+
#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 */
+ /* finally close the connection */
send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0);
close (sd);
}