diff --git a/src/core/slavebase.h b/src/core/slavebase.h --- a/src/core/slavebase.h +++ b/src/core/slavebase.h @@ -943,6 +943,15 @@ */ PrivilegeOperationStatus requestPrivilegeOperation(); + /** + * Adds @p action to the list of PolicyKit actions which the + * slave is authorized to perform. + * + * @param action the PolicyKit action + * @since 5.45 + */ + void addTemporaryAuthorization(const QString &action); + protected: /** * Name of the protocol supported by this slave diff --git a/src/core/slavebase.cpp b/src/core/slavebase.cpp --- a/src/core/slavebase.cpp +++ b/src/core/slavebase.cpp @@ -123,6 +123,7 @@ bool m_rootEntryListed = false; bool m_confirmationAsked; + QSet m_tempAuths; QString m_warningCaption; QString m_warningMessage; int m_privilegeOperationStatus; @@ -1499,3 +1500,8 @@ return KIO::PrivilegeOperationStatus(d->m_privilegeOperationStatus); } + +void SlaveBase::addTemporaryAuthorization(const QString &action) +{ + d->m_tempAuths.insert(action); +} diff --git a/src/ioslaves/file/file_unix.cpp b/src/ioslaves/file/file_unix.cpp --- a/src/ioslaves/file/file_unix.cpp +++ b/src/ioslaves/file/file_unix.cpp @@ -847,15 +847,17 @@ out << arg; } - KAuth::Action execAction(QStringLiteral("org.kde.kio.file.exec")); + const QString actionId = QStringLiteral("org.kde.kio.file.exec"); + KAuth::Action execAction(actionId); execAction.setHelperId(QStringLiteral("org.kde.kio.file")); QVariantMap argv; argv.insert(QStringLiteral("arguments"), helperArgs); execAction.setArguments(argv); auto reply = execAction.execute(); if (reply->exec()) { + addTemporaryAuthorization(actionId); return PrivilegeOperationReturnValue::success(); }