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
This commit is contained in:
panoplie 2022-11-12 16:50:47 +01:00 committed by Niels De Graef
parent 31ea8cb41d
commit 7387774263

View File

@ -475,6 +475,10 @@ secret_service_search_sync (SecretService *service,
return NULL; return NULL;
} }
if (flags & SECRET_SEARCH_UNLOCK)
secret_service_unlock_dbus_paths_sync (service, (const gchar**) locked_paths,
cancellable, NULL, NULL);
ret = TRUE; ret = TRUE;
want = 1; want = 1;
@ -509,9 +513,6 @@ secret_service_search_sync (SecretService *service,
items = g_list_concat (items, g_list_copy (unlocked)); items = g_list_concat (items, g_list_copy (unlocked));
items = g_list_reverse (items); 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) if (flags & SECRET_SEARCH_LOAD_SECRETS)
secret_item_load_secrets_sync (items, NULL, NULL); secret_item_load_secrets_sync (items, NULL, NULL);