[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: [PATCH] Issue 2489: requests keyring password and unlocks the keyring.

From: Bert Huijben <b.huijben_at_competence.biz>
Date: Thu, 25 Sep 2008 09:26:34 +0200

        Hi

> -----Original Message-----
> From: Alexander Thomas [mailto:alexander_at_collab.net]
> Sent: donderdag 25 september 2008 7:41
> To: Subversion-Dev
> Subject: [PATCH] Issue 2489: requests keyring password and unlocks the
> keyring.
>
> [[[
> If the default keyring is already locked, prompt for keyring
> password and unlock the keyring.
>
> * subversion/libsvn_auth_gnome_keyring/gnome_keyring.c
> (): Include svn_pools.h
> (gnome_keyring_unlock_keyring): New static function to unlock
> keyring.
>
> Patch by: Alexander Thomas <alexander_at_collab.net>
> ]]]
>
>
> -Alexander Thomas(AT)

> 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);

This code assumes the keyring support always runs on the cmdline, but the code is in a library that is also used by gui clients. (e.g. Eclipse)

The gnome keyring support should define a prompt handler like the other authentication handlers. This allows the client to provide the prompt: dialog, cmdline, etc.
This prompt handler can also handle --non-interactive support for you, if that isn't handled higher up. (I didn't check if keyring support is enabled at all in --non-interactive mode)

> + 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;
>

These last two changes are not documented in your log message.

        Bert

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-09-25 09:26:52 CEST

This is an archived mail posted to the Subversion Dev mailing list.