summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sturmlechner <asturm@gentoo.org>2021-12-16 16:16:01 +0100
committerAndreas Sturmlechner <asturm@gentoo.org>2021-12-16 17:59:38 +0100
commitcecff9745ecabf06913db8b591b2832a856c7401 (patch)
tree51b1d7dca84fa14bf3d7f8924df632684d5765ec /kde-apps
parentsys-kernel/vanilla-sources: Linux version bump (diff)
downloadgentoo-cecff9745ecabf06913db8b591b2832a856c7401.tar.gz
gentoo-cecff9745ecabf06913db8b591b2832a856c7401.tar.bz2
gentoo-cecff9745ecabf06913db8b591b2832a856c7401.zip
kde-apps/kdepim-runtime: POP3: Fix SSL connections
See also: https://mail.kde.org/pipermail/distributions/2021-December/001099.html https://invent.kde.org/pim/kdepim-runtime/-/merge_requests/63 KDE-bug: https://bugs.kde.org/show_bug.cgi?id=446751 Package-Manager: Portage-3.0.30, Repoman-3.0.3 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
Diffstat (limited to 'kde-apps')
-rw-r--r--kde-apps/kdepim-runtime/files/kdepim-runtime-21.12.0-fix-pop3-ssl-connections.patch127
-rw-r--r--kde-apps/kdepim-runtime/kdepim-runtime-21.12.0-r1.ebuild88
2 files changed, 215 insertions, 0 deletions
diff --git a/kde-apps/kdepim-runtime/files/kdepim-runtime-21.12.0-fix-pop3-ssl-connections.patch b/kde-apps/kdepim-runtime/files/kdepim-runtime-21.12.0-fix-pop3-ssl-connections.patch
new file mode 100644
index 000000000000..e911588dbdcb
--- /dev/null
+++ b/kde-apps/kdepim-runtime/files/kdepim-runtime-21.12.0-fix-pop3-ssl-connections.patch
@@ -0,0 +1,127 @@
+From f14fabcefb45790175e209ef8ae394def4a805e9 Mon Sep 17 00:00:00 2001
+From: Albert Astals Cid <aacid@kde.org>
+Date: Fri, 10 Dec 2021 21:55:13 +0100
+Subject: [PATCH] POP3: Fix SSL connections
+
+We need to go into ssl before trying to read from the socket, otherwise
+nothing works
+
+BUGS: 446751
+---
+ resources/pop3/pop3protocol.cpp | 72 ++++++++++++++++++++-------------
+ resources/pop3/pop3protocol.h | 2 +
+ 2 files changed, 45 insertions(+), 29 deletions(-)
+
+diff --git a/resources/pop3/pop3protocol.cpp b/resources/pop3/pop3protocol.cpp
+index c2d01d33a..15971919e 100644
+--- a/resources/pop3/pop3protocol.cpp
++++ b/resources/pop3/pop3protocol.cpp
+@@ -535,6 +535,39 @@ Result POP3Protocol::loginPASS()
+ return Result::pass();
+ }
+
++Result POP3Protocol::startSsl()
++{
++ mSocket->ignoreSslErrors(); // Don't worry, errors are handled manually below
++ mSocket->startClientEncryption();
++ const bool encryptionStarted = mSocket->waitForEncrypted(s_connectTimeout);
++
++ const QSslCipher cipher = mSocket->sessionCipher();
++ const QList<QSslError> errors = mSocket->sslHandshakeErrors();
++ if (!encryptionStarted || !errors.isEmpty() || !mSocket->isEncrypted() || cipher.isNull() || cipher.usedBits() == 0) {
++ QString errorString = std::accumulate(errors.begin(), errors.end(), QString(), [](QString cur, const QSslError &error) {
++ if (!cur.isEmpty())
++ cur += QLatin1Char('\n');
++ cur += error.errorString();
++ return cur;
++ });
++
++ qCDebug(POP3_LOG) << "Initial SSL handshake failed. cipher.isNull() is" << cipher.isNull() << ", cipher.usedBits() is" << cipher.usedBits()
++ << ", the socket says:" << mSocket->errorString() << "and the SSL errors are:" << errorString;
++ mContinueAfterSslError = false;
++ Q_EMIT sslError(KSslErrorUiData(mSocket));
++ if (!mContinueAfterSslError) {
++ if (errorString.isEmpty())
++ errorString = mSocket->errorString();
++ qCDebug(POP3_LOG) << "TLS setup has failed. Aborting." << errorString;
++ closeConnection();
++ return Result::fail(ERR_SSL_FAILURE, i18n("SSL/TLS error: %1", errorString));
++ }
++ } else {
++ qCDebug(POP3_LOG) << "TLS has been enabled.";
++ }
++ return Result::pass();
++}
++
+ Result POP3Protocol::openConnection()
+ {
+ m_try_apop = mSettings.authenticationMethod() == MailTransport::Transport::EnumAuthenticationType::APOP;
+@@ -560,6 +593,13 @@ Result POP3Protocol::openConnection()
+ return Result::fail(mSocket->error(), errorString);
+ }
+
++ if (mSettings.useSSL()) {
++ const Result res = startSsl();
++ if (!res.success) {
++ return res;
++ }
++ }
++
+ mConnected = true;
+
+ greeting_buf = new char[GREETING_BUF_LEN];
+@@ -608,35 +648,9 @@ Result POP3Protocol::openConnection()
+ "was unsuccessful.\nYou can "
+ "disable TLS in the POP account settings dialog."));
+ }
+- }
+- if (mSettings.useSSL() || mSettings.useTLS()) {
+- mSocket->ignoreSslErrors(); // Don't worry, errors are handled manually below
+- mSocket->startClientEncryption();
+- const bool encryptionStarted = mSocket->waitForEncrypted(s_connectTimeout);
+-
+- const QSslCipher cipher = mSocket->sessionCipher();
+- const QList<QSslError> errors = mSocket->sslHandshakeErrors();
+- if (!encryptionStarted || !errors.isEmpty() || !mSocket->isEncrypted() || cipher.isNull() || cipher.usedBits() == 0) {
+- QString errorString = std::accumulate(errors.begin(), errors.end(), QString(), [](QString cur, const QSslError &error) {
+- if (!cur.isEmpty())
+- cur += QLatin1Char('\n');
+- cur += error.errorString();
+- return cur;
+- });
+-
+- qCDebug(POP3_LOG) << "Initial SSL handshake failed. cipher.isNull() is" << cipher.isNull() << ", cipher.usedBits() is" << cipher.usedBits()
+- << ", the socket says:" << mSocket->errorString() << "and the SSL errors are:" << errorString;
+- mContinueAfterSslError = false;
+- Q_EMIT sslError(KSslErrorUiData(mSocket));
+- if (!mContinueAfterSslError) {
+- if (errorString.isEmpty())
+- errorString = mSocket->errorString();
+- qCDebug(POP3_LOG) << "TLS setup has failed. Aborting." << errorString;
+- closeConnection();
+- return Result::fail(ERR_SSL_FAILURE, i18n("SSL/TLS error: %1", errorString));
+- }
+- } else {
+- qCDebug(POP3_LOG) << "TLS has been enabled.";
++ const Result res = startSsl();
++ if (!res.success) {
++ return res;
+ }
+ }
+
+diff --git a/resources/pop3/pop3protocol.h b/resources/pop3/pop3protocol.h
+index 9b40b334f..d01f7ab7a 100644
+--- a/resources/pop3/pop3protocol.h
++++ b/resources/pop3/pop3protocol.h
+@@ -127,6 +127,8 @@ private:
+ */
+ Q_REQUIRED_RESULT Result loginPASS();
+
++ Q_REQUIRED_RESULT Result startSsl();
++
+ const Settings &mSettings;
+ QSslSocket *const mSocket;
+ unsigned short int m_iPort;
+--
+GitLab
+
diff --git a/kde-apps/kdepim-runtime/kdepim-runtime-21.12.0-r1.ebuild b/kde-apps/kdepim-runtime/kdepim-runtime-21.12.0-r1.ebuild
new file mode 100644
index 000000000000..a66086cea67a
--- /dev/null
+++ b/kde-apps/kdepim-runtime/kdepim-runtime-21.12.0-r1.ebuild
@@ -0,0 +1,88 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+ECM_HANDBOOK="optional"
+ECM_TEST="forceoptional"
+PVCUT=$(ver_cut 1-3)
+KFMIN=5.88.0
+QTMIN=5.15.2
+VIRTUALX_REQUIRED="test"
+inherit ecm kde.org
+
+DESCRIPTION="Runtime plugin collection to extend the functionality of KDE PIM"
+HOMEPAGE="https://apps.kde.org/kontact/"
+
+LICENSE="GPL-2+ LGPL-2.1+"
+SLOT="5"
+KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86"
+IUSE="speech"
+
+RESTRICT="test"
+
+# TODO kolab
+RDEPEND="
+ >=app-crypt/qca-2.3.0:2
+ dev-libs/cyrus-sasl:2
+ dev-libs/libical:=
+ dev-libs/qtkeychain:=
+ >=dev-qt/qtdbus-${QTMIN}:5
+ >=dev-qt/qtgui-${QTMIN}:5
+ >=dev-qt/qtnetwork-${QTMIN}:5
+ >=dev-qt/qtnetworkauth-${QTMIN}:5
+ >=dev-qt/qtwebengine-${QTMIN}:5[widgets]
+ >=dev-qt/qtwidgets-${QTMIN}:5
+ >=dev-qt/qtxml-${QTMIN}:5
+ >=kde-apps/akonadi-${PVCUT}:5
+ >=kde-apps/akonadi-calendar-${PVCUT}:5
+ >=kde-apps/akonadi-contacts-${PVCUT}:5
+ >=kde-apps/akonadi-mime-${PVCUT}:5
+ >=kde-apps/akonadi-notes-${PVCUT}:5
+ >=kde-apps/kalarmcal-${PVCUT}:5
+ >=kde-apps/kcalutils-${PVCUT}:5
+ >=kde-apps/kidentitymanagement-${PVCUT}:5
+ >=kde-apps/kimap-${PVCUT}:5
+ >=kde-apps/kldap-${PVCUT}:5
+ >=kde-apps/kmailtransport-${PVCUT}:5
+ >=kde-apps/kmbox-${PVCUT}:5
+ >=kde-apps/kmime-${PVCUT}:5
+ >=kde-apps/libkdepim-${PVCUT}:5
+ >=kde-apps/libkgapi-${PVCUT}:5
+ >=kde-frameworks/kcalendarcore-${KFMIN}:5
+ >=kde-frameworks/kcmutils-${KFMIN}:5
+ >=kde-frameworks/kcodecs-${KFMIN}:5
+ >=kde-frameworks/kcompletion-${KFMIN}:5
+ >=kde-frameworks/kconfig-${KFMIN}:5
+ >=kde-frameworks/kconfigwidgets-${KFMIN}:5
+ >=kde-frameworks/kcontacts-${KFMIN}:5
+ >=kde-frameworks/kcoreaddons-${KFMIN}:5
+ >=kde-frameworks/kdav-${KFMIN}:5
+ >=kde-frameworks/kholidays-${KFMIN}:5
+ >=kde-frameworks/ki18n-${KFMIN}:5
+ >=kde-frameworks/kio-${KFMIN}:5
+ >=kde-frameworks/kitemmodels-${KFMIN}:5
+ >=kde-frameworks/kjobwidgets-${KFMIN}:5
+ >=kde-frameworks/knotifications-${KFMIN}:5
+ >=kde-frameworks/knotifyconfig-${KFMIN}:5
+ >=kde-frameworks/kservice-${KFMIN}:5
+ >=kde-frameworks/ktextwidgets-${KFMIN}:5
+ >=kde-frameworks/kwidgetsaddons-${KFMIN}:5
+ >=kde-frameworks/kwindowsystem-${KFMIN}:5
+ >=kde-frameworks/kxmlgui-${KFMIN}:5
+ speech? ( >=dev-qt/qtspeech-${QTMIN}:5 )
+"
+DEPEND="${RDEPEND}
+ >=dev-qt/qtxmlpatterns-${QTMIN}:5
+ test? ( >=kde-apps/kimap-${PVCUT}:5[test] )
+"
+
+PATCHES=( "${FILESDIR}"/${P}-fix-pop3-ssl-connections.patch )
+
+src_configure() {
+ local mycmakeargs=(
+ -DCMAKE_DISABLE_FIND_PACKAGE_Libkolabxml=ON
+ $(cmake_use_find_package speech Qt5TextToSpeech)
+ )
+ ecm_src_configure
+}