[gnome-initial-setup/new-user-mode-fixes: 1/3] Revert "keyring: don't change keyring password explicitly"



commit 69714499c2ac260dfde6f24fa0070719bdc07bfa
Author: Tristan Van Berkom <tristan vanberkom codethink co uk>
Date:   Tue Nov 24 10:15:03 2015 +0000

    Revert "keyring: don't change keyring password explicitly"
    
    This reverts commit 02168722cfd18cdc0213c0d3270f04f8c5dbd375.

 gnome-initial-setup/gis-keyring.c                  |   57 ++++++++++++++++++++
 gnome-initial-setup/gis-keyring.h                  |    1 +
 .../pages/password/gis-password-page.c             |    2 +
 3 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/gnome-initial-setup/gis-keyring.c b/gnome-initial-setup/gis-keyring.c
index cbef4f2..6459591 100644
--- a/gnome-initial-setup/gis-keyring.c
+++ b/gnome-initial-setup/gis-keyring.c
@@ -67,3 +67,60 @@ out:
        if (launcher)
                g_object_unref (launcher);
 }
+
+void
+gis_update_login_keyring_password (const gchar *new_)
+{
+       GDBusConnection *bus = NULL;
+       SecretService *service = NULL;
+       SecretValue *old_secret = NULL;
+       SecretValue *new_secret = NULL;
+       GError *error = NULL;
+       
+       service = secret_service_get_sync (SECRET_SERVICE_OPEN_SESSION, NULL, &error);
+       if (service == NULL) {
+               g_warning ("Failed to get secret service: %s", error->message);
+               g_error_free (error);
+               goto out;
+       }
+
+       bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+       if (bus == NULL) {
+               g_warning ("Failed to get session bus: %s", error->message);
+               g_error_free (error);
+               goto out;
+       }
+
+       old_secret = secret_value_new (DUMMY_PWD, strlen (DUMMY_PWD), "text/plain");
+       new_secret = secret_value_new (new_, strlen (new_), "text/plain");
+
+       g_dbus_connection_call_sync (bus,
+                                     "org.gnome.keyring",
+                                     "/org/freedesktop/secrets",
+                                     "org.gnome.keyring.InternalUnsupportedGuiltRiddenInterface",
+                                     "ChangeWithMasterPassword",
+                                     g_variant_new ("(o@(oayays)@(oayays))",
+                                                    "/org/freedesktop/secrets/collection/login",
+                                                    secret_service_encode_dbus_secret (service, old_secret),
+                                                    secret_service_encode_dbus_secret (service, new_secret)),
+                                     NULL,
+                                     0,
+                                     G_MAXINT,
+                                     NULL, &error);
+
+        if (error != NULL) {
+          g_warning ("Failed to change keyring password: %s", error->message);
+          g_error_free (error);
+        }
+
+out:
+
+       if (service)
+               g_object_unref (service);
+       if (bus)
+               g_object_unref (bus);
+       if (old_secret)
+               secret_value_unref (old_secret);
+       if (new_secret)
+               secret_value_unref (new_secret);
+}
diff --git a/gnome-initial-setup/gis-keyring.h b/gnome-initial-setup/gis-keyring.h
index 496b153..764f1e6 100644
--- a/gnome-initial-setup/gis-keyring.h
+++ b/gnome-initial-setup/gis-keyring.h
@@ -28,6 +28,7 @@
 G_BEGIN_DECLS
 
 void   gis_ensure_login_keyring          ();
+void   gis_update_login_keyring_password (const gchar *new_);
 
 G_END_DECLS
 
diff --git a/gnome-initial-setup/pages/password/gis-password-page.c 
b/gnome-initial-setup/pages/password/gis-password-page.c
index 00f83c1..5acd5c8 100644
--- a/gnome-initial-setup/pages/password/gis-password-page.c
+++ b/gnome-initial-setup/pages/password/gis-password-page.c
@@ -95,6 +95,8 @@ gis_password_page_save_data (GisPage *gis_page)
     act_user_set_password (act_user, password, "");
 
   gis_driver_set_user_permissions (gis_page->driver, act_user, password);
+
+  gis_update_login_keyring_password (password);
 }
 
 static void


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