From 5a4a8ac5d6e038e8ce87a398e43b43998194e667 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 8 May 2015 21:43:40 +0200 Subject: [PATCH] Bug 746873 - Gnucash asks sql passwords before wallet password Work around a bug in libsecret. Under certain conditions libsecret will silently fail to find a password even though it is stored. The workaround uses another interface call to force unlocking the secret store which works around the bug. This workaround should be removed once a fix for https://bugzilla.gnome.org/show_bug.cgi?id=748625 will be commonly available. --- src/gnome-utils/gnc-keyring.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/gnome-utils/gnc-keyring.c b/src/gnome-utils/gnc-keyring.c index d6eaa2333d..5c91e068ea 100644 --- a/src/gnome-utils/gnc-keyring.c +++ b/src/gnome-utils/gnc-keyring.c @@ -180,6 +180,24 @@ gboolean gnc_keyring_get_password ( GtkWidget *parent, *password = NULL; #ifdef HAVE_LIBSECRET + /* Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=746873 + * and by extension for https://bugzilla.gnome.org/show_bug.cgi?id=748625 + * Store a dummy password and delete it again. This forces libsecret + * to open the keychain, where only a call to secret_password_lookup_sync + * sometimes fails to do so. More details can be found in the bug reports + * referenced above. */ + secret_password_store_sync (SECRET_SCHEMA_GNUCASH, SECRET_COLLECTION_DEFAULT, + "Dummy password", "dummy", NULL, &error, + "protocol", "gnucash", + "server", "gnucash", + "user", "gnucash", + NULL); + secret_password_clear_sync (SECRET_SCHEMA_GNUCASH, NULL, &error, + "protocol", "gnucash", + "server", "gnucash", + "user", "gnucash", + NULL); + /* Note: only use the port attribute if it was set by the user. */ if (port == 0) libsecret_password = secret_password_lookup_sync (SECRET_SCHEMA_GNUCASH, NULL, &error,