From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-992342-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id DE5E1139083
	for <garchives@archives.gentoo.org>; Fri, 22 Dec 2017 13:49:27 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 12880E0F1A;
	Fri, 22 Dec 2017 13:49:27 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id D8F43E0F1A
	for <gentoo-commits@lists.gentoo.org>; Fri, 22 Dec 2017 13:49:26 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 7E3C1341236
	for <gentoo-commits@lists.gentoo.org>; Fri, 22 Dec 2017 13:49:25 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 01C20AE7E
	for <gentoo-commits@lists.gentoo.org>; Fri, 22 Dec 2017 13:49:24 +0000 (UTC)
From: "Andreas Sturmlechner" <asturm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Andreas Sturmlechner" <asturm@gentoo.org>
Message-ID: <1513950550.4d8f371deba438789b34ca5c0ca8b5f5afa52fe2.asturm@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: kde-apps/ksmtp/, kde-apps/ksmtp/files/
X-VCS-Repository: repo/gentoo
X-VCS-Files: kde-apps/ksmtp/files/ksmtp-17.12.0-ehlo-auth-fix.patch kde-apps/ksmtp/ksmtp-17.12.0-r1.ebuild
X-VCS-Directories: kde-apps/ksmtp/ kde-apps/ksmtp/files/
X-VCS-Committer: asturm
X-VCS-Committer-Name: Andreas Sturmlechner
X-VCS-Revision: 4d8f371deba438789b34ca5c0ca8b5f5afa52fe2
X-VCS-Branch: master
Date: Fri, 22 Dec 2017 13:49:24 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 90c6de2c-e90e-45f8-9522-ff8125014cdc
X-Archives-Hash: 4a49637596330f8fa48319c33801d234

commit:     4d8f371deba438789b34ca5c0ca8b5f5afa52fe2
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 22 13:41:08 2017 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Fri Dec 22 13:49:10 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4d8f371d

kde-apps/ksmtp: Fix EHLO double auth

See also: https://phabricator.kde.org/D9476
KDE-Bug: https://bugs.kde.org/show_bug.cgi?id=388068
Package-Manager: Portage-2.3.13, Repoman-2.3.4

 .../ksmtp/files/ksmtp-17.12.0-ehlo-auth-fix.patch  | 108 +++++++++++++++++++++
 kde-apps/ksmtp/ksmtp-17.12.0-r1.ebuild             |  24 +++++
 2 files changed, 132 insertions(+)

