You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Mark Phippard <ma...@gmail.com> on 2015/02/08 02:48:12 UTC

Re: svn commit: r1658123 - in /subversion/trunk/subversion: bindings/javahl/native/OperationContext.cpp bindings/javahl/native/Prompter.cpp bindings/javahl/native/Prompter.h libsvn_auth_gnome_keyring/gnome_keyring.c

What might this be useful for? Non-GUI apps? I assume this will not break the current functionality, which finally works as of 1.8.11.

Mark

> On Feb 7, 2015, at 8:32 PM, rhuijben@apache.org wrote:
> 
> Author: rhuijben
> Date: Sun Feb  8 01:32:07 2015
> New Revision: 1658123
> 
> URL: http://svn.apache.org/r1658123
> Log:
> Expose the Gnome keyring unlock prompt to the JavaHL C++ code.
> (Exposing it to JavaHL itself is a different step where brane might
> have better ideas)
> 
> * subversion/bindings/javahl/native/OperationContext.cpp
>  (OperationContext::getAuthBaton):
>     Hook gnome prompt if we have a prompter implementation.
> 
> * subversion/bindings/javahl/native/Prompter.cpp
>  (Prompter::get_gnome_keyring_unlock,
>   Prompter::gnome_keyring_unlock_prompt): New function.
> 
> * subversion/bindings/javahl/native/Prompter.h
>  (Prompter::get_gnome_keyring_unlock,
>   Prompter::gnome_keyring_unlock_prompt): New function.
> 
> * subversion/libsvn_auth_gnome_keyring/gnome_keyring.c
>  (ensure_gnome_keyring_is_unlocked): Allow prompt func to not provide a
>    password, similar to our other credential callbacks. This makes it easier
>    for bindings to conditionally handle the prompt.
> 
> Modified:
>    subversion/trunk/subversion/bindings/javahl/native/OperationContext.cpp
>    subversion/trunk/subversion/bindings/javahl/native/Prompter.cpp
>    subversion/trunk/subversion/bindings/javahl/native/Prompter.h
>    subversion/trunk/subversion/libsvn_auth_gnome_keyring/gnome_keyring.c
> 
> Modified: subversion/trunk/subversion/bindings/javahl/native/OperationContext.cpp
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/OperationContext.cpp?rev=1658123&r1=1658122&r2=1658123&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/bindings/javahl/native/OperationContext.cpp (original)
> +++ subversion/trunk/subversion/bindings/javahl/native/OperationContext.cpp Sun Feb  8 01:32:07 2015
> @@ -218,6 +218,27 @@ OperationContext::getAuthBaton(SVN::Pool
>   /* Build an authentication baton to give to libsvn_client. */
>   svn_auth_open(&ab, providers, pool);
> 
> +  if (m_prompter.get())
> +    {
> +      svn_auth_gnome_keyring_unlock_prompt_func_t unlock_cb;
> +      void *unlock_baton;
> +
> +      m_prompter->get_gnome_keyring_unlock(&unlock_cb, &unlock_baton,
> +                                         in_pool);
> +
> +      if (unlock_cb)
> +        {
> +          svn_auth_set_parameter(
> +                         ab,
> +                         SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_FUNC,
> +                         unlock_cb);
> +        svn_auth_set_parameter(
> +                         ab,
> +                         SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_FUNC,
> +                         unlock_baton);
> +      }
> +    }
> +
>   /* Place any default --username or --password credentials into the
>    * auth_baton's run-time parameter hash.  ### Same with --no-auth-cache? */
>   if (!m_userName.empty())
> 
> Modified: subversion/trunk/subversion/bindings/javahl/native/Prompter.cpp
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/Prompter.cpp?rev=1658123&r1=1658122&r2=1658123&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/bindings/javahl/native/Prompter.cpp (original)
> +++ subversion/trunk/subversion/bindings/javahl/native/Prompter.cpp Sun Feb  8 01:32:07 2015
> @@ -138,6 +138,16 @@ Prompter::get_provider_client_ssl_passwo
>   return provider;
> }
> 
> +void
> +Prompter::get_gnome_keyring_unlock(
> +              svn_auth_gnome_keyring_unlock_prompt_func_t *cb,
> +              void **baton,
> +              SVN::Pool &in_pool)
> +{
> +  *cb = gnome_keyring_unlock_prompt;
> +  *baton = this;
> +}
> +
> svn_error_t *Prompter::simple_prompt(
>     svn_auth_cred_simple_t **cred_p,
>     void *baton,
> @@ -221,6 +231,18 @@ svn_error_t *Prompter::ssl_client_cert_p
>   return err;
> }
> 
> +svn_error_t *Prompter::gnome_keyring_unlock_prompt(
> +    char **keyring_password,
> +    const char *keyring_name,
> +    void *baton,
> +    apr_pool_t *pool)
> +{
> +  /* ### TODO: Forward to Java */
> +
> +  *keyring_password = NULL; /* Don't attempt an unlock */
> +  return SVN_NO_ERROR;
> +}
> +
> svn_error_t *Prompter::plaintext_prompt(
>     svn_boolean_t *may_save_plaintext,
>     const char *realmstring,
> 
> Modified: subversion/trunk/subversion/bindings/javahl/native/Prompter.h
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/Prompter.h?rev=1658123&r1=1658122&r2=1658123&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/bindings/javahl/native/Prompter.h (original)
> +++ subversion/trunk/subversion/bindings/javahl/native/Prompter.h Sun Feb  8 01:32:07 2015
> @@ -60,6 +60,11 @@ public:
>   svn_auth_provider_object_t *get_provider_client_ssl(SVN::Pool &in_pool);
>   svn_auth_provider_object_t *get_provider_client_ssl_password(SVN::Pool &in_pool);
> 
> +  void get_gnome_keyring_unlock(
> +              svn_auth_gnome_keyring_unlock_prompt_func_t *cb,
> +              void **baton,
> +              SVN::Pool &in_pool);
> +
> protected:
>   explicit Prompter(::Java::Env env, jobject jprompter);
> 
> @@ -144,6 +149,12 @@ protected:
>       svn_boolean_t may_save,
>       apr_pool_t *pool);
> 
> +  static svn_error_t *gnome_keyring_unlock_prompt(
> +      char **keyring_password,
> +      const char *keyring_name,
> +      void *baton,
> +      apr_pool_t *pool);
> +
> protected:
>   virtual svn_error_t *dispatch_plaintext_prompt(
>       ::Java::Env env,
> 
> Modified: subversion/trunk/subversion/libsvn_auth_gnome_keyring/gnome_keyring.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_auth_gnome_keyring/gnome_keyring.c?rev=1658123&r1=1658122&r2=1658123&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_auth_gnome_keyring/gnome_keyring.c (original)
> +++ subversion/trunk/subversion/libsvn_auth_gnome_keyring/gnome_keyring.c Sun Feb  8 01:32:07 2015
> @@ -129,19 +129,22 @@ ensure_gnome_keyring_is_unlocked(svn_boo
>         svn_hash_gets(parameters,
>                       SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_BATON);
> 
> -      char *keyring_password;
> -
>       if (unlock_prompt_func && check_keyring_is_locked(default_keyring))
>         {
> +          char *keyring_password;
> +
>           SVN_ERR((*unlock_prompt_func)(&keyring_password,
>                                         default_keyring,
>                                         unlock_prompt_baton,
>                                         scratch_pool));
> 
>           /* If keyring is locked give up and try the next provider. */
> -          if (! unlock_gnome_keyring(default_keyring, keyring_password,
> -                                     scratch_pool))
> -            return SVN_NO_ERROR;
> +          if (keyring_password)
> +            {
> +              if (! unlock_gnome_keyring(default_keyring, keyring_password,
> +                                         scratch_pool))
> +                return SVN_NO_ERROR;
> +            }
>         }
>     }
>   else
> 
> 

Re: svn commit: r1658123 - in /subversion/trunk/subversion: bindings/javahl/native/OperationContext.cpp bindings/javahl/native/Prompter.cpp bindings/javahl/native/Prompter.h libsvn_auth_gnome_keyring/gnome_keyring.c

Posted by Branko Čibej <br...@wandisco.com>.
On 08.02.2015 12:04, Branko Čibej wrote:
> On 08.02.2015 10:58, Bert Huijben wrote:
>>> -----Original Message-----
>>> From: Mark Phippard [mailto:markphip@gmail.com]
>>> Sent: zondag 8 februari 2015 02:48
>>> To: dev@subversion.apache.org
>>> Cc: commits@subversion.apache.org
>>> Subject: Re: svn commit: r1658123 - in /subversion/trunk/subversion:
>>> bindings/javahl/native/OperationContext.cpp
>>> bindings/javahl/native/Prompter.cpp bindings/javahl/native/Prompter.h
>>> libsvn_auth_gnome_keyring/gnome_keyring.c
>>>
>>> What might this be useful for? Non-GUI apps? I assume this will not break
>> the
>>> current functionality, which finally works as of 1.8.11.
>> It will only change behavior if the prompt function is both hooked *and*
>> does provide a password. Some optional callback that allows to provide a
>> password should be added to JavaHL, as using JavaHL doesn't imply that you
>> are using a GUI that has access to the Gnome display handling.
> I don't like the idea of exposing platform-specific authentication
> callbacks in the JavaHL API.
>
> IIUC, if you're using the command-line client in a headless terminal and
> want to use the Gnome keyring, you have to start the Gnome keyring
> daemon and unlock the keyring manually, e.g., as described here:
>
> http://superuser.com/questions/141036/use-of-gnome-keyring-daemon-without-x
>
> I don't see a good reason to have JavaHL behave differently.

I reverted r1658123 and r1658123 in r1658150, with Bert's +1 from IRC.

-- Brane

Re: svn commit: r1658123 - in /subversion/trunk/subversion: bindings/javahl/native/OperationContext.cpp bindings/javahl/native/Prompter.cpp bindings/javahl/native/Prompter.h libsvn_auth_gnome_keyring/gnome_keyring.c

Posted by Branko Čibej <br...@wandisco.com>.
On 08.02.2015 10:58, Bert Huijben wrote:
>> -----Original Message-----
>> From: Mark Phippard [mailto:markphip@gmail.com]
>> Sent: zondag 8 februari 2015 02:48
>> To: dev@subversion.apache.org
>> Cc: commits@subversion.apache.org
>> Subject: Re: svn commit: r1658123 - in /subversion/trunk/subversion:
>> bindings/javahl/native/OperationContext.cpp
>> bindings/javahl/native/Prompter.cpp bindings/javahl/native/Prompter.h
>> libsvn_auth_gnome_keyring/gnome_keyring.c
>>
>> What might this be useful for? Non-GUI apps? I assume this will not break
> the
>> current functionality, which finally works as of 1.8.11.
> It will only change behavior if the prompt function is both hooked *and*
> does provide a password. Some optional callback that allows to provide a
> password should be added to JavaHL, as using JavaHL doesn't imply that you
> are using a GUI that has access to the Gnome display handling.

I don't like the idea of exposing platform-specific authentication
callbacks in the JavaHL API.

IIUC, if you're using the command-line client in a headless terminal and
want to use the Gnome keyring, you have to start the Gnome keyring
daemon and unlock the keyring manually, e.g., as described here:

http://superuser.com/questions/141036/use-of-gnome-keyring-daemon-without-x

I don't see a good reason to have JavaHL behave differently.

-- Brane

RE: svn commit: r1658123 - in /subversion/trunk/subversion: bindings/javahl/native/OperationContext.cpp bindings/javahl/native/Prompter.cpp bindings/javahl/native/Prompter.h libsvn_auth_gnome_keyring/gnome_keyring.c

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: Mark Phippard [mailto:markphip@gmail.com]
> Sent: zondag 8 februari 2015 02:48
> To: dev@subversion.apache.org
> Cc: commits@subversion.apache.org
> Subject: Re: svn commit: r1658123 - in /subversion/trunk/subversion:
> bindings/javahl/native/OperationContext.cpp
> bindings/javahl/native/Prompter.cpp bindings/javahl/native/Prompter.h
> libsvn_auth_gnome_keyring/gnome_keyring.c
> 
> What might this be useful for? Non-GUI apps? I assume this will not break
the
> current functionality, which finally works as of 1.8.11.

It will only change behavior if the prompt function is both hooked *and*
does provide a password. Some optional callback that allows to provide a
password should be added to JavaHL, as using JavaHL doesn't imply that you
are using a GUI that has access to the Gnome display handling.

	Bert


RE: svn commit: r1658123 - in /subversion/trunk/subversion: bindings/javahl/native/OperationContext.cpp bindings/javahl/native/Prompter.cpp bindings/javahl/native/Prompter.h libsvn_auth_gnome_keyring/gnome_keyring.c

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: Mark Phippard [mailto:markphip@gmail.com]
> Sent: zondag 8 februari 2015 02:48
> To: dev@subversion.apache.org
> Cc: commits@subversion.apache.org
> Subject: Re: svn commit: r1658123 - in /subversion/trunk/subversion:
> bindings/javahl/native/OperationContext.cpp
> bindings/javahl/native/Prompter.cpp bindings/javahl/native/Prompter.h
> libsvn_auth_gnome_keyring/gnome_keyring.c
> 
> What might this be useful for? Non-GUI apps? I assume this will not break
the
> current functionality, which finally works as of 1.8.11.

It will only change behavior if the prompt function is both hooked *and*
does provide a password. Some optional callback that allows to provide a
password should be added to JavaHL, as using JavaHL doesn't imply that you
are using a GUI that has access to the Gnome display handling.

	Bert