[Pkg-nagios-devel] nagios-plugins/debian/patches 16_check_smtp_protocolfix.dpatch, 1.1, 1.2

seanius at haydn.debian.org seanius at haydn.debian.org
Sun Oct 9 23:08:41 UTC 2005


Update of /cvsroot/pkg-nagios/nagios-plugins/debian/patches
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv3254/debian/patches

Modified Files:
	16_check_smtp_protocolfix.dpatch 
Log Message:
enhanced detection of local host name.


Index: 16_check_smtp_protocolfix.dpatch
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios-plugins/debian/patches/16_check_smtp_protocolfix.dpatch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- 16_check_smtp_protocolfix.dpatch	9 Oct 2005 22:31:17 -0000	1.1
+++ 16_check_smtp_protocolfix.dpatch	9 Oct 2005 23:08:38 -0000	1.2
@@ -6,8 +6,8 @@
 
 @DPATCH@
 diff -urNad nagios-plugins~/plugins/check_smtp.c nagios-plugins/plugins/check_smtp.c
---- nagios-plugins~/plugins/check_smtp.c	2005-10-10 00:26:43.000000000 +0200
-+++ nagios-plugins/plugins/check_smtp.c	2005-10-10 00:27:00.000000000 +0200
+--- nagios-plugins~/plugins/check_smtp.c	2005-10-10 00:55:39.000000000 +0200
++++ nagios-plugins/plugins/check_smtp.c	2005-10-10 01:05:31.000000000 +0200
 @@ -59,10 +59,17 @@
  enum {
  	SMTP_PORT	= 25
@@ -30,15 +30,16 @@
  
  int process_arguments (int, char **);
  int validate_arguments (void);
-@@ -101,6 +108,7 @@
+@@ -101,6 +108,8 @@
  int check_critical_time = FALSE;
  int verbose = 0;
  int use_ssl = FALSE;
 +short use_ehlo = FALSE;
++char *localhostname = NULL;
  int sd;
  char buffer[MAX_INPUT_BUFFER];
  enum {
-@@ -112,13 +120,14 @@
+@@ -112,14 +121,16 @@
  int
  main (int argc, char **argv)
  {
@@ -53,18 +54,29 @@
  	char *helocmd = NULL;
 +	char *ehlo_resp = NULL;
  	struct timeval tv;
++	struct hostent *hp;
  
  	setlocale (LC_ALL, "");
-@@ -129,12 +138,12 @@
+ 	bindtextdomain (PACKAGE, LOCALEDIR);
+@@ -129,12 +140,19 @@
  		usage4 (_("Could not parse arguments"));
  
  	/* initialize the HELO command with the localhostname */
 -#ifndef HOST_MAX_BYTES
 -#define HOST_MAX_BYTES 255
 -#endif
- 	helocmd = malloc (HOST_MAX_BYTES);
- 	gethostname(helocmd, HOST_MAX_BYTES);
+-	helocmd = malloc (HOST_MAX_BYTES);
+-	gethostname(helocmd, HOST_MAX_BYTES);
 -	asprintf (&helocmd, "%s%s%s", SMTP_HELO, helocmd, "\r\n");
++	if(! localhostname){
++		localhostname = malloc (HOST_MAX_BYTES);
++		gethostname(localhostname, HOST_MAX_BYTES);
++		hp = gethostbyname(localhostname);
++		if(!hp) helocmd = localhostname;
++		else helocmd = hp->h_name;
++	} else {
++		helocmd = localhostname;
++	}
 +	if(use_ehlo)
 +		asprintf (&helocmd, "%s%s%s", SMTP_EHLO, helocmd, "\r\n");
 +	else
@@ -72,7 +84,7 @@
  
  	/* initialize the MAIL command with optional FROM command  */
  	asprintf (&cmd_str, "%sFROM: %s%s", mail_command, from_arg, "\r\n");
-@@ -178,11 +187,25 @@
+@@ -178,11 +196,26 @@
  			}
  		}
  
@@ -95,12 +107,49 @@
 +
 +		if(use_ssl && ! supports_tls){
 +			printf(_("WARNING - TLS not supported by server\n"));
++			send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0);
 +			return STATE_WARNING;
 +		}
  
  #ifdef HAVE_SSL
  		if(use_ssl) {
-@@ -439,6 +462,7 @@
+@@ -192,6 +225,7 @@
+ 		  recv(sd,buffer, MAX_INPUT_BUFFER-1, 0); /* wait for it */
+ 		  if (!strstr (buffer, server_expect)) {
+ 		    printf (_("Server does not support STARTTLS\n"));
++		    send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0);
+ 		    return STATE_UNKNOWN;
+ 		  }
+ 		  if(connect_STARTTLS() != OK) {
+@@ -333,6 +367,7 @@
+ 		{"timeout", required_argument, 0, 't'},
+ 		{"port", required_argument, 0, 'p'},
+ 		{"from", required_argument, 0, 'f'},
++		{"fqdn", required_argument, 0, 'F'},
+ 		{"command", required_argument, 0, 'C'},
+ 		{"response", required_argument, 0, 'R'},
+ 		{"nocommand", required_argument, 0, 'n'},
+@@ -359,7 +394,7 @@
+ 	}
+ 
+ 	while (1) {
+-		c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:",
++		c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:F:",
+ 		                 longopts, &option);
+ 
+ 		if (c == -1 || c == EOF)
+@@ -380,6 +415,10 @@
+ 			else
+ 				usage4 (_("Port must be a positive integer"));
+ 			break;
++		case 'F':
++		/* localhostname */
++			localhostname = strdup(optarg);
++			break;
+ 		case 'f':									/* from argument */
+ 			from_arg = optarg;
+ 			smtp_use_dummycmd = 1;
+@@ -439,6 +478,7 @@
  		case 'S':
  		/* starttls */
  			use_ssl = TRUE;




More information about the Pkg-nagios-devel mailing list