summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdg@redhat.com>2022-05-13 10:42:40 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2022-05-21 12:35:41 +0000
commit8bd42172af81d3e18397a690fc4eec14aa2d3122 (patch)
treea2ec4ce48fa38f6816e7ef6d6960657a5a3732d2
parent269ae26c81ed716f2552af016acd5e91f17a93fd (diff)
downloadgnome-keyring-nielsdg/default-keyring-in-portal-impl.tar.gz
secret-portal: Properly check the default keyringnielsdg/default-keyring-in-portal-impl
Fixes: https://gitlab.gnome.org/GNOME/gnome-keyring/-/issues/107
-rw-r--r--daemon/dbus/gkd-secret-portal.c25
1 files changed, 24 insertions, 1 deletions
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 ();
}