This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch master
in repository devscripts.

commit ff2a05dfef6b9d59576529c9eedfed96bcf5d8a9
Author: Andrew Shadura <[email protected]>
Date:   Mon Nov 2 21:21:02 2015 +0100

    Add STARTTLS support
    
    Use Net::SMTPS for both SMTP+SSL and SMTP+STARTTLS.
    When not connecting over SSL, always use Net::SMTPS in hope
    it does STARTTLS when it's detected. If Net::SMTPS isn't
    available, fall back to plain old Net::SMTP.
    
    Replace libnet-smtp-ssl-perl dependency with libnet-smtps-perl.
    
    Signed-off-by: Andrew Shadura <[email protected]>
---
 README         |  2 +-
 debian/control |  4 ++--
 scripts/bts.pl | 40 +++++++++++++++++++++++++---------------
 3 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/README b/README
index d03809e..575d3d4 100644
--- a/README
+++ b/README
@@ -27,7 +27,7 @@ And now, in mostly alphabetical order, the scripts:
 - bts: A command-line tool for accessing the BTS, both to
   send mails to [email protected] and to access the web pages and
   SOAP interface of the BTS. [www-browser, libauthen-sasl-perl,
-  libnet-smtp-ssl-perl, libsoap-lite-perl, liburi-perl, libwww-perl,
+  libnet-smtps-perl, libsoap-lite-perl, liburi-perl, libwww-perl,
   bsd-mailx | mailx]
 
 - build-rdeps: Searches for all packages that build-depend on a given package
diff --git a/debian/control b/debian/control
index 353e44c..5d16bdb 100644
--- a/debian/control
+++ b/debian/control
@@ -91,7 +91,7 @@ Suggests: adequate,
           how-can-i-help,
           libauthen-sasl-perl,
           libfile-desktopentry-perl,
-          libnet-smtp-ssl-perl,
+          libnet-smtps-perl,
           libterm-size-perl,
           libtimedate-perl,
           libyaml-syck-perl,
@@ -114,7 +114,7 @@ Description: scripts to make the life of a Debian Package 
maintainer easier
     E for stderr) for every line of output
   - archpath: print tla/Bazaar package names [tla | bazaar]
   - bts: a command-line tool for manipulating the BTS [www-browser,
-    libauthen-sasl-perl, libnet-smtp-ssl-perl, libsoap-lite-perl, liburi-perl,
+    libauthen-sasl-perl, libnet-smtps-perl, libsoap-lite-perl, liburi-perl,
     libwww-perl, bsd-mailx | mailx]
   - build-rdeps: search for all packages that build-depend on a given package
     [dctrl-tools, dose-extra]
diff --git a/scripts/bts.pl b/scripts/bts.pl
index eb60b76..2a650d1 100755
--- a/scripts/bts.pl
+++ b/scripts/bts.pl
@@ -74,7 +74,7 @@ $SIG{'__WARN__'} = sub { warn $_[0] unless $_[0] =~ /^Parsing 
of undecoded UTF-8
 my $it = undef;
 my $last_user = '';
 my $lwp_broken = undef;
-my $smtp_ssl_broken = undef;
+my $smtps_broken = undef;
 my $authen_sasl_broken;
 my $ua;
 
@@ -98,21 +98,21 @@ sub have_lwp() {
     return $lwp_broken ? 0 : 1;
 }
 
-sub have_smtp_ssl() {
-    return ($smtp_ssl_broken ? 0 : 1) if defined $smtp_ssl_broken;
+sub have_smtps() {
+    return ($smtps_broken ? 0 : 1) if defined $smtps_broken;
     eval {
-       require Net::SMTP::SSL;
+       require Net::SMTPS;
     };
 
     if ($@) {
-       if ($@ =~ m%^Can\'t locate Net/SMTP/SSL%) {
-           $smtp_ssl_broken="the libnet-smtp-ssl-perl package is not 
installed";
+       if ($@ =~ m%^Can\'t locate Net/SMTPS%) {
+           $smtps_broken="the libnet-smtps-perl package is not installed";
        } else {
-           $smtp_ssl_broken="couldn't load Net::SMTP::SSL: $@";
+           $smtps_broken="couldn't load Net::SMTPS: $@";
        }
     }
-    else { $smtp_ssl_broken=''; }
-    return $smtp_ssl_broken ? 0 : 1;
+    else { $smtps_broken=''; }
+    return $smtps_broken ? 0 : 1;
 }
 
 sub have_authen_sasl() {
@@ -349,6 +349,9 @@ The host name may be followed by a colon (":") and a port 
number in
 order to use a port other than the default.  It may also begin with
 "ssmtp://" or "smtps://" to indicate that SMTPS should be used.
 
+If SMTPS not specified, B<bts> will still try to use STARTTLS if it's 
advertised
+by the SMTP host.
+
 Note that one of B<$DEBEMAIL> or B<$EMAIL> must be set in the environment in 
order
 to use direct SMTP connections to send emails.
 
@@ -2617,18 +2620,25 @@ sub send_mail {
            my ($host, $port) = split(/:/, $1);
            $port ||= '465';
 
-           if (have_smtp_ssl) {
-               $smtp = Net::SMTP::SSL->new($host, Port => $port,
-                   Hello => $smtphelo) or die "$progname: failed to open SMTPS 
connection to $smtphost\n($@)\n";
+           if (have_smtps) {
+               $smtp = Net::SMTPS->new($host, Port => $port,
+                   Hello => $smtphelo, doSSL => 'ssl')
+                   or die "$progname: failed to open SMTPS connection to 
$smtphost\n($@)\n";
            } else {
-               die "$progname: Unable to establish SMTPS connection: 
$smtp_ssl_broken\n";
+               die "$progname: Unable to establish SMTPS connection: 
$smtps_broken\n";
            }
        } else {
            my ($host, $port) = split(/:/, $smtphost);
            $port ||= '25';
 
-           $smtp = Net::SMTP->new($host, Port => $port, Hello => $smtphelo)
-               or die "$progname: failed to open SMTP connection to 
$smtphost\n($@)\n";
+           if (have_smtps) {
+               $smtp = Net::SMTPS->new($host, Port => $port,
+                   Hello => $smtphelo, doSSL => 'starttls')
+                   or die "$progname: failed to open SMTP connection to 
$smtphost\n($@)\n";
+           } else {
+               $smtp = Net::SMTP->new($host, Port => $port, Hello => $smtphelo)
+                   or die "$progname: failed to open SMTP connection to 
$smtphost\n($@)\n";
+           }
        }
        if ($smtpuser) {
            if (have_authen_sasl) {

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/collab-maint/devscripts.git

_______________________________________________
devscripts-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/devscripts-devel

Reply via email to