From 89bd4eb6c764480ff5301691cdbb689ffd45fce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 11 Oct 2020 22:20:54 +0100 Subject: [PATCH] Store successful polkit authentication requests. We need this to avoid multiple authentication requests when applying long operations. Otherwise, the user will have to authenticate after each job, which can mean up to 4 password dialogs for some longer operations. --- src/util/externalcommandhelper.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp index 8cede39..c874d3b 100644 --- a/src/util/externalcommandhelper.cpp +++ b/src/util/externalcommandhelper.cpp @@ -333,9 +333,11 @@ bool ExternalCommandHelper::isCallerAuthorized() return false; } - // track who called into us so we can close when all callers have gone away - // this has to happen before authorisation as anyone could have activated us - m_serviceWatcher->addWatchedService(message().service()); + // Cache successful authentication requests, so that clients don't need + // to authenticate multiple times during long partitioning operations. + if (m_serviceWatcher->watchedServices().contains(message().service())) { + return true; + } PolkitQt1::SystemBusNameSubject subject(message().service()); PolkitQt1::Authority *authority = PolkitQt1::Authority::instance(); @@ -357,9 +359,13 @@ bool ExternalCommandHelper::isCallerAuthorized() switch (result) { case PolkitQt1::Authority::Yes: + // track who called into us so we can close when all callers have gone away + m_serviceWatcher->addWatchedService(message().service()); return true; default: sendErrorReply(QDBusError::AccessDenied); + if (m_serviceWatcher->watchedServices().isEmpty()) + qApp->quit(); return false; } }