[Nagiosplug-checkins] CVS: nagiosplug/plugins check_smtp.c,1.5,1.6

Subhendu Ghosh sghosh at users.sourceforge.net
Mon Sep 2 11:57:16 CEST 2002


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

Modified Files:
	check_smtp.c 
Log Message:
new -f option for adding a FROM address for RFC correctness

Index: check_smtp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_smtp.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** check_smtp.c	1 Sep 2002 16:18:29 -0000	1.5
--- check_smtp.c	2 Sep 2002 18:47:07 -0000	1.6
***************
*** 53,58 ****
   * According to rfc821 you can include a null reversepath in the from command
   * - but a log message is generated on the smtp server.
   */
! #define SMTP_DUMMYCMD  "MAIL FROM:<>\r\n"
  #define SMTP_USE_DUMMYCMD 1
  #define SMTP_QUIT	"QUIT\r\n"
--- 53,61 ----
   * According to rfc821 you can include a null reversepath in the from command
   * - but a log message is generated on the smtp server.
+  *
+  * Use the -f option to provide a FROM address
   */
!   
! #define SMTP_DUMMYCMD  "MAIL "
  #define SMTP_USE_DUMMYCMD 1
  #define SMTP_QUIT	"QUIT\r\n"
***************
*** 68,71 ****
--- 71,75 ----
  char *server_address = NULL;
  char *server_expect = NULL;
+ char *from_arg = " ";
  int warning_time = 0;
  int check_warning_time = FALSE;
***************
*** 81,84 ****
--- 85,89 ----
  	char buffer[MAX_INPUT_BUFFER] = "";
  	char helocmd[255] = SMTP_HELO ;
+ 	char from_str[255] = SMTP_DUMMYCMD ;
  	char myhostname[248];
  	
***************
*** 87,94 ****
  		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 */
--- 92,113 ----
  		usage ("Invalid command arguments supplied\n");
  
! 	/* initialize the HELO command with the localhostname */
  	gethostname(myhostname, sizeof(myhostname));
  	strcat(helocmd, myhostname);
  	strcat(helocmd, "\r\n");
+ 
+ 	/* initialize the MAIL command with optional FROM command  */
+ 	if (from_arg) {
+ 		strcat(from_str, "FROM: ");
+ 		strcat(from_str, from_arg);
+ 	}
+ 	/* terminate line with a CRLF */
+ 	strcat(from_str, "\r\n");
+ 		
+ 	if (verbose == TRUE){
+ 		printf ("FROMCMD: %s\n", from_str);
+ 	}
+ 
+ 	
  	
  	/* initialize alarm signal handling */
***************
*** 158,164 ****
  				
  #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 */
  
--- 177,185 ----
  				
  #ifdef SMTP_USE_DUMMYCMD
! 		send(sd,from_str,strlen(from_str),0);
! 		/* allow for response to DUMMYCMD to reach us */
! 		recv(sd,buffer,MAX_INPUT_BUFFER-1,0);
! 		if (verbose == TRUE) 
! 			printf("DUMMYCMD: %s\n%s\n",from_str,buffer);		
  #endif /* SMTP_USE_DUMMYCMD */
  
***************
*** 241,245 ****
  		{"critical", required_argument, 0, 'c'},
  		{"warning", required_argument, 0, 'w'},
! 		{"port", required_argument, 0, 'P'},
  		{"verbose", no_argument, 0, 'v'},
  		{"version", no_argument, 0, 'V'},
--- 262,267 ----
  		{"critical", required_argument, 0, 'c'},
  		{"warning", required_argument, 0, 'w'},
! 		{"port", required_argument, 0, 'p'},
! 		{"from", required_argument, 0, 'f'},
  		{"verbose", no_argument, 0, 'v'},
  		{"version", no_argument, 0, 'V'},
***************
*** 252,259 ****
  #ifdef HAVE_GETOPT_H
  		c =
! 			getopt_long (argc, argv, "+hVvt:p:e:c:w:H:", long_options,
  									 &option_index);
  #else
! 		c = getopt (argc, argv, "+?hVvt:p:e:c:w:H:");
  #endif
  
--- 274,281 ----
  #ifdef HAVE_GETOPT_H
  		c =
! 			getopt_long (argc, argv, "+hVvt:p:f:e:c:w:H:", long_options,
  									 &option_index);
  #else
! 		c = getopt (argc, argv, "+?hVvt:p:f:e:c:w:H:");
  #endif
  
***************
*** 267,270 ****
--- 289,293 ----
  		case 'p':
  		case 'e':
+ 		case 'f':
  		case 'c':
  		case 'w':
***************
*** 290,294 ****
  			}
  			break;
! 		case 'e':									/* username */
  			server_expect = optarg;
  			break;
--- 313,320 ----
  			}
  			break;
! 		case 'f':									/* from argument */
! 			from_arg = optarg;
! 			break;
! 		case 'e':									/* server expect string on 220  */
  			server_expect = optarg;
  			break;
***************
*** 365,368 ****
--- 391,396 ----
  		 " -e, --expect=STRING\n"
  		 "   String to expect in first line of server response (default: %s)\n"
+ 		 " -f, --from=STRING\n"
+ 		 "   from address to include in MAIL command (default NULL, Exchange2000 requires one)\n"
  		 " -w, --warning=INTEGER\n"
  		 "   Seconds necessary to result in a warning status\n"
***************
*** 389,393 ****
  {
  	printf
! 		("Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit] [-t timeout] [-v]\n"
  		 "       %s --help\n"
  		 "       %s --version\n", PROGNAME, PROGNAME, PROGNAME);
--- 417,421 ----
  {
  	printf
! 		("Usage: %s -H host [-e expect] [-p port] [-f from addr] [-w warn] [-c crit] [-t timeout] [-v]\n"
  		 "       %s --help\n"
  		 "       %s --version\n", PROGNAME, PROGNAME, PROGNAME);





More information about the Commits mailing list