This patch fixes a regression introduced in
dd2ac025db69bc78ca62391153ce4e74215e4903, which broke the bts script
when using implicit TLS via the submissions port (465), i.e. when
setting `--smtp-host` to a string starting with "smtps://" or
"ssmtp://".
The issue was that the mentioned commit added a line unconditionally
upgrading the connection with STARTTLS, even when the connection was
already using TLS via implicit TLS, which is an illegal operation and
causes Net::SMTP::starttls to die with message "SMTP connection is
already in SSL mode".
Closes: #1078426
---
scripts/bts.pl | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/scripts/bts.pl b/scripts/bts.pl
index 9a878430..7ca37f6a 100755
--- a/scripts/bts.pl
+++ b/scripts/bts.pl
@@ -2684,7 +2684,8 @@ sub send_mail {
} elsif (length $smtphost) {
my $smtp;
- if ($smtphost =~ m%^(?:(?:ssmtp|smtps)://)(.*)$%) {
+ my $smtps = $smtphost =~ m%^(?:(?:ssmtp|smtps)://)(.*)$%;
+ if ($smtps) {
my ($host, $port) = split(/:/, $1);
$port ||= '465';
@@ -2711,10 +2712,12 @@ sub send_mail {
if ($smtpuser) {
if (have_authen_sasl) {
$smtppass = getpass() if not $smtppass;
- # Enforce STARTTLS; Net::SMTP will otherwise refuse auth() in
- # the next step, and terminate the connection with FIN.
+ # Enforce STARTTLS, unless we're using SMTPS; Net::SMTP will
+ # otherwise refuse auth() in the next step, and terminate the
+ # connection with FIN.
$smtp->starttls()
- or die "$progname: Could not upgrade with STARTTLS";
+ or die "$progname: Could not upgrade with STARTTLS"
+ unless $smtps;
$smtp->auth($smtpuser, $smtppass)
or die
"$progname: failed to authenticate to $smtphost\n($@)\n";
--
2.45.2