Index: subversion/libsvn_auth_gnome_keyring/gnome_keyring.c =================================================================== --- subversion/libsvn_auth_gnome_keyring/gnome_keyring.c (revision 33273) +++ subversion/libsvn_auth_gnome_keyring/gnome_keyring.c (working copy) @@ -26,6 +26,7 @@ #include "svn_auth.h" #include "svn_auth_dso.h" #include "svn_error.h" +#include "svn_pools.h" #include "private/svn_auth_private.h" @@ -40,6 +41,48 @@ /* GNOME Keyring simple provider, puts passwords in GNOME Keyring */ /*-----------------------------------------------------------------------*/ +/* If the default keyring is already locked, prompts for keyring + * password and unlocks the keyring. Returns default keyring + * name if successfully unlocked, else NULL. */ +static const char * +gnome_keyring_unlock_keyring(apr_pool_t *pool) +{ + GnomeKeyringResult result; + char *def = NULL; + char *def_dup = NULL; + GnomeKeyringInfo *keyring_info=NULL; + + /* Finds default keyring. */ + result = gnome_keyring_get_default_keyring_sync(&def); + if (result != GNOME_KEYRING_RESULT_OK || def == NULL) + return NULL; + + /* Get details about the default keyring. */ + gnome_keyring_get_info_sync(def, &keyring_info); + + /* Check if default keyring is locked. */ + if (keyring_info && gnome_keyring_info_get_is_locked(keyring_info)) + { + char *passwd; + char *prompt_text; + svn_auth_cred_simple_t *cred; + apr_pool_t *subpool = svn_pool_create(pool); + + prompt_text = apr_psprintf(subpool, "Keyring [%s]", def); + svn_cmdline_auth_simple_prompt(&cred, NULL, NULL, prompt_text, + TRUE, subpool); + gnome_keyring_unlock_sync(def, cred->password); + svn_pool_destroy(subpool); + } + + /* Cleanup. */ + gnome_keyring_info_free(keyring_info); + def_dup = apr_pstrdup(pool, def); + if (def) + free(def); + return def_dup; +} + /* Implementation of password_get_t that retrieves the password from GNOME Keyring. */ static svn_boolean_t @@ -65,6 +108,9 @@ return FALSE; } + if (!gnome_keyring_unlock_keyring(pool)) + return FALSE; + GnomeKeyringResult result; GList *items; svn_boolean_t ret = FALSE; @@ -117,6 +163,9 @@ return FALSE; } + if (!gnome_keyring_unlock_keyring(pool)) + return FALSE; + GnomeKeyringResult result; guint32 item_id;