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.
This commit is contained in:
parent
424c8f0bf0
commit
89bd4eb6c7
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue