[gnome-software] snap: Drop old non-polkit auth path - all tracked distributions have snapd >= 2.32
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] snap: Drop old non-polkit auth path - all tracked distributions have snapd >= 2.32
- Date: Wed, 23 May 2018 00:15:36 +0000 (UTC)
commit 98506b350d7f1d5f77a70d15f10d101f26ea87ce
Author: Robert Ancell <robert ancell canonical com>
Date: Wed May 23 12:14:58 2018 +1200
snap: Drop old non-polkit auth path - all tracked distributions have snapd >= 2.32
plugins/snap/gs-plugin-snap.c | 35 +++++++++--------------------------
1 file changed, 9 insertions(+), 26 deletions(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index ba53d62e..b45f87ea 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -29,7 +29,6 @@
struct GsPluginData {
SnapdAuthData *auth_data;
gchar *store_name;
- gboolean snapd_supports_polkit;
SnapdSystemConfinement system_confinement;
GsAuth *auth;
@@ -192,7 +191,6 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
GsPluginData *priv = gs_plugin_get_data (plugin);
g_autoptr(SnapdClient) client = NULL;
g_autoptr(SnapdSystemInformation) system_information = NULL;
- g_auto(GStrv) version = NULL;
client = get_client (plugin, error);
if (client == NULL)
@@ -207,15 +205,6 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
_("Snap Store"));
priv->system_confinement = snapd_system_information_get_confinement (system_information);
- version = g_strsplit (snapd_system_information_get_version (system_information), ".", -1);
- if (g_strv_length (version) >= 2) {
- int major = g_ascii_strtoull (version[0], NULL, 10);
- int minor = g_ascii_strtoull (version[1], NULL, 10);
-
- if (major > 2 || (major == 2 && minor >= 28))
- priv->snapd_supports_polkit = TRUE;
- }
-
/* load from disk */
gs_auth_add_metadata (priv->auth, "macaroon", NULL);
if (!gs_auth_store_load (priv->auth,
@@ -1042,34 +1031,28 @@ gs_plugin_auth_login (GsPlugin *plugin, GsAuth *auth,
GCancellable *cancellable, GError **error)
{
GsPluginData *priv = gs_plugin_get_data (plugin);
+ g_autoptr(SnapdClient) client = NULL;
+ g_autoptr(SnapdUserInformation) user_information = NULL;
g_autoptr(GVariant) macaroon_variant = NULL;
g_autofree gchar *serialized_macaroon = NULL;
if (auth != priv->auth)
return TRUE;
- /* snapd < 2.28 required root access to login, so we went via a D-Bus service (snapd-login-service).
- * For newer versions we just access it directly */
g_clear_object (&priv->auth_data);
- if (priv->snapd_supports_polkit) {
- g_autoptr(SnapdClient) client = NULL;
- g_autoptr(SnapdUserInformation) user_information = NULL;
- client = get_client (plugin, error);
- if (client == NULL)
- return FALSE;
+ client = get_client (plugin, error);
+ if (client == NULL)
+ return FALSE;
- user_information = snapd_client_login2_sync (client, gs_auth_get_username (auth),
gs_auth_get_password (auth), gs_auth_get_pin (auth), NULL, error);
- if (user_information != NULL)
- priv->auth_data = g_object_ref (snapd_user_information_get_auth_data
(user_information));
- }
- else
- priv->auth_data = snapd_login_sync (gs_auth_get_username (auth), gs_auth_get_password (auth),
gs_auth_get_pin (auth), NULL, error);
- if (priv->auth_data == NULL) {
+ user_information = snapd_client_login2_sync (client, gs_auth_get_username (auth),
gs_auth_get_password (auth), gs_auth_get_pin (auth), NULL, error);
+ if (user_information == NULL) {
snapd_error_convert (error);
return FALSE;
}
+ priv->auth_data = g_object_ref (snapd_user_information_get_auth_data (user_information));
+
macaroon_variant = g_variant_new ("(s^as)",
snapd_auth_data_get_macaroon (priv->auth_data),
snapd_auth_data_get_discharges (priv->auth_data));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]