[Nagiosplug-checkins] CVS: nagiosplug/plugins check_smtp.c,1.3,1.4

Subhendu Ghosh sghosh at users.sourceforge.net
Wed Aug 14 12:06:11 CEST 2002


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory usw-pr-cvs1:/tmp/cvs-serv2217

Modified Files:
	check_smtp.c 
Log Message:
added HELO command

Index: check_smtp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_smtp.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** check_smtp.c	13 Jun 2002 20:49:38 -0000	1.3
--- check_smtp.c	14 Aug 2002 19:04:56 -0000	1.4
***************
*** 44,47 ****
--- 44,49 ----
  #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
***************
*** 75,82 ****
--- 77,92 ----
  	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);
***************
*** 139,142 ****
--- 149,157 ----
  
  		/* 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);
***************
*** 145,148 ****
--- 160,164 ----
  #endif /* SMTP_USE_DUMMYCMD */
  
+ 		/* finally close the connection */
  		send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0);
  		close (sd);





More information about the Commits mailing list