[Pkg-nagios-devel] Bug#821207: [nagios-plugins-contrib] check_smtp_send fails when sending with --tls

Jan Wagner waja at cyconet.org
Sat Apr 16 17:34:45 UTC 2016


Package: nagios-plugins-contrib
Version: 14.20141104
Severity: important

When using the check_smtp_send to check the smtp server using (start)tls
this fails:

./check_smtp_send -H smtp.gmail.com -p 587 --tls -U testsend at gmail.com
-P XXXXXXXXXX --mailto testsend at gmail.com --mailfrom testreceive at gmail.com
SMTP SEND CRITICAL - Can't locate object method "message" via package
"Net::SMTP::TLS" at /usr/lib/nagios/plugins/check_smtp_send line 153.

It seems that the problem is introduced upstream in version 0.7.1a by
the "replaces all newlines in the input string with spaces"-fix. The
problematic (upstream) change is attached.

There is also a bug on Launchpad: LP #1497564

Cheers, Jan.
-- 
Never write mail to <waja at spamfalle.info>, you have been warned!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT d-- s+: a C+++ UL++++ P+ L+++ E--- W+++ N+++ o++ K++ w--- O M+ V- PS
PE Y++
PGP++ t-- 5 X R tv- b+ DI D+ G++ e++ h---- r+++ y++++
------END GEEK CODE BLOCK------
-------------- next part --------------
--- check_smtp_send_0.7.1	2011-11-11 02:56:05.000000000 +0100
+++ check_smtp_send_0.7.1a	2011-12-13 18:26:16.000000000 +0100
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use strict;
 use POSIX qw(strftime);
-my $VERSION = '0.7.2';
+my $VERSION = '0.7.3';
 my $COPYRIGHT = 'Copyright (C) 2005-2011 Jonathan Buhacoff <jonathan at buhacoff.net>';
 my $LICENSE = 'http://www.gnu.org/licenses/gpl.txt';
 my %status = ( 'OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3 );
@@ -147,16 +147,26 @@
 	if( $tls and $auth_method ) {
 		$smtp_port = $default_smtp_tls_port unless $smtp_port;
 		$smtp = TLS_auth->new($smtp_server, Timeout=>$timeout, Port=>$smtp_port, User=>$username, Password=>$password, Auth_Method=>$auth_method);
+		if( $smtp ) {
+			my $message = oneline($smtp->message());
+			die "cannot connect with TLS/$auth_method: $message" if $smtp->code() =~ m/53\d/;
+		}
 	}
 	elsif( $tls ) {
 		$smtp_port = $default_smtp_tls_port unless $smtp_port;
 		$smtp = Net::SMTP::TLS->new($smtp_server, Timeout=>$timeout, Port=>$smtp_port, User=>$username, Password=>$password);
+		if( $smtp ) {
+			my $message = oneline($smtp->message());
+			die "cannot connect with TLS: $message" if $smtp->code() =~ m/53\d/;
+		}
 	}
 	elsif( $ssl ) {
 		$smtp_port = $default_smtp_ssl_port unless $smtp_port;
 		$smtp = Net::SMTP::SSL->new($smtp_server, Port => $smtp_port, Timeout=>$timeout,Debug=>$smtp_debug);
 		if( $smtp && $username )  {
 			$smtp->auth($username, $password);
+			my $message = oneline($smtp->message());
+			die "cannot connect with SSL/password: $message" if $smtp->code() =~ m/53\d/;
 		}	
 	}
 	elsif( $auth_method ) {
@@ -164,6 +174,8 @@
 		$smtp = Net::SMTP_auth->new($smtp_server, Port=>$smtp_port, Timeout=>$timeout,Debug=>$smtp_debug);	
 		if( $smtp ) {
 			$smtp->auth($auth_method, $username, $password);
+			my $message = oneline($smtp->message());
+			die "cannot connect with SSL/$auth_method: $message" if $smtp->code() =~ m/53\d/;
 		}			
 	}
 	else {
@@ -171,8 +183,10 @@
 		$smtp = Net::SMTP->new($smtp_server, Port=>$smtp_port, Timeout=>$timeout,Debug=>$smtp_debug);	
 		if( $smtp && $username ) {
 			$smtp->auth($username, $password);
+			my $message = oneline($smtp->message());
+			die "cannot connect with password: $message" if $smtp->code() =~ m/53\d/;
 		}	
-	}	
+	}
 };
 if( $@ ) {
 	$@ =~ s/\n/ /g; # the error message can be multiline but we want our output to be just one line
@@ -358,6 +372,13 @@
 	return $string;
 }
 
+# replaces all newlines in the input string with spaces
+sub oneline {
+	my ($input) = @_;
+	$input =~ s/[\r\n]+/ /g;
+	return $input;
+}
+
 # NAME
 #	PluginReport
 # SYNOPSIS
@@ -499,6 +520,14 @@
 
 Use the notls option to turn off the tls option.
 
+Also, you may need to fix your copy of Net::SMTP::TLS. Here is the diff against version 0.12:
+
+ 254c254
+ < 	$me->_command(sprintf("AUTH PLAIN %S",
+ ---
+ > 	$me->_command(sprintf("AUTH PLAIN %s",
+
+
 =item --ssl
 
 =item --nossl
@@ -721,7 +750,11 @@
  Wed Jul  6 19:18:26 AST 2011
  + the --hostname is now optional; if not provided the plugin will lookup the MX record for the --mailto address (requires Net::DNS)
  + version 0.7.2
- 
+
+ Tue Dec 13 09:24:04 PST 2011
+ + separated authentication errors from connection errors
+ + version 0.7.3
+
 =head1 AUTHOR
 
 Jonathan Buhacoff <jonathan at buhacoff.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-nagios-devel/attachments/20160416/3ac51f35/attachment.sig>


More information about the Pkg-nagios-devel mailing list