From 7387774263cd344d08a68b06e1bf10e9ce5e6a53 Mon Sep 17 00:00:00 2001 From: panoplie <59100-panoplie@users.noreply.gitlab.gnome.org> Date: Sat, 12 Nov 2022 16:50:47 +0100 Subject: [PATCH] sync-search: unlock keyring before getting secret attributes In gnome-keyring, the secret items attributes are not visible until the keyring is unlocked. But in libsecret, the synchronous secret search function unlocks the keyring after and not before the attributes dbus pull. So when the keyring is locked and you run secret_service_search_sync(), you get hashed or empty attributes because the keyring was locked at the time these attributes were pulled. If you run this function when the keyring is already unlocked, there is no problem. This commit moves the unlock routine before the attributes pull to make the synchronous search function working correctly when the keyring is locked initially. Issues #6 gnome-shell#4780 --- libsecret/secret-methods.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libsecret/secret-methods.c b/libsecret/secret-methods.c index 75dbed3..e0cb3eb 100644 --- a/libsecret/secret-methods.c +++ b/libsecret/secret-methods.c @@ -475,6 +475,10 @@ secret_service_search_sync (SecretService *service, return NULL; } + if (flags & SECRET_SEARCH_UNLOCK) + secret_service_unlock_dbus_paths_sync (service, (const gchar**) locked_paths, + cancellable, NULL, NULL); + ret = TRUE; want = 1; @@ -509,9 +513,6 @@ secret_service_search_sync (SecretService *service, items = g_list_concat (items, g_list_copy (unlocked)); items = g_list_reverse (items); - if (flags & SECRET_SEARCH_UNLOCK) - secret_service_unlock_sync (service, locked, cancellable, NULL, NULL); - if (flags & SECRET_SEARCH_LOAD_SECRETS) secret_item_load_secrets_sync (items, NULL, NULL);