dnfdaemon: Make it possible to set 'interactive' option for Rpm::system_upgrade()
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
2ae58eed2e
commit
a05c167e15
|
@ -223,6 +223,8 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.
|
|||
|
||||
- mode: string (one of "distrosync", "upgrade", default is "distrosync")
|
||||
By default the system_upgrade behaves like `dnf distro-sync`, always installing packages from the new release, even if they are older than the currently installed version. If set to "upgrade", packages from the new release are not installed if they are older than what is currently installed (behave like `dnf upgrade`).
|
||||
- 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.
|
||||
-->
|
||||
|
|
|
@ -817,14 +817,15 @@ sdbus::MethodReply Rpm::remove(sdbus::MethodCall & call) {
|
|||
}
|
||||
|
||||
sdbus::MethodReply Rpm::system_upgrade(sdbus::MethodCall & call) {
|
||||
if (!session.check_authorization(dnfdaemon::POLKIT_EXECUTE_RPM_TRANSACTION, call.getSender())) {
|
||||
throw std::runtime_error("Not authorized");
|
||||
}
|
||||
auto base = session.get_base();
|
||||
|
||||
// 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(dnfdaemon::POLKIT_EXECUTE_RPM_TRANSACTION, call.getSender(), interactive)) {
|
||||
throw std::runtime_error("Not authorized");
|
||||
}
|
||||
auto base = session.get_base();
|
||||
|
||||
// check that releasever is different than the detected one
|
||||
auto target_releasever = base->get_vars()->get_value("releasever");
|
||||
|
|
Loading…
Reference in New Issue