[PATCH v2] send-email: auth plain/login fix
- From
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
- Date
- Sep 27, 2011, 21:36 UTC
- Message-ID
- <1317159419-23166-1-git-send-email-zbyszek@in.waw.pl>
- In-Reply-To
- <m3fwjjp69m.fsf@localhost.localdomain>
git send-email was not authenticating properly when communicating over TLS with a server supporting only AUTH PLAIN and AUTH LOGIN. This is e.g. the standard server setup under debian with exim4 and probably everywhere where system accounts are used.
The solution comes from this forum thread: http://www.perlmonks.org/?node_id=904354
This patch is tested by sending it :)
Before: Net::SMTP>>> Net::SMTP(2.31) Net::SMTP>>> Net::Cmd(2.29) Net::SMTP>>> Exporter(5.64_01) Net::SMTP>>> IO::Socket::INET(1.31) Net::SMTP>>> IO::Socket(1.31) Net::SMTP>>> IO::Handle(1.28) ... Net::SMTP=GLOB(0x238f668)>>> STARTTLS Net::SMTP=GLOB(0x238f668)<<< 220 2.0.0 Ready to start TLS Net::SMTP::SSL=GLOB(0x238f668)>>> EHLO localhost.localdomain Net::SMTP::SSL=GLOB(0x238f668)<<< 250-yyy.yyy.yyy Hello xxx.xxx [xxx.xxx.xxx.xxx], pleased to meet you Net::SMTP::SSL=GLOB(0x238f668)<<< 250-ENHANCEDSTATUSCODES Net::SMTP::SSL=GLOB(0x238f668)<<< 250-PIPELINING Net::SMTP::SSL=GLOB(0x238f668)<<< 250-8BITMIME Net::SMTP::SSL=GLOB(0x238f668)<<< 250-SIZE 80000000 Net::SMTP::SSL=GLOB(0x238f668)<<< 250-DSN Net::SMTP::SSL=GLOB(0x238f668)<<< 250-AUTH=LOGIN PLAIN Net::SMTP::SSL=GLOB(0x238f668)<<< 250-AUTH LOGIN PLAIN Net::SMTP::SSL=GLOB(0x238f668)<<< 250-DELIVERBY Net::SMTP::SSL=GLOB(0x238f668)<<< 250 HELP Password: Net::SMTP::SSL=GLOB(0x238f668)>>> AUTH Net::SMTP::SSL=GLOB(0x238f668)<<< 501 5.5.2 AUTH mechanism must be specified 5.5.2 AUTH mechanism must be specified
After: Net::SMTP=GLOB(0x1ac4a60)>>> STARTTLS Net::SMTP=GLOB(0x1ac4a60)<<< 220 2.0.0 Ready to start TLS Net::SMTP::SSL=GLOB(0x1ac4a60)>>> EHLO localhost.localdomain Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 250-yyy.yyy.yyy Hello xxx.xxx [xxx.xxx.xxx.xxx], pleased to meet you Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 250-ENHANCEDSTATUSCODES Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 250-PIPELINING Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 250-8BITMIME Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 250-SIZE 80000000 Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 250-DSN Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 250-AUTH=LOGIN PLAIN Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 250-AUTH LOGIN PLAIN Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 250-DELIVERBY Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 250 HELP Password: Net::SMTP::SSL=GLOB(0x1ac4a60)>>> AUTH LOGIN Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 334 VXNlcm5hbWU6 Net::SMTP::SSL=GLOB(0x1ac4a60)>>> emJ5c3plaw== Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 334 UGFzc3dvcmQ6 Net::SMTP::SSL=GLOB(0x1ac4a60)>>> dGVzdA== Net::SMTP::SSL=GLOB(0x1ac4a60)<<< 535 5.7.0 authentication failed 5.7.0 authentication failed
The password is incorrect in this snippet, but the protocol works correctly.
Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
---
v2: - added sign-off as requested, although the patch is as trivial
as it gets
- the import is performed only if it will be usedgit-send-email.perl | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl index 37dfbe7..5a22d18 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -1098,6 +1098,8 @@ X-Mailer: git-send-email $gitversion } if (defined $smtp_authuser) { + require Authen::SASL; + Authen::SASL->import(qw(Perl)); if (!defined $smtp_authpass) {
-- 1.7.6