summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2018-12-18 13:26:29 +0100
committerOndrej Holy <oholy@redhat.com>2019-01-04 13:01:31 +0000
commit2c472cd9e9607138ddaad9fcc3c5a37d5572ba02 (patch)
treeacd0fcb5c45d1f572f41af12ab5eb65710635d66 /daemon
parentb92980d078a51aebf5e167cb70e9dce9e4e37ef0 (diff)
downloadgvfs-2c472cd9e9607138ddaad9fcc3c5a37d5572ba02.tar.gz
keyring: Prefer the most recent item
If keyring contains more entries for one host, the first one is always used. However, this is not always the best one. Imagine the situation that the username was changed on the server for some reason and the previous username is invalid. When user connects using the new username, a new entry is added to the keyring. However, next time the old username is automatically used when mounting using the hostname only, which leads to login failures and the user has to specify its password each time... Prefer the most recent item from keyring if they are equal in specificity in order to prevent such issues. It would be best to remove the invalid entry automatically from the keyring, but it is not safe to remove it just in case of login failure, because it might be just some network outage, or so... https://gitlab.gnome.org/GNOME/gvfs/issues/352
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfskeyring.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/daemon/gvfskeyring.c b/daemon/gvfskeyring.c
index 556672be..8fa56f78 100644
--- a/daemon/gvfskeyring.c
+++ b/daemon/gvfskeyring.c
@@ -153,6 +153,10 @@ compare_specificity (gconstpointer a,
res = g_hash_table_size (attributes_a) - g_hash_table_size (attributes_b);
+ /* Prefer the most recent item if they are equal in specificity. */
+ if (res == 0)
+ res = secret_item_get_modified (item_b) - secret_item_get_modified (item_a);
+
g_hash_table_unref (attributes_a);
g_hash_table_unref (attributes_b);