[gnome-keyring/nielsdg/default-keyring-in-portal-impl] secret-portal: Properly check the default keyring




commit c2070758867701457fd296387603f01b7da635b8
Author: Niels De Graef <nielsdg redhat com>
Date:   Fri May 13 10:42:40 2022 +0200

    secret-portal: Properly check the default keyring
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-keyring/-/issues/107

 daemon/dbus/gkd-secret-portal.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/daemon/dbus/gkd-secret-portal.c b/daemon/dbus/gkd-secret-portal.c
index 4663b7b9..d8b160f7 100644
--- a/daemon/dbus/gkd-secret-portal.c
+++ b/daemon/dbus/gkd-secret-portal.c
@@ -61,6 +61,29 @@ enum {
        PROP_SERVICE
 };
 
+static char *
+get_default_collection ()
+{
+       char *default_path = NULL;
+       char *contents = NULL;
+
+       default_path = g_build_filename (g_get_user_data_dir (),
+                                        "keyrings",
+                                        "default",
+                                        NULL);
+       if (g_file_get_contents (default_path, &contents, NULL, NULL)) {
+               g_strstrip (contents);
+               if (!contents[0]) {
+                       g_free (contents);
+                       contents = NULL;
+               }
+       }
+
+       g_free (default_path);
+
+       return (contents != NULL)? contents : g_strdup ("login");
+}
+
 static void
 gkd_secret_portal_init (GkdSecretPortal *self)
 {
@@ -70,7 +93,7 @@ gkd_secret_portal_init (GkdSecretPortal *self)
                self->collection = g_strdup (collection);
        else
 #endif
-               self->collection = g_strdup ("login");
+               self->collection = get_default_collection ();
        self->cancellable = g_cancellable_new ();
 }
 


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