[Nagiosplug-checkins] nagiosplug/plugins check_smtp.c,1.52,1.53

Ton Voon tonvoon at users.sourceforge.net
Thu Oct 12 22:36:48 CEST 2006


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv8227

Modified Files:
	check_smtp.c 
Log Message:
Resend EHLO after TLS negotiation as per RFC3207 (Holger Weiss - 1482832)


Index: check_smtp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_smtp.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- check_smtp.c	20 Jun 2006 11:17:02 -0000	1.52
+++ check_smtp.c	12 Oct 2006 20:36:45 -0000	1.53
@@ -282,6 +282,35 @@
 		  } else {
 			ssl_established = 1;
 		  }
+
+		/*
+		 * Resend the EHLO command.
+		 *
+		 * RFC 3207 (4.2) says: ``The client MUST discard any knowledge
+		 * obtained from the server, such as the list of SMTP service
+		 * extensions, which was not obtained from the TLS negotiation
+		 * itself.  The client SHOULD send an EHLO command as the first
+		 * command after a successful TLS negotiation.''  For this
+		 * reason, some MTAs will not allow an AUTH LOGIN command before
+		 * we resent EHLO via TLS.
+		 */
+		if (my_send(helocmd, strlen(helocmd)) <= 0) {
+			printf(_("SMTP UNKNOWN - Cannot send EHLO command via TLS.\n"));
+			my_close();
+			return STATE_UNKNOWN;
+		}
+		if (verbose)
+			printf(_("sent %s"), helocmd);
+		if ((n = my_recv(buffer, MAX_INPUT_BUFFER - 1)) <= 0) {
+			printf(_("SMTP UNKNOWN - Cannot read EHLO response via TLS.\n"));
+			my_close();
+			return STATE_UNKNOWN;
+		}
+		if (verbose) {
+			buffer[n] = '\0';
+			printf("%s", buffer);
+		}
+
 #  ifdef USE_OPENSSL
 		  if ( check_cert ) {
 		    result = np_net_ssl_check_cert(days_till_exp);
@@ -705,8 +734,8 @@
 	printf (_(UT_IPv46));
 
 	printf (" %s\n", "-e, --expect=STRING");
-  printf (_("String to expect in first line of server response (default: '%s')"),SMTP_EXPECT);
-  printf (" %s\n\n", "-n, nocommand\n");
+  printf (_("    String to expect in first line of server response (default: '%s')\n"), SMTP_EXPECT);
+  printf (" %s\n", "-n, nocommand");
   printf ("    %s\n", _("Suppress SMTP command"));
   printf (" %s\n", "-C, --command=STRING");
   printf ("    %s\n", _("SMTP command (may be used repeatedly)"));
@@ -734,6 +763,7 @@
 
 	printf (_(UT_VERBOSE));
 
+	printf("\n");
 	printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return"));
   printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN.  Successful"));
   printf ("%s\n", _("connects, but incorrect reponse messages from the host result in"));





More information about the Commits mailing list