[kde-runtime] - backport kwallet synchronous mode fix (kde#254198)
Rex Dieter
rdieter at fedoraproject.org
Tue Sep 3 20:48:34 UTC 2013
commit f0d8ff7d29f71e20fc4c356682f12a179a9ebfb1
Author: Rex Dieter <rdieter at math.unl.edu>
Date: Tue Sep 3 15:48:24 2013 -0500
- backport kwallet synchronous mode fix (kde#254198)
Fix-the-synchronous-mode-wallet-open-logic.patch | 323 ++++++++++++++++++++++
kde-runtime.spec | 6 +-
2 files changed, 328 insertions(+), 1 deletions(-)
---
diff --git a/Fix-the-synchronous-mode-wallet-open-logic.patch b/Fix-the-synchronous-mode-wallet-open-logic.patch
new file mode 100644
index 0000000..ff94d2d
--- /dev/null
+++ b/Fix-the-synchronous-mode-wallet-open-logic.patch
@@ -0,0 +1,323 @@
+From b0f9053ed8abff4ef973b10842f761422ee17f41 Mon Sep 17 00:00:00 2001
+From: Valentin Rusu <kde at rusu.info>
+Date: Sun, 1 Sep 2013 01:28:09 +0200
+Subject: [PATCH 1/3] Fix the synchronous-mode wallet open logic
+
+BUG: 254198
+
+The wallet synchronous open requests now use qdbus delayed replies.
+The execution path now returns to the main event loop instead of
+a nested event loop. The wallet opening UI logic is correctly handled
+no longer leading to a frozen kwalletd.
+
+Beware that this commit should be used along with the corresponding
+fix of the kdelibs/kdeui module. Failing to updating kdelibs lead to
+an aparently similar freeze condition, as kdeui also used an internal
+event loop, faking synchronous operation when making async kwalletd calls.
+---
+ kwalletd/CMakeLists.txt | 1 -
+ kwalletd/kwalletd.cpp | 74 +++++++++++++++++++++++++++++++-------------
+ kwalletd/kwalletopenloop.cpp | 46 ---------------------------
+ kwalletd/kwalletopenloop.h | 50 ------------------------------
+ kwalletd/main.cpp | 1 +
+ 5 files changed, 54 insertions(+), 118 deletions(-)
+ delete mode 100644 kwalletd/kwalletopenloop.cpp
+ delete mode 100644 kwalletd/kwalletopenloop.h
+
+diff --git a/kwalletd/CMakeLists.txt b/kwalletd/CMakeLists.txt
+index e668f58..d421233 100644
+--- a/kwalletd/CMakeLists.txt
++++ b/kwalletd/CMakeLists.txt
+@@ -12,7 +12,6 @@ set(kwalletd_KDEINIT_SRCS
+ main.cpp
+ kbetterthankdialog.cpp
+ kwalletd.cpp
+- kwalletopenloop.cpp
+ kwalletwizard.cpp
+ ktimeout.cpp
+ kwalletsessionstore.cpp
+diff --git a/kwalletd/kwalletd.cpp b/kwalletd/kwalletd.cpp
+index b940fd1..35bbeda 100644
+--- a/kwalletd/kwalletd.cpp
++++ b/kwalletd/kwalletd.cpp
+@@ -55,13 +55,12 @@
+ #include <assert.h>
+
+ #include "kwalletadaptor.h"
+-#include "kwalletopenloop.h"
+
+ class KWalletTransaction {
+
+ public:
+- KWalletTransaction()
+- : tType(Unknown), cancelled(false), tId(nextTransactionId)
++ explicit KWalletTransaction(QDBusConnection conn)
++ : tType(Unknown), cancelled(false), tId(nextTransactionId), res(-1), connection(conn)
+ {
+ nextTransactionId++;
+ // make sure the id is never < 0 as that's used for the
+@@ -90,6 +89,9 @@ class KWalletTransaction {
+ bool modal;
+ bool isPath;
+ int tId; // transaction id
++ int res;
++ QDBusMessage message;
++ QDBusConnection connection;
+
+ private:
+ static int nextTransactionId;
+@@ -198,7 +200,7 @@ void KWalletD::processTransactions() {
+ } else if (_curtrans->cancelled) {
+ // the wallet opened successfully but the application
+ // opening exited/crashed while the dialog was still shown.
+- KWalletTransaction *_xact = new KWalletTransaction();
++ KWalletTransaction *_xact = new KWalletTransaction(_curtrans->connection);
+ _xact->tType = KWalletTransaction::CloseCancelled;
+ _xact->appid = _curtrans->appid;
+ _xact->wallet = _curtrans->wallet;
+@@ -207,11 +209,13 @@ void KWalletD::processTransactions() {
+ }
+
+ // emit the AsyncOpened signal as a reply
++ _curtrans->res = res;
+ emit walletAsyncOpened(_curtrans->tId, res);
+ break;
+
+ case KWalletTransaction::OpenFail:
+ // emit the AsyncOpened signal with an invalid handle
++ _curtrans->res = -1;
+ emit walletAsyncOpened(_curtrans->tId, -1);
+ break;
+
+@@ -230,6 +234,15 @@ void KWalletD::processTransactions() {
+ break;
+ }
+
++ // send delayed dbus message reply to the caller
++ if (_curtrans->message.type() != QDBusMessage::InvalidMessage) {
++ if (_curtrans->connection.isConnected()) {
++ QDBusMessage reply = _curtrans->message.createReply();
++ reply << _curtrans->res;
++ _curtrans->connection.send(reply);
++ }
++ }
++
+ delete _curtrans;
+ _curtrans = 0;
+ }
+@@ -237,28 +250,45 @@ void KWalletD::processTransactions() {
+ _processing = false;
+ }
+
+-
+-
+ int KWalletD::openPath(const QString& path, qlonglong wId, const QString& appid) {
+ int tId = openPathAsync(path, wId, appid, false);
+ if (tId < 0) {
+ return tId;
+ }
+
++ // NOTE the real return value will be sent by the dbusmessage delayed reply
++ return 0;
+ // wait for the open-transaction to be processed
+- KWalletOpenLoop loop(this);
+- return loop.waitForAsyncOpen(tId);
++// KWalletOpenLoop loop(this);
++// return loop.waitForAsyncOpen(tId);
+ }
+
+ int KWalletD::open(const QString& wallet, qlonglong wId, const QString& appid) {
+- int tId = openAsync(wallet, wId, appid, false);
+- if (tId < 0) {
+- return tId;
+- }
++ if (!_enabled) { // guard
++ return -1;
++ }
+
+- // wait for the open-transaction to be processed
+- KWalletOpenLoop loop(this);
+- return loop.waitForAsyncOpen(tId);
++ if (!QRegExp("^[\\w\\^\\&\\'\\@\\{\\}\\[\\]\\,\\$\\=\\!\\-\\#\\(\\)\\%\\.\\+\\_\\s]+$").exactMatch(wallet)) {
++ return -1;
++ }
++
++ KWalletTransaction *xact = new KWalletTransaction(connection());
++ _transactions.append(xact);
++
++ message().setDelayedReply(true);
++ xact->message = message();
++
++ xact->appid = appid;
++ xact->wallet = wallet;
++ xact->wId = wId;
++ xact->modal = true; // mark dialogs as modal, the app has blocking wait
++ xact->tType = KWalletTransaction::Open;
++ xact->isPath = false;
++
++ QTimer::singleShot(0, this, SLOT(processTransactions()));
++ checkActiveDialog();
++ // NOTE the real return value will be sent by the dbusmessage delayed reply
++ return 0;
+ }
+
+ int KWalletD::openAsync(const QString& wallet, qlonglong wId, const QString& appid,
+@@ -271,8 +301,8 @@ int KWalletD::openAsync(const QString& wallet, qlonglong wId, const QString& app
+ return -1;
+ }
+
+- KWalletTransaction *xact = new KWalletTransaction;
+- _transactions.append(xact);
++ KWalletTransaction *xact = new KWalletTransaction(connection());
++ _transactions.append(xact);
+
+ xact->appid = appid;
+ xact->wallet = wallet;
+@@ -298,8 +328,8 @@ int KWalletD::openPathAsync(const QString& path, qlonglong wId, const QString& a
+ return -1;
+ }
+
+- KWalletTransaction *xact = new KWalletTransaction;
+- _transactions.append(xact);
++ KWalletTransaction *xact = new KWalletTransaction(connection());
++ _transactions.append(xact);
+
+ xact->appid = appid;
+ xact->wallet = path;
+@@ -674,9 +704,11 @@ int KWalletD::deleteWallet(const QString& wallet) {
+
+
+ void KWalletD::changePassword(const QString& wallet, qlonglong wId, const QString& appid) {
+- KWalletTransaction *xact = new KWalletTransaction;
++ KWalletTransaction *xact = new KWalletTransaction(connection());
++
++ message().setDelayedReply(true);
++ xact->message = message();
+
+- //msg.setDelayedReply(true);
+ xact->appid = appid;
+ xact->wallet = wallet;
+ xact->wId = wId;
+diff --git a/kwalletd/kwalletopenloop.cpp b/kwalletd/kwalletopenloop.cpp
+deleted file mode 100644
+index 39d3901..0000000
+--- a/kwalletd/kwalletopenloop.cpp
++++ /dev/null
+@@ -1,46 +0,0 @@
+-// -*- indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*-
+-/*
+- This file is part of the KDE libraries
+-
+- Copyright (c) 2008 Michael Leupold <lemma at confuego.org>
+-
+- This library is free software; you can redistribute it and/or
+- modify it under the terms of the GNU Library General Public
+- License as published by the Free Software Foundation; either
+- version 2 of the License, or (at your option) any later version.
+-
+- This library is distributed in the hope that it will be useful,
+- but WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- Library General Public License for more details.
+-
+- You should have received a copy of the GNU Library General Public License
+- along with this library; see the file COPYING.LIB. If not, write to
+- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+- Boston, MA 02110-1301, USA.
+-
+-*/
+-
+-#include "kwalletopenloop.h"
+-#include "kwalletd.h"
+-
+-int KWalletOpenLoop::waitForAsyncOpen(int tId)
+-{
+- transaction = tId;
+- connect(wallet, SIGNAL(walletAsyncOpened(int, int)),
+- SLOT(walletAsyncOpened(int, int)));
+- exec();
+- disconnect(this, SLOT(walletAsyncOpened(int, int)));
+- return result;
+-}
+-
+-void KWalletOpenLoop::walletAsyncOpened(int tId, int handle)
+-{
+- // if our transaction finished, stop waiting
+- if (tId == transaction) {
+- result = handle;
+- quit();
+- }
+-}
+-
+-#include "kwalletopenloop.moc"
+diff --git a/kwalletd/kwalletopenloop.h b/kwalletd/kwalletopenloop.h
+deleted file mode 100644
+index 55c5139..0000000
+--- a/kwalletd/kwalletopenloop.h
++++ /dev/null
+@@ -1,50 +0,0 @@
+-// -*- indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*-
+-/*
+- This file is part of the KDE libraries
+-
+- Copyright (c) 2008 Michael Leupold <lemma at confuego.org>
+-
+- This library is free software; you can redistribute it and/or
+- modify it under the terms of the GNU Library General Public
+- License as published by the Free Software Foundation; either
+- version 2 of the License, or (at your option) any later version.
+-
+- This library is distributed in the hope that it will be useful,
+- but WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- Library General Public License for more details.
+-
+- You should have received a copy of the GNU Library General Public License
+- along with this library; see the file COPYING.LIB. If not, write to
+- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+- Boston, MA 02110-1301, USA.
+-
+-*/
+-
+-#ifndef KWALLETOPENLOOP_H
+-#define KWALLETOPENLOOP_H
+-
+-#include <QtCore/QEventLoop>
+-
+-class KWalletD;
+-
+-class KWalletOpenLoop : public QEventLoop {
+- Q_OBJECT
+-
+- public:
+- explicit KWalletOpenLoop(KWalletD* w, QObject* parent = 0)
+- : QEventLoop(parent), wallet(w) {}
+-
+- // returns the open handle
+- int waitForAsyncOpen(int tId);
+-
+- public slots:
+- void walletAsyncOpened(int tId, int handle);
+-
+- private:
+- KWalletD* wallet;
+- int transaction;
+- int result;
+-};
+-
+-#endif
+diff --git a/kwalletd/main.cpp b/kwalletd/main.cpp
+index 5b4455e..0a5be89 100644
+--- a/kwalletd/main.cpp
++++ b/kwalletd/main.cpp
+@@ -65,6 +65,7 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
+ return (0);
+ }
+
++ kDebug() << "kwalletd started";
+ KWalletD walletd;
+ return app.exec();
+ }
+--
+1.8.3.1
+
diff --git a/kde-runtime.spec b/kde-runtime.spec
index f0464a4..753999f 100644
--- a/kde-runtime.spec
+++ b/kde-runtime.spec
@@ -6,7 +6,7 @@
Name: kde-runtime
Summary: KDE Runtime
Version: 4.11.1
-Release: 0.1%{?dist}
+Release: 1%{?dist}
# http://techbase.kde.org/Policies/Licensing_Policy
License: LGPLv2+ and GPLv2+
@@ -63,6 +63,8 @@ Patch52: kde-runtime-mouseeventlistener.patch
Patch53: kde-runtime-initial_passwordless_kwallet_option.patch
## upstream patches
+# https://bugs.kde.org/show_bug.cgi?id=254198
+Patch100: Fix-the-synchronous-mode-wallet-open-logic.patch
# rhel patches
Patch300: kde-runtime-4.9.2-webkit.patch
@@ -201,6 +203,7 @@ Requires: %{name} = %{version}-%{release}
%patch51 -p1 -b .mouseeventlistener-1
%patch52 -p1 -b .mouseeventlistener
%patch53 -p1 -b .initial_passwordless_kwallet_option
+%patch100 -p1 -b .Fix-the-synchronous-mode-wallet-open-logic
%if ! 0%{?webkit}
%patch300 -p1 -b .webkit
@@ -420,6 +423,7 @@ fi
%changelog
* Tue Sep 03 2013 Rex Dieter <rdieter at fedoraproject.org> 4.11.1-1
- 4.11.1
+- backport kwallet synchronous mode fix (kde#254198)
* Thu Aug 08 2013 Than Ngo <than at redhat.com> - 4.11.0-1
- 4.11.0
More information about the scm-commits
mailing list