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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// track who called into us so we can close when all callers have gone away
|
// Cache successful authentication requests, so that clients don't need
|
||||||
// this has to happen before authorisation as anyone could have activated us
|
// to authenticate multiple times during long partitioning operations.
|
||||||
m_serviceWatcher->addWatchedService(message().service());
|
if (m_serviceWatcher->watchedServices().contains(message().service())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
PolkitQt1::SystemBusNameSubject subject(message().service());
|
PolkitQt1::SystemBusNameSubject subject(message().service());
|
||||||
PolkitQt1::Authority *authority = PolkitQt1::Authority::instance();
|
PolkitQt1::Authority *authority = PolkitQt1::Authority::instance();
|
||||||
|
@ -357,9 +359,13 @@ bool ExternalCommandHelper::isCallerAuthorized()
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case PolkitQt1::Authority::Yes:
|
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;
|
return true;
|
||||||
default:
|
default:
|
||||||
sendErrorReply(QDBusError::AccessDenied);
|
sendErrorReply(QDBusError::AccessDenied);
|
||||||
|
if (m_serviceWatcher->watchedServices().isEmpty())
|
||||||
|
qApp->quit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue