dnfdaemon: Make it possible to set 'interactive' option for Goal::do_transaction()
The operation can require root privileges, for which it can ask the user through polkit. It's okay when the operation is interactive, aka issued by a user, but when the operation is ran by a background service, then the password prompt coming out of blue is wrong. This change allows to tell the daemon server whether it can ask for the root password or not.
This commit is contained in:
parent
25b181098e
commit
d63616e8ce
|
@ -87,6 +87,8 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.
|
|||
Adds a comment to a transaction.
|
||||
- offline: boolean, default false
|
||||
If true, the transaction will be prepared to run during the next reboot. Otherwise, it will run immediately.
|
||||
- interactive: boolean, default true
|
||||
Set to "true", when the operation is done by a user, thus user interaction like password prompts can be done.
|
||||
|
||||
Unknown options are ignored.
|
||||
-->
|
||||
|
|
|
@ -374,10 +374,14 @@ bool is_transaction_trusted(libdnf5::base::Transaction * transaction) {
|
|||
sdbus::MethodReply Goal::do_transaction(sdbus::MethodCall & call) {
|
||||
transaction_resolved_assert();
|
||||
auto * transaction = session.get_transaction();
|
||||
// read options from dbus call
|
||||
dnfdaemon::KeyValueMap options;
|
||||
call >> options;
|
||||
bool interactive = dnfdaemon::key_value_map_get<bool>(options, "interactive", true);
|
||||
if (!session.check_authorization(
|
||||
is_transaction_trusted(transaction) ? dnfdaemon::POLKIT_EXECUTE_RPM_TRUSTED_TRANSACTION
|
||||
: dnfdaemon::POLKIT_EXECUTE_RPM_TRANSACTION,
|
||||
call.getSender())) {
|
||||
call.getSender(), interactive)) {
|
||||
throw std::runtime_error("Not authorized");
|
||||
}
|
||||
|
||||
|
@ -390,10 +394,6 @@ sdbus::MethodReply Goal::do_transaction(sdbus::MethodCall & call) {
|
|||
|
||||
session.set_cancel_download(Session::CancelDownload::NOT_REQUESTED);
|
||||
|
||||
// read options from dbus call
|
||||
dnfdaemon::KeyValueMap options;
|
||||
call >> options;
|
||||
|
||||
bool offline = dnfdaemon::key_value_map_get<bool>(options, "offline", false);
|
||||
|
||||
if (offline) {
|
||||
|
|
Loading…
Reference in New Issue