[gnome-software/wip/mcrha/packagekit-ensure-interactive-flag] packagekit: Ensure PkClient::interactive flag being set



commit 50ea9e8e6c4c3c23607b1ea9cc56e5e1b15c9e42
Author: Milan Crha <mcrha redhat com>
Date:   Mon Sep 13 15:02:37 2021 +0200

    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 338cc3874..ef06bcd23 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 da083019a..c9e4e49fd 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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]