Remove dependency on deprecated Net::SMTP::SSL
PATCH 1/1 Remove dependency on deprecated Net::SMTP::SSL
Refactor send_message() to remove dependency on deprecated Net::SMTP::SSL:
<http://search.cpan.org/~rjbs/Net-SMTP-SSL-1.04/lib/Net/SMTP/SSL.pm#DEPRECATED>
--- git-send-email.perl | 54 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 29 deletions(-)
git-send-email.perl +25 -29
@@ -1330,15 +1330,17 @@ Message-Id: $message_id print $sm "$header\n$message"; close $sm or die $!; } else { - if (!defined $smtp_server) { die "The required SMTP server is not properly defined." } + require Net::SMTP; + $smtp_domain ||= maildomain(); + my $smtp_ssl = 0; + if ($smtp_encryption eq 'ssl') { $smtp_server_port ||= 465; # ssmtp - require Net::SMTP::SSL; - $smtp_domain ||= maildomain(); + $smtp_ssl = 1; require IO::Socket::SSL; # Suppress "variable accessed once" warning.
@@ -1347,37 +1349,31 @@ Message-Id: $message_id $IO::Socket::SSL::DEBUG = 1; } - # Net::SMTP::SSL->new() does not forward any SSL options IO::Socket::SSL::set_client_defaults( ssl_verify_params()); - $smtp ||= Net::SMTP::SSL->new($smtp_server, - Hello => $smtp_domain, - Port => $smtp_server_port, - Debug => $debug_net_smtp); } else { - require Net::SMTP; - $smtp_domain ||= maildomain(); $smtp_server_port ||= 25; - $smtp ||= Net::SMTP->new($smtp_server, - Hello => $smtp_domain, - Debug => $debug_net_smtp, - Port => $smtp_server_port); - if ($smtp_encryption eq 'tls' && $smtp) { - require Net::SMTP::SSL; - $smtp->command('STARTTLS'); - $smtp->response(); - if ($smtp->code == 220) { - $smtp = Net::SMTP::SSL->start_SSL($smtp, - ssl_verify_params()) - or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); - $smtp_encryption = ''; - # Send EHLO again to receive fresh - # supported commands - $smtp->hello($smtp_domain); - } else { - die "Server does not support STARTTLS! ".$smtp->message; - } + } + + $smtp ||= Net::SMTP->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp, + SSL => $smtp_ssl); + + if ($smtp_encryption eq 'tls' && $smtp) { + $smtp->command('STARTTLS'); + $smtp->response(); + if ($smtp->code == 220) { + $smtp->starttls(ssl_verify_params()) + or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); + $smtp_encryption = ''; + # Send EHLO again to receive fresh + # supported commands + $smtp->hello($smtp_domain); + } else { + die "Server does not support STARTTLS! ".$smtp->message; } }
Signature · 1 line
2.9.3 (Apple Git-75)
Quoted 4 lines · Mike Fisher
Refactor
send_message()to remove dependency on deprecatedNet::SMTP::SSL:<http://search.cpan.org/~rjbs/Net-SMTP-SSL-1.04/lib/Net/SMTP/SSL.pm#DEPRECATED>
As much as I hate to say this, I think this is going to cause compatibility problems. Net::SMTP is part of core Perl (as of v5.7.3), but the version you want to rely on (which you did not provide an explicit dependency on) is from October 2014.
That basically means that no Perl on a Red Hat or CentOS system is going to provide that support, since RHEL 7 was released in June 2014. Providing an updated Git on those platforms would require replacing the system Perl or parts of it, which would be undesirable. This would affect Debian 7 as well.
We currently support Perl 5.8 [0], so if you want to remove support for Net::SMTP::SSL, I'd recommend a solution that works with that version.
[0] I personally believe we should drop support for Perl older than 5.10.1 (if not newer), but that's my opinion and it isn't shared by other list regulars.
Signature · 3 lines
brian m. carlson / brian with sandals: Houston, Texas, US +1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: https://keybase.io/bk2204
Quoted 19 lines · brian m. carlson
Quoted 4 lines · Mike Fisher
Refactor
send_message()to remove dependency on deprecatedNet::SMTP::SSL:<http://search.cpan.org/~rjbs/Net-SMTP-SSL-1.04/lib/Net/SMTP/SSL.pm#DEPRECATED>
As much as I hate to say this, I think this is going to cause compatibility problems.
Net::SMTPis part of core Perl (as of v5.7.3), but the version you want to rely on (which you did not provide an explicit dependency on) is from October 2014.That basically means that no Perl on a Red Hat or CentOS system is going to provide that support, since RHEL 7 was released in June 2014. Providing an updated Git on those platforms would require replacing the system Perl or parts of it, which would be undesirable. This would affect Debian 7 as well.
Quoted 10 lines
We currently support Perl 5.8 [0], so if you want to remove support for
Net::SMTP::SSL, I'd recommend a solution that works with that version.[0] I personally believe we should drop support for Perl older than 5.10.1 (if not newer), but that's my opinion and it isn't shared by other list regulars.
Signature · 3 lines
brian m. carlson / brian with sandals: Houston, Texas, US +1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: https://keybase.io/bk2204
Net::SMTP::SSL is marked as DEPRECATED on FreeBSD ports tree and will be removed in 2017-03-31. When it happens users will not be able to run git-send-email anymore. I’m considering to add Mike’s patch to FreeBSD ports tree as an alternative but it would be good to have a official solution for this problem.
FreeBSD bug report can be found at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214335
--
Renato Botelho
Quoted 3 lines · Mike Fisher
Thanks for contributing to Git.
One comment on the head line:
Quoted 1 line
Refactor
send_message()to remove dependency on deprecated
Net::SMTP::SSL
The word "refactor" may be used in other way: Re-structure the code, and use the same API.
"Remove dependency on deprecated Net::SMTP::SSL"
Quoted 2 lines
Refactor
send_message()to remove dependency on deprecatedNet::SMTP::SSL:
Is there a security risk with require Net::SMTP::SSL ?
If yes, the commit message should state this.
If no:
Even if it is deprecated, is it still in use somewhere ?
Does it hurt someone, is there any OS release where the old code doesn't work anymore ? Or is it "only" nice to have ?
Since when does Net::SMTP include Net::SMTP::SSL ?
On which system has the change been tested ?
I think the commit message could and should give more information like this.
My comments may be over-critical.
Lets see if other people from the list know more than me.
Quoted 13 lines
<http://search.cpan.org/~rjbs/Net-SMTP-SSL-1.04/lib/Net/SMTP/SSL.pm#DEPRECATED>
Signed-off-by Mike Fisher <[email protected]>--- git-send-email.perl | 54 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 29 deletions(-)git-send-email.perl +0
-0
git-send-email.perl Message-Id: $message_id · line 1333
Quoted 4 lines
git-send-email.perl +0
-1@@ -1330,15 +1330,17 @@ Message-Id: $message_id print $sm "$header\n$message"; close $sm or die $!; } else { -
I can see one refactoring, that is the removal of an empty line.
Quoted 75 lines
git-send-email.perl +25
-28if (!defined $smtp_server) { die "The required SMTP server is not properly defined." } + require Net::SMTP; + $smtp_domain ||= maildomain(); + my $smtp_ssl = 0; + if ($smtp_encryption eq 'ssl') { $smtp_server_port ||= 465; # ssmtp - require Net::SMTP::SSL; - $smtp_domain ||= maildomain(); + $smtp_ssl = 1; require IO::Socket::SSL; # Suppress "variable accessed once" warning.@@ -1347,37 +1349,31 @@ Message-Id: $message_id $IO::Socket::SSL::DEBUG = 1; } - # Net::SMTP::SSL->new() does not forward any SSL options IO::Socket::SSL::set_client_defaults( ssl_verify_params()); - $smtp ||= Net::SMTP::SSL->new($smtp_server, - Hello => $smtp_domain, - Port => $smtp_server_port, - Debug => $debug_net_smtp); } else { - require Net::SMTP; - $smtp_domain ||= maildomain(); $smtp_server_port ||= 25; - $smtp ||= Net::SMTP->new($smtp_server, - Hello => $smtp_domain, - Debug => $debug_net_smtp, - Port => $smtp_server_port); - if ($smtp_encryption eq 'tls' && $smtp) { - require Net::SMTP::SSL; - $smtp->command('STARTTLS'); - $smtp->response(); - if ($smtp->code == 220) { - $smtp = Net::SMTP::SSL->start_SSL($smtp, - ssl_verify_params()) - or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); - $smtp_encryption = ''; - # Send EHLO again to receive fresh - # supported commands - $smtp->hello($smtp_domain); - } else { - die "Server does not support STARTTLS! ".$smtp->message; - } + } + + $smtp ||= Net::SMTP->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp, + SSL => $smtp_ssl); + + if ($smtp_encryption eq 'tls' && $smtp) { + $smtp->command('STARTTLS'); + $smtp->response(); + if ($smtp->code == 220) { + $smtp->starttls(ssl_verify_params()) + or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); + $smtp_encryption = ''; + # Send EHLO again to receive fresh + # supported commands + $smtp->hello($smtp_domain); + } else { + die "Server does not support STARTTLS! ".$smtp->message; } }
PATCH 1/1 send-email: Net::SMTP::SSL is obsolete, use only when necessary
In reply to Mike FisherNet::SMTP itself can do the necessary SSL and STARTTLS bits just fine since version 1.28, and Net::SMTP::SSL is now deprecated. Since 1.28 isn't that old yet, keep the old code in place and use it when necessary.
---
Note: I've only been able to test the starttls bits. None of the smtp servers I use actually use ssl, only starttls.
git-send-email.perl | 52 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-)
git-send-email.perl +34 -18
@@ -1353,10 +1353,12 @@ EOF die __("The required SMTP server is not properly defined.") } + require Net::SMTP; + my $use_net_smtp_ssl = $Net::SMTP::VERSION lt "1.28"; + $smtp_domain ||= maildomain(); + if ($smtp_encryption eq 'ssl') { $smtp_server_port ||= 465; # ssmtp - require Net::SMTP::SSL; - $smtp_domain ||= maildomain(); require IO::Socket::SSL; # Suppress "variable accessed once" warning.
@@ -1368,34 +1370,48 @@ EOF # Net::SMTP::SSL->new() does not forward any SSL options IO::Socket::SSL::set_client_defaults( ssl_verify_params()); - $smtp ||= Net::SMTP::SSL->new($smtp_server, - Hello => $smtp_domain, - Port => $smtp_server_port, - Debug => $debug_net_smtp); + + if ($use_net_smtp_ssl) { + require Net::SMTP::SSL; + $smtp ||= Net::SMTP::SSL->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp); + } + else { + $smtp ||= Net::SMTP->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp, + SSL => 1); + } } else { - require Net::SMTP; - $smtp_domain ||= maildomain(); $smtp_server_port ||= 25; $smtp ||= Net::SMTP->new($smtp_server, Hello => $smtp_domain, Debug => $debug_net_smtp, Port => $smtp_server_port); if ($smtp_encryption eq 'tls' && $smtp) { - require Net::SMTP::SSL; - $smtp->command('STARTTLS'); - $smtp->response(); - if ($smtp->code == 220) { + if ($use_net_smtp_ssl) { + $smtp->command('STARTTLS'); + $smtp->response(); + if ($smtp->code != 220) { + die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); + } + require Net::SMTP::SSL; $smtp = Net::SMTP::SSL->start_SSL($smtp, ssl_verify_params()) or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); - $smtp_encryption = ''; - # Send EHLO again to receive fresh - # supported commands - $smtp->hello($smtp_domain); - } else { - die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); } + else { + $smtp->starttls(ssl_verify_params()) + or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); + } + $smtp_encryption = ''; + # Send EHLO again to receive fresh + # supported commands + $smtp->hello($smtp_domain); } }
Signature · 1 line
2.12.0-437-g0cc2799
Re: [PATCH] send-email: Net::SMTP::SSL is obsolete, use only when necessary
Quoted 18 lines · Dennis Kaarsemaker
Net::SMTPitself can do the necessary SSL and STARTTLS bits just fine since version 1.28, andNet::SMTP::SSLis now deprecated. Since 1.28 isn't that old yet, keep the old code in place and use it when necessary.Signed-off-by Dennis Kaarsemaker <[email protected]>---
Note: I've only been able to test the starttls bits. None of the smtp servers I use actually use ssl, only starttls.git-send-email.perl | 52 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-)git-send-email.perl +0
-0
git-send-email.perl EOF · line 1359
Quoted 7 lines
git-send-email.perl +4
-0@@ -1353,10 +1353,12 @@ EOF die __("The required SMTP server is not properly defined.") } + require Net::SMTP; + my $use_net_smtp_ssl = $Net::SMTP::VERSION lt "1.28"; + $smtp_domain ||= maildomain(); +
While Net::SMTP is unlikely to change its versioning scheme, let's use comparisons via the version module here in case they do change it to something silly, and this ends up introducing a bug.
E.g. 04.00 would be considered a higher version by CPAN than 1.28, but not by this code:
$ perl -wE 'my ($x, $y) = @ARGV; my ($vx, $vy) = map {
version->parse($_) } ($x, $y); say $vx < $vy ? "vlower" : "vhigher";
say $x lt $y ? "slower" : "shigher"' 04.00 1.28
vhigher
slowerIf we grep ::VERSION we can find other cases where we've gotten this wrong, unlikely to bite us in practice, but version.pm is in core (so core that you don't even need to use/require it), so let's do this better for new code.
git-send-email.perl EOF · line 1400
Quoted 3 lines
[...]
git-send-email.perl +2
-0+ if ($smtp->code != 220) { + die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message);
Here a new message you're adding gets __(), makes sense.
Quoted 6 lines
git-send-email.perl +2
-1+ } + require Net::SMTP::SSL; $smtp = Net::SMTP::SSL->start_SSL($smtp, ssl_verify_params()) or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); - $smtp_encryption = '';
git-send-email.perl EOF · line 1410
Quoted 10 lines
git-send-email.perl +4
-5- # Send EHLO again to receive fresh - # supported commands - $smtp->hello($smtp_domain); - } else { - die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); } + else { + $smtp->starttls(ssl_verify_params()) + or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); + }
I see you just copied that from above but I wonder if it makes sense to just mark both occurrences with __() too while we're at it.
Re: [PATCH] send-email: Net::SMTP::SSL is obsolete, use only when necessary
Quoted 11 lines · Ævar Arnfjörð Bjarmason
git-send-email.perl EOF · line 1359
Quoted 4 lines · Dennis Kaarsemaker
git-send-email.perl +4
-0+ require Net::SMTP; + my $use_net_smtp_ssl = $Net::SMTP::VERSION lt "1.28"; + $smtp_domain ||= maildomain(); +While
Net::SMTPis unlikely to change its versioning scheme, let's use comparisons via the version module here in case they do change it to something silly, and this ends up introducing a bug.
ok.
Quoted 5 lines
git-send-email.perl EOF · line 1400
Quoted 3 lines
[...]
git-send-email.perl +2
-0+ if ($smtp->code != 220) { + die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message);Here a new message you're adding gets
__(), makes sense.
Didn't add it, it just moved from a bit further below :)
Quoted 7 lines
git-send-email.perl EOF · line 1410
Quoted 4 lines
git-send-email.perl +4
-0+ else { + $smtp->starttls(ssl_verify_params()) + or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); + }I see you just copied that from above but I wonder if it makes sense to just mark both occurrences with
__()too while we're at it.
ok.
D.
PATCH v2 1/1 send-email: Net::SMTP::SSL is obsolete, use only when necessary
In reply to Ævar Arnfjörð BjarmasonNet::SMTP itself can do the necessary SSL and STARTTLS bits just fine since version 1.28, and Net::SMTP::SSL is now deprecated. Since 1.28 isn't that old yet, keep the old code in place and use it when necessary.
While we're in the area, mark some messages for translation that were not yet marked as such.
--- git-send-email.perl | 54 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-)
git-send-email.perl +35 -19
@@ -1353,10 +1353,12 @@ EOF die __("The required SMTP server is not properly defined.") } + require Net::SMTP; + my $use_net_smtp_ssl = version->parse($Net::SMTP::VERSION) < version->parse("1.28"); + $smtp_domain ||= maildomain(); + if ($smtp_encryption eq 'ssl') { $smtp_server_port ||= 465; # ssmtp - require Net::SMTP::SSL; - $smtp_domain ||= maildomain(); require IO::Socket::SSL; # Suppress "variable accessed once" warning.
@@ -1368,34 +1370,48 @@ EOF # Net::SMTP::SSL->new() does not forward any SSL options IO::Socket::SSL::set_client_defaults( ssl_verify_params()); - $smtp ||= Net::SMTP::SSL->new($smtp_server, - Hello => $smtp_domain, - Port => $smtp_server_port, - Debug => $debug_net_smtp); + + if ($use_net_smtp_ssl) { + require Net::SMTP::SSL; + $smtp ||= Net::SMTP::SSL->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp); + } + else { + $smtp ||= Net::SMTP->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp, + SSL => 1); + } } else { - require Net::SMTP; - $smtp_domain ||= maildomain(); $smtp_server_port ||= 25; $smtp ||= Net::SMTP->new($smtp_server, Hello => $smtp_domain, Debug => $debug_net_smtp, Port => $smtp_server_port); if ($smtp_encryption eq 'tls' && $smtp) { - require Net::SMTP::SSL; - $smtp->command('STARTTLS'); - $smtp->response(); - if ($smtp->code == 220) { + if ($use_net_smtp_ssl) { + $smtp->command('STARTTLS'); + $smtp->response(); + if ($smtp->code != 220) { + die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); + } + require Net::SMTP::SSL; $smtp = Net::SMTP::SSL->start_SSL($smtp, ssl_verify_params()) - or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); - $smtp_encryption = ''; - # Send EHLO again to receive fresh - # supported commands - $smtp->hello($smtp_domain); - } else { - die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); + or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr()); + } + else { + $smtp->starttls(ssl_verify_params()) + or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr()); } + $smtp_encryption = ''; + # Send EHLO again to receive fresh + # supported commands + $smtp->hello($smtp_domain); } }
Signature · 1 line
2.12.0-488-gd3584ba
Re: [PATCH v2] send-email: Net::SMTP::SSL is obsolete, use only when necessary
Ping. It's a little over a month since I sent this, but I haven't seen any comments. Is this commit good to go?
Quoted 98 lines · Dennis Kaarsemaker
Net::SMTPitself can do the necessary SSL and STARTTLS bits just fine since version 1.28, andNet::SMTP::SSLis now deprecated. Since 1.28 isn't that old yet, keep the old code in place and use it when necessary.While we're in the area, mark some messages for translation that were not yet marked as such.
Signed-off-by Dennis Kaarsemaker <[email protected]>--- git-send-email.perl | 54 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-)git-send-email.perl +35
-19@@ -1353,10 +1353,12 @@ EOF die __("The required SMTP server is not properly defined.") } + require Net::SMTP; + my $use_net_smtp_ssl = version->parse($Net::SMTP::VERSION) < version->parse("1.28"); + $smtp_domain ||= maildomain(); + if ($smtp_encryption eq 'ssl') { $smtp_server_port ||= 465; # ssmtp - require Net::SMTP::SSL; - $smtp_domain ||= maildomain(); require IO::Socket::SSL; # Suppress "variable accessed once" warning.@@ -1368,34 +1370,48 @@ EOF # Net::SMTP::SSL->new() does not forward any SSL options IO::Socket::SSL::set_client_defaults( ssl_verify_params()); - $smtp ||= Net::SMTP::SSL->new($smtp_server, - Hello => $smtp_domain, - Port => $smtp_server_port, - Debug => $debug_net_smtp); + + if ($use_net_smtp_ssl) { + require Net::SMTP::SSL; + $smtp ||= Net::SMTP::SSL->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp); + } + else { + $smtp ||= Net::SMTP->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp, + SSL => 1); + } } else { - require Net::SMTP; - $smtp_domain ||= maildomain(); $smtp_server_port ||= 25; $smtp ||= Net::SMTP->new($smtp_server, Hello => $smtp_domain, Debug => $debug_net_smtp, Port => $smtp_server_port); if ($smtp_encryption eq 'tls' && $smtp) { - require Net::SMTP::SSL; - $smtp->command('STARTTLS'); - $smtp->response(); - if ($smtp->code == 220) { + if ($use_net_smtp_ssl) { + $smtp->command('STARTTLS'); + $smtp->response(); + if ($smtp->code != 220) { + die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); + } + require Net::SMTP::SSL; $smtp = Net::SMTP::SSL->start_SSL($smtp, ssl_verify_params()) - or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); - $smtp_encryption = ''; - # Send EHLO again to receive fresh - # supported commands - $smtp->hello($smtp_domain); - } else { - die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); + or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr()); + } + else { + $smtp->starttls(ssl_verify_params()) + or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr()); } + $smtp_encryption = ''; + # Send EHLO again to receive fresh + # supported commands + $smtp->hello($smtp_domain); } }
Re: [PATCH v2] send-email: Net::SMTP::SSL is obsolete, use only when necessary
Second ping. This problem is not going away, so if this solution is not acceptable, I'd like to know what needs to be improved.
Quoted 102 lines · Dennis Kaarsemaker
Ping. It's a little over a month since I sent this, but I haven't seen any comments. Is this commit good to go?
Quoted 98 lines · Dennis Kaarsemaker
Net::SMTPitself can do the necessary SSL and STARTTLS bits just fine since version 1.28, andNet::SMTP::SSLis now deprecated. Since 1.28 isn't that old yet, keep the old code in place and use it when necessary.While we're in the area, mark some messages for translation that were not yet marked as such.
Signed-off-by Dennis Kaarsemaker <[email protected]>--- git-send-email.perl | 54 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-)git-send-email.perl +35
-19@@ -1353,10 +1353,12 @@ EOF die __("The required SMTP server is not properly defined.") } + require Net::SMTP; + my $use_net_smtp_ssl = version->parse($Net::SMTP::VERSION) < version->parse("1.28"); + $smtp_domain ||= maildomain(); + if ($smtp_encryption eq 'ssl') { $smtp_server_port ||= 465; # ssmtp - require Net::SMTP::SSL; - $smtp_domain ||= maildomain(); require IO::Socket::SSL; # Suppress "variable accessed once" warning.@@ -1368,34 +1370,48 @@ EOF # Net::SMTP::SSL->new() does not forward any SSL options IO::Socket::SSL::set_client_defaults( ssl_verify_params()); - $smtp ||= Net::SMTP::SSL->new($smtp_server, - Hello => $smtp_domain, - Port => $smtp_server_port, - Debug => $debug_net_smtp); + + if ($use_net_smtp_ssl) { + require Net::SMTP::SSL; + $smtp ||= Net::SMTP::SSL->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp); + } + else { + $smtp ||= Net::SMTP->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp, + SSL => 1); + } } else { - require Net::SMTP; - $smtp_domain ||= maildomain(); $smtp_server_port ||= 25; $smtp ||= Net::SMTP->new($smtp_server, Hello => $smtp_domain, Debug => $debug_net_smtp, Port => $smtp_server_port); if ($smtp_encryption eq 'tls' && $smtp) { - require Net::SMTP::SSL; - $smtp->command('STARTTLS'); - $smtp->response(); - if ($smtp->code == 220) { + if ($use_net_smtp_ssl) { + $smtp->command('STARTTLS'); + $smtp->response(); + if ($smtp->code != 220) { + die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); + } + require Net::SMTP::SSL; $smtp = Net::SMTP::SSL->start_SSL($smtp, ssl_verify_params()) - or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); - $smtp_encryption = ''; - # Send EHLO again to receive fresh - # supported commands - $smtp->hello($smtp_domain); - } else { - die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); + or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr()); + } + else { + $smtp->starttls(ssl_verify_params()) + or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr()); } + $smtp_encryption = ''; + # Send EHLO again to receive fresh + # supported commands + $smtp->hello($smtp_domain); } }
Ævar Arnfjörð Bjarmason
Reviewed-byRe: [PATCH v2] send-email: Net::SMTP::SSL is obsolete, use only when necessary
Quoted 2 lines · Dennis Kaarsemaker
Second ping. This problem is not going away, so if this solution is not acceptable, I'd like to know what needs to be improved.
FWIW:
Quoted 103 lines · Dennis Kaarsemaker
Quoted 102 lines
Ping. It's a little over a month since I sent this, but I haven't seen any comments. Is this commit good to go?
Quoted 98 lines · Dennis Kaarsemaker
Net::SMTPitself can do the necessary SSL and STARTTLS bits just fine since version 1.28, andNet::SMTP::SSLis now deprecated. Since 1.28 isn't that old yet, keep the old code in place and use it when necessary.While we're in the area, mark some messages for translation that were not yet marked as such.
Signed-off-by Dennis Kaarsemaker <[email protected]>--- git-send-email.perl | 54 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-)git-send-email.perl +35
-19@@ -1353,10 +1353,12 @@ EOF die __("The required SMTP server is not properly defined.") } + require Net::SMTP; + my $use_net_smtp_ssl = version->parse($Net::SMTP::VERSION) < version->parse("1.28"); + $smtp_domain ||= maildomain(); + if ($smtp_encryption eq 'ssl') { $smtp_server_port ||= 465; # ssmtp - require Net::SMTP::SSL; - $smtp_domain ||= maildomain(); require IO::Socket::SSL; # Suppress "variable accessed once" warning.@@ -1368,34 +1370,48 @@ EOF # Net::SMTP::SSL->new() does not forward any SSL options IO::Socket::SSL::set_client_defaults( ssl_verify_params()); - $smtp ||= Net::SMTP::SSL->new($smtp_server, - Hello => $smtp_domain, - Port => $smtp_server_port, - Debug => $debug_net_smtp); + + if ($use_net_smtp_ssl) { + require Net::SMTP::SSL; + $smtp ||= Net::SMTP::SSL->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp); + } + else { + $smtp ||= Net::SMTP->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp, + SSL => 1); + } } else { - require Net::SMTP; - $smtp_domain ||= maildomain(); $smtp_server_port ||= 25; $smtp ||= Net::SMTP->new($smtp_server, Hello => $smtp_domain, Debug => $debug_net_smtp, Port => $smtp_server_port); if ($smtp_encryption eq 'tls' && $smtp) { - require Net::SMTP::SSL; - $smtp->command('STARTTLS'); - $smtp->response(); - if ($smtp->code == 220) { + if ($use_net_smtp_ssl) { + $smtp->command('STARTTLS'); + $smtp->response(); + if ($smtp->code != 220) { + die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); + } + require Net::SMTP::SSL; $smtp = Net::SMTP::SSL->start_SSL($smtp, ssl_verify_params()) - or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); - $smtp_encryption = ''; - # Send EHLO again to receive fresh - # supported commands - $smtp->hello($smtp_domain); - } else { - die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); + or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr()); + } + else { + $smtp->starttls(ssl_verify_params()) + or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr()); } + $smtp_encryption = ''; + # Send EHLO again to receive fresh + # supported commands + $smtp->hello($smtp_domain); } }
Re: [PATCH v2] send-email: Net::SMTP::SSL is obsolete, use only when necessary
In reply to Dennis KaarsemakerQuoted 2 lines · Dennis Kaarsemaker
Second ping. This problem is not going away, so if this solution is not acceptable, I'd like to know what needs to be improved.
Perhaps you needed to actually test with older installation that people have, it seems, between pings. Immediately after this was merged to 'master', we start getting bug reports X-<.
Eric Biggers' message
https://public-inbox.org/git/<[email protected]>
seems to indicate that we should cut off at 3.01 not 1.28?
Thanks.
Quoted 20 lines · Dennis Kaarsemaker
Quoted 19 lines
Ping. It's a little over a month since I sent this, but I haven't seen any comments. Is this commit good to go?
Quoted 15 lines · Dennis Kaarsemaker
Net::SMTPitself can do the necessary SSL and STARTTLS bits just fine since version 1.28, andNet::SMTP::SSLis now deprecated. Since 1.28 isn't that old yet, keep the old code in place and use it when necessary.
...git-send-email.perl +2
-0@@ -1353,10 +1353,12 @@ EOF die __("The required SMTP server is not properly defined.") } + require Net::SMTP; + my $use_net_smtp_ssl = version->parse($Net::SMTP::VERSION) < version->parse("1.28");
Re: [PATCH v2] send-email: Net::SMTP::SSL is obsolete, use only when necessary
Quoted 9 lines · Junio C Hamano
Quoted 2 lines · Dennis Kaarsemaker
Second ping. This problem is not going away, so if this solution is not acceptable, I'd like to know what needs to be improved.
Perhaps you needed to actually test with older installation that people have, it seems, between pings. Immediately after this was merged to 'master', we start getting bug reports X-<.
Quoted 7 lines
Eric Biggers' message
https://public-inbox.org/git/<[email protected]>;
seems to indicate that we should cut off at 3.01 not 1.28?
Thanks.
Apologies for that. The version numbering of libnet is *weird*. The libnet version this was fixed in *is* 1.28, but the Net::SMTP module in
libnet version 1.28 has version 2.33.
I did test with some older perl versions, but not far enough back it seems :(
D.
Re: [PATCH v2] send-email: Net::SMTP::SSL is obsolete, use only when necessary
In reply to Dennis KaarsemakerHi,
Quoted 4 lines · Dennis Kaarsemaker
Net::SMTPitself can do the necessary SSL and STARTTLS bits just fine since version 1.28, andNet::SMTP::SSLis now deprecated. Since 1.28 isn't that old yet, keep the old code in place and use it when necessary.
This broke git send-email for me. The error message is
Can't locate object method "starttls" via package "Net::SMTP" at /usr/lib/git-core/git-send-email line 1410.
Is 1.28 the right minimum version?
$ perl -e 'require Net::SMTP; print version->parse($Net::SMTP::VERSION); print "\n"' 2.31 $ grep VERSION /usr/share/perl/5.18.2/Net/SMTP.pm use vars qw($VERSION @ISA); $VERSION = "2.31"; $ grep starttls /usr/share/perl/5.18.2/Net/SMTP.pm $ dpkg-query -W perl perl 5.18.2-2ubuntu1.1
Patch left unsnipped for reference.
Thanks,
Jonathan
Quoted 96 lines
While we're in the area, mark some messages for translation that were not yet marked as such.
Signed-off-by Dennis Kaarsemaker <[email protected]>--- git-send-email.perl | 54 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-)git-send-email.perl +35
-19@@ -1353,10 +1353,12 @@ EOF die __("The required SMTP server is not properly defined.") } + require Net::SMTP; + my $use_net_smtp_ssl = version->parse($Net::SMTP::VERSION) < version->parse("1.28"); + $smtp_domain ||= maildomain(); + if ($smtp_encryption eq 'ssl') { $smtp_server_port ||= 465; # ssmtp - require Net::SMTP::SSL; - $smtp_domain ||= maildomain(); require IO::Socket::SSL; # Suppress "variable accessed once" warning.@@ -1368,34 +1370,48 @@ EOF # Net::SMTP::SSL->new() does not forward any SSL options IO::Socket::SSL::set_client_defaults( ssl_verify_params()); - $smtp ||= Net::SMTP::SSL->new($smtp_server, - Hello => $smtp_domain, - Port => $smtp_server_port, - Debug => $debug_net_smtp); + + if ($use_net_smtp_ssl) { + require Net::SMTP::SSL; + $smtp ||= Net::SMTP::SSL->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp); + } + else { + $smtp ||= Net::SMTP->new($smtp_server, + Hello => $smtp_domain, + Port => $smtp_server_port, + Debug => $debug_net_smtp, + SSL => 1); + } } else { - require Net::SMTP; - $smtp_domain ||= maildomain(); $smtp_server_port ||= 25; $smtp ||= Net::SMTP->new($smtp_server, Hello => $smtp_domain, Debug => $debug_net_smtp, Port => $smtp_server_port); if ($smtp_encryption eq 'tls' && $smtp) { - require Net::SMTP::SSL; - $smtp->command('STARTTLS'); - $smtp->response(); - if ($smtp->code == 220) { + if ($use_net_smtp_ssl) { + $smtp->command('STARTTLS'); + $smtp->response(); + if ($smtp->code != 220) { + die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); + } + require Net::SMTP::SSL; $smtp = Net::SMTP::SSL->start_SSL($smtp, ssl_verify_params()) - or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); - $smtp_encryption = ''; - # Send EHLO again to receive fresh - # supported commands - $smtp->hello($smtp_domain); - } else { - die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message); + or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr()); + } + else { + $smtp->starttls(ssl_verify_params()) + or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr()); } + $smtp_encryption = ''; + # Send EHLO again to receive fresh + # supported commands + $smtp->hello($smtp_domain); } }Signature · 1 line
2.12.0-488-gd3584ba
Re: [PATCH v2] send-email: Net::SMTP::SSL is obsolete, use only when necessary
Quoted 13 lines · Jonathan Nieder
Quoted 4 lines · Dennis Kaarsemaker
Net::SMTPitself can do the necessary SSL and STARTTLS bits just fine since version 1.28, andNet::SMTP::SSLis now deprecated. Since 1.28 isn't that old yet, keep the old code in place and use it when necessary.This broke git send-email for me. The error message is
Can't locate object method "starttls" via package "
Net::SMTP" at/usr/lib/git-core/git-send-emailline 1410.Is 1.28 the right minimum version?
Quoted 9 lines
$ perl -e 'require Net::SMTP; print version->parse($Net::SMTP::VERSION); print "\n"' 2.31 $ grep VERSION /usr/share/perl/5.18.2/Net/SMTP.pm use vars qw($VERSION @ISA); $VERSION = "2.31"; $ grep starttls /usr/share/perl/5.18.2/Net/SMTP.pm $ dpkg-query -W perl perl 5.18.2-2ubuntu1.1
Thanks.
Let's revert the merge for now until we know (this time for certain) what the minimum version is.
Re: [PATCH v2] send-email: Net::SMTP::SSL is obsolete, use only when necessary
Hi,
Quoted 9 lines · Junio C Hamano
Quoted 7 lines · Jonathan Nieder
This broke git send-email for me. The error message is
Can't locate object method "starttls" via package "
Net::SMTP" at/usr/lib/git-core/git-send-emailline 1410.Is 1.28 the right minimum version?
$ perl -e 'require Net::SMTP; print version->parse($Net::SMTP::VERSION); print "\n"'
[...]
Quoted 8 lines
Quoted 3 lines
$ grep starttls /usr/share/perl/5.18.2/Net/SMTP.pm $ dpkg-query -W perl perl 5.18.2-2ubuntu1.1Thanks.
Let's revert the merge for now until we know (this time for certain) what the minimum version is.
Thanks. I just sent
http://public-inbox.org/git/[email protected]
in response to another thread. That uses 3.01 as minimum version, since it is the minimum version imported to core perl with starttls support.
I haven't tried testing with historical Net::SMTP versions, though. Is there a git repository available with all Net::SMTP versions from CPAN, or is https://perl5.git.perl.org/perl.git as good as it gets?
Regards,
Jonathan