2008-11-25 13:36:03 Arfrever Frehtes Taifersar Arahesis napisał(a):
> 2008-11-25 05:02 <jwhitlock_at_tigris.org> napisał(a):
> > Author: jwhitlock
> > Date: Mon Nov 24 20:02:43 2008
> > New Revision: 34399
> >
> > Log:
> > Greatly simplify how to get a list of available platform-specific auth
> > providers.
> >
> > * subversion/libsvn_subr/auth.c,
> > subversion/include/svn_auth.h
> > (svn_auth_get_platform_specific_client_providers): Added.
> >
> > * subversion/libsvn_subr/cmdline.c (svn_cmdline_create_auth_baton),
> > subversion/bindings/javahl/native/SVNClient.cpp (getContext): Use the new
> > function added above.
> >
> > * subversion/tests/libsvn_subr/auth-test.c
> > (test_platform_specific_auth_providers): Test the new function added above.
> >
> > Modified:
> > trunk/subversion/bindings/javahl/native/SVNClient.cpp
> > trunk/subversion/include/svn_auth.h
> > trunk/subversion/libsvn_subr/auth.c
> > trunk/subversion/libsvn_subr/cmdline.c
> > trunk/subversion/tests/libsvn_subr/auth-test.c
> >
> > Modified: trunk/subversion/bindings/javahl/native/SVNClient.cpp
> > URL: http://svn.collab.net/viewvc/svn/trunk/subversion/bindings/javahl/native/SVNClient.cpp?pathrev=34399&r1=34398&r2=34399
> > ==============================================================================
> > --- trunk/subversion/bindings/javahl/native/SVNClient.cpp Mon Nov 24 19:53:13 2008 (r34398)
> > +++ trunk/subversion/bindings/javahl/native/SVNClient.cpp Mon Nov 24 20:02:43 2008 (r34399)
> > @@ -1159,89 +1159,17 @@ svn_client_ctx_t *SVNClient::getContext(
> > svn_client_ctx_t *ctx;
> > SVN_JNI_ERR(svn_client_create_context(&ctx, pool), NULL);
> >
> > - apr_array_header_t *providers
> > - = apr_array_make(pool, 10, sizeof(svn_auth_provider_object_t *));
> > + /* The whole list of registered providers */
> > + apr_array_header_t *providers;
> > +
> > + /* Populate the registered providers with the platform-specific providers */
> > + SVN_JNI_ERR(svn_auth_get_platform_specific_client_providers(&providers,
> > + pool), NULL);
> >
> > /* The main disk-caching auth providers, for both
> > * 'username/password' creds and 'username' creds. */
> > svn_auth_provider_object_t *provider;
> >
> > - /* Windows auth providers */
> > - SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "windows",
> > - "simple",
> > - pool),
> > - NULL);
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "windows",
> > - "ssl_client_cert_pw",
> > - pool),
> > - NULL);
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - /* Keychain auth providers */
> > - SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "keychain",
> > - "simple",
> > - pool),
> > - NULL);
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "keychain",
> > - "ssl_client_cert_pw",
> > - pool),
> > - NULL);
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - /* GNOME Keyring auth providers */
> > - SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "gnome_keyring",
> > - "simple",
> > - pool),
> > - NULL);
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "gnome_keyring",
> > - "ssl_client_cert_pw",
> > - pool),
> > - NULL);
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - /* KWallet auth providers */
> > - SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "kwallet",
> > - "simple",
> > - pool),
> > - NULL);
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "kwallet",
> > - "ssl_client_cert_pw",
> > - pool),
> > - NULL);
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > svn_auth_get_simple_provider(&provider, pool);
> > APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > svn_auth_get_username_provider(&provider, pool);
> >
> > Modified: trunk/subversion/include/svn_auth.h
> > URL: http://svn.collab.net/viewvc/svn/trunk/subversion/include/svn_auth.h?pathrev=34399&r1=34398&r2=34399
> > ==============================================================================
> > --- trunk/subversion/include/svn_auth.h Mon Nov 24 19:53:13 2008 (r34398)
> > +++ trunk/subversion/include/svn_auth.h Mon Nov 24 20:02:43 2008 (r34399)
> > @@ -805,6 +805,26 @@ svn_auth_get_platform_specific_provider(
> > const char *provider_type,
> > apr_pool_t *pool);
> >
> > +/** Create and return an array of <tt>svn_auth_provider_object_t *</tt> objects.
> > + * Only client auth providers available for the current platform are returned.
> > + *
> > + * Create and allocate @a *providers in @a pool.
> > + *
> > + * Can throw an error if the platform supports the "gnome_keyring" or the
> > + * "kwallet" auth provider and loading the respective shared library fails.
>
> This information is partially misleading, so I suggest to remove it in
> doc string of svn_auth_get_platform_specific_client_providers() and
> svn_auth_get_platform_specific_provider().
> These functions can return an error only when creating / locking /
> unlocking of DSO mutex fails.
> When loading of libsvn_auth_(kwallet|gnome_keyring) fails for other
> reasons, then no error is returned.
>
> > + *
> > + * Order of the platform-specific auth providers:
>
> s/Order/Default order/
>
> > + * 1. gnome-keyring
> > + * 2. kwallet
> > + * 3. keychain
> > + * 4. windows-cryptoapi
> > + *
> > + * @since New in 1.6.
> > + */
> > +svn_error_t *
> > +svn_auth_get_platform_specific_client_providers(apr_array_header_t **providers,
> > + apr_pool_t *pool);
> > +
> > #if (defined(WIN32) && !defined(__MINGW32__)) || defined(DOXYGEN)
> > /**
> > * Create and return @a *provider, an authentication provider of type @c
> >
> > Modified: trunk/subversion/libsvn_subr/auth.c
> > URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_subr/auth.c?pathrev=34399&r1=34398&r2=34399
> > ==============================================================================
> > --- trunk/subversion/libsvn_subr/auth.c Mon Nov 24 19:53:13 2008 (r34398)
> > +++ trunk/subversion/libsvn_subr/auth.c Mon Nov 24 20:02:43 2008 (r34399)
> > @@ -475,3 +475,82 @@ svn_auth_get_platform_specific_provider(
> >
> > return SVN_NO_ERROR;
> > }
> > +
> > +svn_error_t *
> > +svn_auth_get_platform_specific_client_providers(apr_array_header_t **providers,
> > + apr_pool_t *pool)
>
> This function should accept 'svn_config_t *config' argument and
> support 'password-stores' config option which was used in
> svn_cmdline_create_auth_baton().
> You can set password_stores_config_option to
> "gnome-keyring,kwallet,keychain,windows-cryptoapi" when config is
> NULL.
>
> > +{
> > + svn_auth_provider_object_t *provider;
> > +
> > + *providers = apr_array_make(pool, 12, sizeof(svn_auth_provider_object_t *));
> > +
> > + /* Gnome Keyring */
>
> s/Gnome/GNOME/
>
> > + SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > + "gnome_keyring",
> > + "simple",
> > + pool));
> > +
> > + if (provider)
> > + APR_ARRAY_PUSH(*providers, svn_auth_provider_object_t *) = provider;
> > +
> > + SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > + "gnome_keyring",
> > + "ssl_client_cert_pw",
> > + pool));
> > +
> > + if (provider)
> > + APR_ARRAY_PUSH(*providers, svn_auth_provider_object_t *) = provider;
> > +
> > + /* Kwallet */
>
> s/Kwallet/KWallet/
>
> > + SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > + "kwallet",
> > + "simple",
> > + pool));
> > +
> > + if (provider)
> > + APR_ARRAY_PUSH(*providers, svn_auth_provider_object_t *) = provider;
> > +
> > + SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > + "kwallet",
> > + "ssl_client_cert_pw",
> > + pool));
> > +
> > + if (provider)
> > + APR_ARRAY_PUSH(*providers, svn_auth_provider_object_t *) = provider;
> > +
> > + /* Keychain */
> > + SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > + "keychain",
> > + "simple",
> > + pool));
> > +
> > + if (provider)
> > + APR_ARRAY_PUSH(*providers, svn_auth_provider_object_t *) = provider;
> > +
> > + SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > + "keychain",
> > + "ssl_client_cert_pw",
> > + pool));
> > +
> > + if (provider)
> > + APR_ARRAY_PUSH(*providers, svn_auth_provider_object_t *) = provider;
> > +
> > + /* Windows */
> > + SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > + "windows",
> > + "simple",
> > + pool));
> > +
> > + if (provider)
> > + APR_ARRAY_PUSH(*providers, svn_auth_provider_object_t *) = provider;
> > +
> > + SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > + "windows",
> > + "ssl_client_cert_pw",
> > + pool));
> > +
> > + if (provider)
> > + APR_ARRAY_PUSH(*providers, svn_auth_provider_object_t *) = provider;
> > +
> > + return SVN_NO_ERROR;
> > +}
> >
> > Modified: trunk/subversion/libsvn_subr/cmdline.c
> > URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_subr/cmdline.c?pathrev=34399&r1=34398&r2=34399
> > ==============================================================================
> > --- trunk/subversion/libsvn_subr/cmdline.c Mon Nov 24 19:53:13 2008 (r34398)
> > +++ trunk/subversion/libsvn_subr/cmdline.c Mon Nov 24 20:02:43 2008 (r34399)
> > @@ -405,13 +405,12 @@ svn_cmdline_create_auth_baton(svn_auth_b
> > svn_boolean_t store_auth_creds_val = TRUE;
> > svn_auth_provider_object_t *provider;
> > svn_cmdline_prompt_baton2_t *pb = NULL;
> > - const char *password_stores_config_option;
> > - apr_array_header_t *password_stores;
> > - int i;
> >
> > /* The whole list of registered providers */
> > - apr_array_header_t *providers
> > - = apr_array_make(pool, 12, sizeof(svn_auth_provider_object_t *));
> > + apr_array_header_t *providers;
> > +
> > + /* Populate the registered providers with the platform-specific providers */
> > + SVN_ERR(svn_auth_get_platform_specific_client_providers(&providers, pool));
> >
> > /* If we have a cancellation function, cram it and the stuff it
> > needs into the prompt baton. */
> > @@ -423,110 +422,6 @@ svn_cmdline_create_auth_baton(svn_auth_b
> > pb->config_dir = config_dir;
> > }
> >
> > - /* Disk-caching auth providers, for both
> > - 'username/password' creds and 'username' creds,
> > - which store passwords encrypted. */
> > - svn_config_get(cfg,
> > - &password_stores_config_option,
> > - SVN_CONFIG_SECTION_AUTH,
> > - SVN_CONFIG_OPTION_PASSWORD_STORES,
> > - "gnome-keyring,kwallet,keychain,windows-cryptoapi");
> > -
> > - password_stores
> > - = svn_cstring_split(password_stores_config_option, " ,", TRUE, pool);
> > -
> > - for (i = 0; i < password_stores->nelts; i++)
> > - {
> > - const char *password_store = APR_ARRAY_IDX(password_stores, i,
> > - const char *);
> > - if (apr_strnatcmp(password_store, "keychain") == 0)
> > - {
> > - SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "keychain",
> > - "simple",
> > - pool));
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "keychain",
> > - "ssl_client_cert_pw",
> > - pool));
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - continue;
> > - }
> > -
> > - if (apr_strnatcmp(password_store, "windows-cryptoapi") == 0)
> > - {
> > - SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "windows",
> > - "simple",
> > - pool));
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - SVN_ERR(svn_auth_get_platform_specific_provider(&provider, "windows",
> > - "ssl_client_cert_pw",
> > - pool));
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - continue;
> > - }
> > -
> > - if (apr_strnatcmp(password_store, "gnome-keyring") == 0)
> > - {
> > - SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "gnome_keyring",
> > - "simple",
> > - pool));
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "gnome_keyring",
> > - "ssl_client_cert_pw",
> > - pool));
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - continue;
> > - }
> > -
> > - if (apr_strnatcmp(password_store, "kwallet") == 0)
> > - {
> > - SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "kwallet",
> > - "simple",
> > - pool));
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
> > - "kwallet",
> > - "ssl_client_cert_pw",
> > - pool));
> > -
> > - if (provider)
> > - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > -
> > - continue;
> > - }
> > - return svn_error_createf(SVN_ERR_BAD_CONFIG_VALUE, NULL,
> > - _("Invalid config: unknown password store "
> > - "'%s'"),
> > - password_store);
> > - }
> > -
> > if (non_interactive == FALSE)
> > {
> > /* This provider doesn't prompt the user in order to get creds;
> > @@ -539,6 +434,7 @@ svn_cmdline_create_auth_baton(svn_auth_b
> > {
> > svn_auth_get_simple_provider2(&provider, NULL, NULL, pool);
> > }
> > +
> > APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> > svn_auth_get_username_provider(&provider, pool);
> > APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
> >
> > Modified: trunk/subversion/tests/libsvn_subr/auth-test.c
> > URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/libsvn_subr/auth-test.c?pathrev=34399&r1=34398&r2=34399
> > ==============================================================================
> > --- trunk/subversion/tests/libsvn_subr/auth-test.c Mon Nov 24 19:53:13 2008 (r34398)
> > +++ trunk/subversion/tests/libsvn_subr/auth-test.c Mon Nov 24 20:02:43 2008 (r34399)
> > @@ -27,8 +27,9 @@ test_platform_specific_auth_providers(co
> > svn_test_opts_t *opts,
> > apr_pool_t *pool)
> > {
> > + apr_array_header_t *providers;
> > svn_auth_provider_object_t *provider;
> > - *msg = "test svn_auth_get_platform_provider";
> > + *msg = "test retrieving platform-specific auth providers";
> >
> > if (msg_only)
> > return SVN_NO_ERROR;
> > @@ -42,6 +43,23 @@ test_platform_specific_auth_providers(co
> > "svn_auth_get_platform_specific_provider('fake', 'fake') should " \
> > "return NULL");
> >
> > + /* Make sure you get two providers when retrieving all auth providers */
> > + svn_auth_get_platform_specific_client_providers(&providers, pool);
> > +
> > +#if defined(SVN_HAVE_KEYCHAIN_SERVICES) || defined(SVN_HAVE_GNOME_KEYRING) || defined(SVN_HAVE_KWALLET) || (defined(WIN32) && !defined(__MINGW32__))
> > + if (providers->nelts != 2)
> > + return svn_error_createf
> > + (SVN_ERR_TEST_FAILED, NULL,
> > + "svn_auth_get_platform_specific_client_providers should return " \
> > + "an array of two providers");
> > +#else
> > + if (providers->nelts != 0)
> > + return svn_error_createf
> > + (SVN_ERR_TEST_FAILED, NULL,
> > + "svn_auth_get_platform_specific_client_providers should return " \
> > + "an array of zero providers");
> > +#endif
> > +
> > /* Test Keychain auth providers */
> > #ifdef SVN_HAVE_KEYCHAIN_SERVICES
> > svn_auth_get_platform_specific_provider(&provider, "keychain", "simple",
> >
Fixed in r34471 and r34472.
--
Arfrever Frehtes Taifersar Arahesis
Received on 2008-11-29 19:35:51 CET