Resolves: #2003365 (packagekit: Ensure PkClient::interactive flag being set)

This commit is contained in:
Milan Crha 2021-09-13 15:13:00 +02:00
parent 4f4ac53d68
commit 95dd5f06f6
2 changed files with 121 additions and 1 deletions

View File

@ -0,0 +1,116 @@
From 50ea9e8e6c4c3c23607b1ea9cc56e5e1b15c9e42 Mon Sep 17 00:00:00 2001
From: Milan Crha <mcrha@redhat.com>
Date: Mon, 13 Sep 2021 15:02:37 +0200
Subject: [PATCH] packagekit: Ensure PkClient::interactive flag being set
That's required to properly ask or not ask for the root credentials on operations,
which require higher privileges. It's important to set the flag always before the call
to the PkTask/PkClient API, because other thread could change the value while
the corresponding lock was released by the execution thread.
Downstream bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=2003365
---
plugins/packagekit/gs-plugin-packagekit-refresh.c | 1 +
plugins/packagekit/gs-plugin-packagekit.c | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/plugins/packagekit/gs-plugin-packagekit-refresh.c b/plugins/packagekit/gs-plugin-packagekit-refresh.c
index 338cc387..ef06bcd2 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refresh.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refresh.c
@@ -94,6 +94,7 @@ _download_only (GsPlugin *plugin, GsAppList *list,
* we end up downloading a different set of packages than what was
* shown to the user */
pk_client_set_cache_age (PK_CLIENT (priv->task), G_MAXUINT);
+ pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
results2 = pk_task_update_packages_sync (priv->task,
package_ids,
cancellable,
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index da083019..c9e4e49f 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -424,6 +424,7 @@ gs_plugin_app_install (GsPlugin *plugin,
/* actually install the package */
gs_packagekit_helper_add_app (helper, app);
g_mutex_lock (&priv->task_mutex);
+ pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
results = pk_task_install_packages_sync (priv->task,
package_ids,
cancellable,
@@ -501,6 +502,7 @@ gs_plugin_app_install (GsPlugin *plugin,
}
gs_packagekit_helper_add_app (helper, app);
g_mutex_lock (&priv->task_mutex);
+ pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
results = pk_task_install_packages_sync (priv->task,
(gchar **) array_package_ids->pdata,
cancellable,
@@ -542,6 +544,7 @@ gs_plugin_app_install (GsPlugin *plugin,
gs_app_set_state (app, GS_APP_STATE_INSTALLING);
gs_packagekit_helper_add_app (helper, app);
g_mutex_lock (&priv->task_mutex);
+ pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
results = pk_task_install_files_sync (priv->task,
package_ids,
cancellable,
@@ -627,6 +630,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
gs_app_set_state (app, GS_APP_STATE_REMOVING);
gs_packagekit_helper_add_app (helper, app);
g_mutex_lock (&priv->task_mutex);
+ pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
results = pk_task_remove_packages_sync (priv->task,
package_ids,
TRUE, GS_PACKAGEKIT_AUTOREMOVE,
@@ -862,6 +866,7 @@ gs_plugin_packagekit_resolve_packages_with_filter (GsPlugin *plugin,
/* resolve them all at once */
g_mutex_lock (&priv->client_mutex_refine);
+ pk_client_set_interactive (priv->client_refine, gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
results = pk_client_resolve (priv->client_refine,
filter,
(gchar **) package_ids->pdata,
@@ -953,6 +958,7 @@ gs_plugin_packagekit_refine_from_desktop (GsPlugin *plugin,
to_array[0] = filename;
gs_packagekit_helper_add_app (helper, app);
g_mutex_lock (&priv->client_mutex_refine);
+ pk_client_set_interactive (priv->client_refine, gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
results = pk_client_search_files (priv->client_refine,
pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED, -1),
(gchar **) to_array,
@@ -1036,6 +1042,7 @@ gs_plugin_packagekit_refine_updatedetails (GsPlugin *plugin,
/* get any update details */
g_mutex_lock (&priv->client_mutex_refine);
+ pk_client_set_interactive (priv->client_refine, gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
results = pk_client_get_update_detail (priv->client_refine,
(gchar **) package_ids,
cancellable,
@@ -1102,6 +1109,7 @@ gs_plugin_packagekit_refine_details2 (GsPlugin *plugin,
/* get any details */
g_mutex_lock (&priv->client_mutex_refine);
+ pk_client_set_interactive (priv->client_refine, gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
results = pk_client_get_details (priv->client_refine,
(gchar **) package_ids->pdata,
cancellable,
@@ -1154,6 +1162,7 @@ gs_plugin_packagekit_refine_update_urgency (GsPlugin *plugin,
/* get the list of updates */
filter = pk_bitfield_value (PK_FILTER_ENUM_NONE);
g_mutex_lock (&priv->client_mutex_refine);
+ pk_client_set_interactive (priv->client_refine, gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
results = pk_client_get_updates (priv->client_refine,
filter,
cancellable,
@@ -1812,6 +1821,7 @@ gs_plugin_packagekit_refresh_guess_app_id (GsPlugin *plugin,
files = g_strsplit (filename, "\t", -1);
gs_packagekit_helper_add_app (helper, app);
g_mutex_lock (&priv->task_mutex_local);
+ pk_client_set_interactive (PK_CLIENT (priv->task_local), gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
results = pk_client_get_files_local (PK_CLIENT (priv->task_local),
files,
cancellable,
--
2.31.1

View File

@ -12,7 +12,7 @@
Name: gnome-software
Version: 41~rc
Release: 1%{?dist}
Release: 2%{?dist}
Summary: A software center for GNOME
License: GPLv2+
@ -20,6 +20,7 @@ URL: https://wiki.gnome.org/Apps/Software
Source0: https://download.gnome.org/sources/gnome-software/41/%{name}-%{tarball_version}.tar.xz
Patch01: 0001-crash-with-broken-theme.patch
Patch02: 0002-packagekit-Ensure-PkClient-interactive-flag-being-se.patch
BuildRequires: appstream-devel >= %{appstream_version}
BuildRequires: gcc
@ -198,6 +199,9 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop
%{_datadir}/gtk-doc/html/gnome-software
%changelog
* Mon Sep 13 2021 Milan Crha <mcrha@redhat.com> - 41~rc-2
- Resolves: #2003365 (packagekit: Ensure PkClient::interactive flag being set)
* Wed Sep 08 2021 Milan Crha <mcrha@redhat.com> - 41~rc-1
- Update to 41.rc