You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2012/08/13 21:31:48 UTC
svn commit: r1372560 - in /subversion/branches/master-passphrase/subversion:
include/svn_auth.h libsvn_auth_kwallet/kwallet.cpp
Author: cmpilato
Date: Mon Aug 13 19:31:47 2012
New Revision: 1372560
URL: http://svn.apache.org/viewvc?rev=1372560&view=rev
Log:
On the 'master-passphrase' branch: implement the KDE Wallet master
passphrase provider.
Disclaimer: I'm not setup to compile against KDE, so ... this may be
completely broken.
* subversion/include/svn_auth.h
(svn_auth_get_kwallet_master_passphrase_provider): New function.
* subversion/libsvn_auth_kwallet/kwallet.cpp
(kwallet_master_passphrase_first_creds,
kwallet_master_passphrase_save_creds,
svn_auth_get_kwallet_master_passphrase_provider): New functions.
(kwallet_master_passphrase_provider): New static structure instance.
Modified:
subversion/branches/master-passphrase/subversion/include/svn_auth.h
subversion/branches/master-passphrase/subversion/libsvn_auth_kwallet/kwallet.cpp
Modified: subversion/branches/master-passphrase/subversion/include/svn_auth.h
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/include/svn_auth.h?rev=1372560&r1=1372559&r2=1372560&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/include/svn_auth.h (original)
+++ subversion/branches/master-passphrase/subversion/include/svn_auth.h Mon Aug 13 19:31:47 2012
@@ -1396,6 +1396,21 @@ svn_auth_get_gnome_keyring_master_passph
svn_auth_provider_object_t **provider,
apr_pool_t *pool);
+
+/** Set @a *provider to an authentication provider of type @c
+ * svn_auth_cred_master_passphrase_t, allocated in @a pool.
+ *
+ * @a *provider retrieves its credentials via KDE Wallet. The
+ * returned credentials are used to unlock Subversion's encrypted
+ * authentication credential store.
+ *
+ * @since New in 1.8.
+ */
+void
+svn_auth_get_kwallet_master_passphrase_provider(
+ svn_auth_provider_object_t **provider,
+ apr_pool_t *pool);
+
#ifdef __cplusplus
}
Modified: subversion/branches/master-passphrase/subversion/libsvn_auth_kwallet/kwallet.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_auth_kwallet/kwallet.cpp?rev=1372560&r1=1372559&r2=1372560&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_auth_kwallet/kwallet.cpp (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_auth_kwallet/kwallet.cpp Mon Aug 13 19:31:47 2012
@@ -453,3 +453,86 @@ svn_auth_get_kwallet_ssl_client_cert_pw_
*provider = po;
}
}
+
+
+
+/*-----------------------------------------------------------------------*/
+/* KWallet master passphrase provider. */
+/*-----------------------------------------------------------------------*/
+
+/* Get cached encrypted credentials from the ssl client cert password
+ provider's cache. */
+static svn_error_t *
+kwallet_master_passphrase_first_creds(void **credentials,
+ void **iter_baton,
+ void *provider_baton,
+ apr_hash_t *parameters,
+ const char *realmstring,
+ apr_pool_t *pool)
+{
+ svn_boolean_t done;
+ const char *passphrase;
+ svn_boolean_t non_interactive = apr_hash_get(parameters,
+ SVN_AUTH_PARAM_NON_INTERACTIVE,
+ APR_HASH_KEY_STRING) != NULL;
+
+ *credentials = NULL;
+
+ SVN_ERR(kwallet_password_get(&done, &passphrase, NULL, realmstring,
+ NULL, parameters, non_interactive, pool));
+ if (done && passphrase)
+ {
+ svn_auth_cred_master_passphrase_t *creds;
+ creds = apr_pcalloc(pool, sizeof(*creds));
+ creds->passphrase =
+ svn_base64_decode_string(svn_string_create(passphrase, pool), pool);
+ *credentials = creds;
+ }
+
+ return SVN_NO_ERROR;
+}
+
+/* Save encrypted credentials to the ssl client cert password provider's
+ cache. */
+static svn_error_t *
+kwallet_master_passphrase_save_creds(svn_boolean_t *saved,
+ void *credentials,
+ void *provider_baton,
+ apr_hash_t *parameters,
+ const char *realmstring,
+ apr_pool_t *pool)
+{
+ svn_auth_cred_master_passphrase_t *creds = credentials;
+ svn_boolean_t non_interactive = apr_hash_get(parameters,
+ SVN_AUTH_PARAM_NON_INTERACTIVE,
+ APR_HASH_KEY_STRING) != NULL;
+ const svn_string_t *encoded_passphrase =
+ svn_base64_encode_string2(creds->passphrase, FALSE, pool);
+
+ SVN_ERR(kwallet_password_set(saved, NULL, realmstring, NULL,
+ encoded_passphrase->data,
+ parameters, non_interactive, pool));
+ return SVN_NO_ERROR;
+}
+
+static const svn_auth_provider_t kwallet_master_passphrase_provider = {
+ SVN_AUTH_CRED_MASTER_PASSPHRASE,
+ kwallet_master_passphrase_first_creds,
+ NULL,
+ kwallet_master_passphrase_save_creds
+};
+
+/* Public API */
+extern "C" {
+void
+svn_auth_get_kwallet_master_passphrase_provider
+ (svn_auth_provider_object_t **provider,
+ apr_pool_t *pool)
+{
+ svn_auth_provider_object_t *po =
+ static_cast<svn_auth_provider_object_t *> (apr_pcalloc(pool, sizeof(*po)));
+
+ po->vtable = &kwallet_master_passphrase_provider;
+ *provider = po;
+}
+}