--- 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); }