diff --git a/kde-apps/ksmtp/files/ksmtp-17.12.0-ehlo-auth-fix.patch b/kde-apps/ksmtp/files/ksmtp-17.12.0-ehlo-auth-fix.patch
new file mode 100644
index 00000000000..903bfe0d114
--- /dev/null
+++ b/kde-apps/ksmtp/files/ksmtp-17.12.0-ehlo-auth-fix.patch
@@ -0,0 +1,108 @@
+From 4564d77d3c644a7d1f99749c4e934969b4e21952 Mon Sep 17 00:00:00 2001
+From: Fabian Vogt <fabian@ritter-vogt.de>
+Date: Fri, 22 Dec 2017 14:22:49 +0100
+Subject: [PATCH] Fix duplicate authentication
+
+Summary:
+The response to EHLO triggers an authentication command, but with TLS
+two EHLOs are sent: For the 220 from the server and after TLS negotiation.
+However, sending it twice results in an unexpected "503 already authenticated"
+response which ends up getting parsed by the SendJob, causing confusion.
+
+BUG: 387926
+BUG: 388068
+
+Reviewers: mlaurent, dvratil
+
+Subscribers: rdieter, heikobecker, asn, #kde_pim, lbeltrame, cgiboudeaux
+
+Tags: #kde_pim
+
+Differential Revision: https://phabricator.kde.org/D9476
+---
+ src/session.cpp       | 29 +++++++++++++++++++----------
+ src/session_p.h       |  1 +
+ src/sessionthread.cpp |  1 -
+ 3 files changed, 20 insertions(+), 11 deletions(-)
+
+diff --git a/src/session.cpp b/src/session.cpp
+index 861419d..4320adc 100644
+--- a/src/session.cpp
++++ b/src/session.cpp
+@@ -80,6 +80,19 @@ void SessionPrivate::setAuthenticationMethods(const QList<QByteArray> &authMetho
+     }
+ }
+ 
++void SessionPrivate::startHandshake()
++{
++    QByteArray cmd;
++    if (!m_ehloRejected) {
++         cmd = "EHLO ";
++    } else {
++         cmd = "HELO ";
++    }
++    setState(Session::Handshake);
++    const auto hostname = m_customHostname.isEmpty() ? m_thread->hostName() : m_customHostname;
++    sendData(cmd + QUrl::toAce(hostname));
++}
++
+ 
+ 
+ Session::Session(const QString &hostName, quint16 port, QObject *parent)
+@@ -277,15 +290,7 @@ void SessionPrivate::responseReceived(const ServerResponse &r)
+ 
+     if (m_state == Session::Ready) {
+         if (r.isCode(22) || m_ehloRejected) {
+-            QByteArray cmd;
+-            if (!m_ehloRejected) {
+-                cmd = "EHLO ";
+-            } else {
+-                cmd = "HELO ";
+-            }
+-            setState(Session::Handshake);
+-            const auto hostname = m_customHostname.isEmpty() ? m_thread->hostName() : m_customHostname;
+-            sendData(cmd + QUrl::toAce(hostname));
++            startHandshake();
+             return;
+         }
+     }
+@@ -346,7 +351,11 @@ KTcpSocket::SslVersion SessionPrivate::negotiatedEncryption() const
+ 
+ void SessionPrivate::encryptionNegotiationResult(bool encrypted, KTcpSocket::SslVersion version)
+ {
+-    Q_UNUSED(encrypted);
++    if (encrypted) {
++        // Get the updated auth methods
++        startHandshake();
++    }
++
+     m_sslVersion = version;
+ }
+ 
+diff --git a/src/session_p.h b/src/session_p.h
+index 875f7be..90151f6 100644
+--- a/src/session_p.h
++++ b/src/session_p.h
+@@ -73,6 +73,7 @@ private Q_SLOTS:
+ 
+ private:
+ 
++    void startHandshake();
+     void startNext();
+     void startSocketTimer();
+     void stopSocketTimer();
+diff --git a/src/sessionthread.cpp b/src/sessionthread.cpp
+index 1e4db8b..c195826 100644
+--- a/src/sessionthread.cpp
++++ b/src/sessionthread.cpp
+@@ -223,7 +223,6 @@ void SessionThread::sslConnected()
+     } else {
+         qCDebug(KSMTP_LOG) << "TLS negotiation done.";
+ 
+-        QMetaObject::invokeMethod(this, "sendData", Qt::QueuedConnection, Q_ARG(QByteArray, "EHLO " + QUrl::toAce(hostName())));
+         Q_EMIT encryptionNegotiationResult(true, m_socket->negotiatedSslVersion());
+     }
+ }
+-- 
+2.13.6
+

diff --git a/kde-apps/ksmtp/ksmtp-17.12.0-r1.ebuild b/kde-apps/ksmtp/ksmtp-17.12.0-r1.ebuild
new file mode 100644
index 00000000000..b9a34c04f0e
--- /dev/null
+++ b/kde-apps/ksmtp/ksmtp-17.12.0-r1.ebuild
@@ -0,0 +1,24 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+KDE_TEST="true"
+inherit kde5
+
+DESCRIPTION="Job-based library to send email through an SMTP server"
+LICENSE="LGPL-2.1+"
+KEYWORDS="~amd64 ~x86"
+IUSE=""
+
+DEPEND="
+	$(add_frameworks_dep kcoreaddons)
+	$(add_frameworks_dep ki18n)
+	$(add_frameworks_dep kio)
+	$(add_kdeapps_dep kmime)
+	$(add_qt_dep qtnetwork)
+	dev-libs/cyrus-sasl
+"
+RDEPEND="${DEPEND}"
+
+PATCHES=( "${FILESDIR}/${P}-ehlo-auth-fix.patch" )