From 5cd906e4f95b5c7de23a81b0adcb54d8d118b35a Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sat, 9 Sep 2023 04:10:56 +0300 Subject: [PATCH] kdecore: do not call the helper asynchronously from KAuthorization::execute() racy-racy.. Signed-off-by: Ivailo Monev --- kdecore/kernel/kauthorization.cpp | 10 +++------- kdecore/kernel/kauthorization.h | 1 + 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/kdecore/kernel/kauthorization.cpp b/kdecore/kernel/kauthorization.cpp index 9fff169e..d4058229 100644 --- a/kdecore/kernel/kauthorization.cpp +++ b/kdecore/kernel/kauthorization.cpp @@ -37,6 +37,7 @@ // see kdebug.areas static const int s_kauthorizationarea = 185; +static const qint64 s_servicetimeout = 30000; void kAuthMessageHandler(QtMsgType type, const char *msg) { @@ -160,12 +161,7 @@ int KAuthorization::execute(const QString &helper, const QString &method, const helper, QString::fromLatin1("/KAuthorization"), QString::fromLatin1("org.kde.kauthorization"), QDBusConnection::systemBus() ); - QDBusPendingReply reply = kauthorizationinterface.asyncCall(QString::fromLatin1("execute"), method, arguments); - kDebug(s_kauthorizationarea) << "Waiting for service call to finish" << helper; - while (!reply.isFinished()) { - QCoreApplication::processEvents(QEventLoop::AllEvents, KAUTHORIZATION_TIMEOUT); - } - kDebug(s_kauthorizationarea) << "Done waiting for service call to finish" << helper; + QDBusReply reply = kauthorizationinterface.call(QString::fromLatin1("execute"), method, arguments); int result = KAuthorization::NoError; if (!reply.isValid()) { result = KAuthorization::DBusError; @@ -221,7 +217,7 @@ void KAuthorization::helperMain(const char* const helper, KAuthorization *object } // in case the process executing the helper crashes - QTimer::singleShot(30000, qApp, SLOT(quit())); + QTimer::singleShot(s_servicetimeout, qApp, SLOT(quit())); } #include "kauthorization.moc" diff --git a/kdecore/kernel/kauthorization.h b/kdecore/kernel/kauthorization.h index b376e936..686ad61a 100644 --- a/kdecore/kernel/kauthorization.h +++ b/kdecore/kernel/kauthorization.h @@ -70,6 +70,7 @@ } @endcode + @warning the helper has failsafe - after 30sec it will exit unconditionally! @since 4.22 */ class KDECORE_EXPORT KAuthorization : public QObject