subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmpil...@apache.org
Subject svn commit: r1363892 - in /subversion/branches/master-passphrase/subversion: include/ libsvn_subr/
Date Fri, 20 Jul 2012 18:31:28 GMT
Author: cmpilato
Date: Fri Jul 20 18:31:27 2012
New Revision: 1363892

URL: http://svn.apache.org/viewvc?rev=1363892&view=rev
Log:
On the 'master-passphrase' branch: Use the auth baton parameters to
cache an auth store reference.  (At this point -- if not earlier --
I'm drifting into territory that will likely prove controversial
should I seek to propose a trunk merge.)

* subversion/include/svn_auth.h
  (SVN_AUTH_PARAM_AUTH_STORE): New #define.

* subversion/libsvn_subr/auth_store.h
* subversion/libsvn_subr/auth_store.c
  (svn_auth__get_store_from_parameters): New function.

* subversion/libsvn_subr/simple_providers.c
  (svn_auth__simple_creds_cache_get, svn_auth__simple_creds_cache_set,
   prompt_for_simple_creds): Use svn_auth__get_store_from_parameters()
    and switch to new auth_store.h interfaces.

* subversion/libsvn_subr/ssl_client_cert_pw_providers.c
  (svn_auth__ssl_client_cert_pw_cache_get,
   svn_auth__ssl_client_cert_pw_cache_set): Use
    svn_auth__get_store_from_parameters() and switch to new
    auth_store.h interfaces.

* subversion/libsvn_subr/ssl_server_trust_providers.c
  (ssl_server_trust_file_first_credentials,
   ssl_server_trust_file_save_credentials): Use
    svn_auth__get_store_from_parameters() and switch to new
    auth_store.h interfaces.

* subversion/libsvn_subr/username_providers.c
  (username_first_creds, username_save_creds): Use
    svn_auth__get_store_from_parameters() and switch to new
    auth_store.h interfaces.

Modified:
    subversion/branches/master-passphrase/subversion/include/svn_auth.h
    subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.c
    subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h
    subversion/branches/master-passphrase/subversion/libsvn_subr/simple_providers.c
    subversion/branches/master-passphrase/subversion/libsvn_subr/ssl_client_cert_pw_providers.c
    subversion/branches/master-passphrase/subversion/libsvn_subr/ssl_server_trust_providers.c
    subversion/branches/master-passphrase/subversion/libsvn_subr/username_providers.c

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=1363892&r1=1363891&r2=1363892&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/include/svn_auth.h (original)
+++ subversion/branches/master-passphrase/subversion/include/svn_auth.h Fri Jul 20 18:31:27
2012
@@ -688,6 +688,13 @@ svn_auth_get_parameter(svn_auth_baton_t 
  * ~/.subversion. */
 #define SVN_AUTH_PARAM_CONFIG_DIR SVN_AUTH_PARAM_PREFIX "config-dir"
 
+/** @brief A pointer to the svn_auth__store_t object used to get/set
+ * cached authentication credentials.
+ *
+ * @since New in 1.8.
+ */
+#define SVN_AUTH_PARAM_AUTH_STORE SVN_AUTH_PARAM_PREFIX "auth-store"
+
 /** Get an initial set of credentials.
  *
  * Ask @a auth_baton to set @a *credentials to a set of credentials

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.c?rev=1363892&r1=1363891&r2=1363892&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.c Fri Jul 20 18:31:27
2012
@@ -323,3 +323,30 @@ svn_auth__store_set_simple_creds(svn_boo
                                         cred_hash, scratch_pool));
   return SVN_NO_ERROR;
 }
+
+
+svn_error_t *
+svn_auth__get_store_from_parameters(svn_auth__store_t **auth_store,
+                                    apr_hash_t *parameters,
+                                    apr_pool_t *pool)
+{
+  *auth_store = apr_hash_get(parameters,
+                             SVN_AUTH_PARAM_AUTH_STORE,
+                             APR_HASH_KEY_STRING);
+  if (! *auth_store)
+    {
+      const char *config_dir = apr_hash_get(parameters,
+                                            SVN_AUTH_PARAM_CONFIG_DIR,
+                                            APR_HASH_KEY_STRING);
+      SVN_ERR(svn_auth__config_store_get(auth_store, config_dir,
+                                         apr_hash_pool_get(parameters),
+                                         pool));
+      SVN_ERR(svn_auth__store_open(*auth_store, FALSE, pool));
+      apr_hash_set(parameters,
+                   SVN_AUTH_PARAM_AUTH_STORE,
+                   APR_HASH_KEY_STRING,
+                   auth_store);
+    }
+  
+  return SVN_NO_ERROR;
+}

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h?rev=1363892&r1=1363891&r2=1363892&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h Fri Jul 20 18:31:27
2012
@@ -250,6 +250,9 @@ svn_auth__config_store_get(svn_auth__sto
 
 
 
+
+/*** Store Functionality ***/
+
 /* Set *CREDS_P to the "username" credentials from AUTH_STORE which
    match REALMSTRING, if any.
 
@@ -304,6 +307,18 @@ svn_auth__store_set_simple_creds(svn_boo
                                  apr_pool_t *scratch_pool);
 
 
+
+/*** Convenience/compatibility functions ***/
+
+/* Set *AUTH_STORE to the authentication store object found in
+   PARAMETERS, if any; otherwise, open a config-based store, cache it
+   in PARAMETERS, and return it. */
+svn_error_t *
+svn_auth__get_store_from_parameters(svn_auth__store_t **auth_store,
+                                    apr_hash_t *parameters,
+                                    apr_pool_t *pool);
+
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/simple_providers.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/simple_providers.c?rev=1363892&r1=1363891&r2=1363892&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/simple_providers.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/simple_providers.c Fri Jul
20 18:31:27 2012
@@ -33,6 +33,7 @@
 #include "svn_utf.h"
 #include "svn_config.h"
 #include "svn_user.h"
+#include "auth_store.h"
 
 #include "private/svn_auth_private.h"
 
@@ -138,9 +139,6 @@ svn_auth__simple_creds_cache_get(void **
                                  const char *passtype,
                                  apr_pool_t *pool)
 {
-  const char *config_dir = apr_hash_get(parameters,
-                                        SVN_AUTH_PARAM_CONFIG_DIR,
-                                        APR_HASH_KEY_STRING);
   svn_config_t *cfg = apr_hash_get(parameters,
                                    SVN_AUTH_PARAM_CONFIG_CATEGORY_SERVERS,
                                    APR_HASH_KEY_STRING);
@@ -165,14 +163,18 @@ svn_auth__simple_creds_cache_get(void **
   apr_hash_t *creds_hash = NULL;
   svn_error_t *err;
   svn_string_t *str;
-
-  /* Try to load credentials from a file on disk, based on the
+  svn_auth__store_t *auth_store;
+ 
+  /* Try to load credentials from the store, based on the
      realmstring.  Don't throw an error, though: if something went
-     wrong reading the file, no big deal.  What really matters is that
+     wrong reading the store, no big deal.  What really matters is that
      we failed to get the creds, so allow the auth system to try the
      next provider. */
-  err = svn_config_read_auth_data(&creds_hash, SVN_AUTH_CRED_SIMPLE,
-                                  realmstring, config_dir, pool);
+  err = svn_auth__get_store_from_parameters(&auth_store, parameters, pool);
+  if (! err)
+    err = svn_auth__store_get_cred_hash(&creds_hash, auth_store,
+                                        SVN_AUTH_CRED_SIMPLE,
+                                        realmstring, pool, pool);
   if (err)
     {
       svn_error_clear(err);
@@ -313,6 +315,7 @@ svn_auth__simple_creds_cache_set(svn_boo
   apr_hash_t *creds_hash = NULL;
   const char *config_dir;
   svn_error_t *err;
+  svn_auth__store_t *auth_store;
   svn_boolean_t dont_store_passwords =
     apr_hash_get(parameters,
                  SVN_AUTH_PARAM_DONT_STORE_PASSWORDS,
@@ -473,8 +476,15 @@ svn_auth__simple_creds_cache_set(svn_boo
     }
 
   /* Save credentials to disk. */
-  err = svn_config_write_auth_data(creds_hash, SVN_AUTH_CRED_SIMPLE,
-                                   realmstring, config_dir, pool);
+  err = svn_auth__get_store_from_parameters(&auth_store, parameters, pool);
+  if (! err)
+    {
+      svn_boolean_t stored;
+
+      err = svn_auth__store_set_cred_hash(&stored, auth_store,
+                                          SVN_AUTH_CRED_SIMPLE,
+                                          realmstring, creds_hash, pool);
+    }
   svn_error_clear(err);
 
   return SVN_NO_ERROR;
@@ -592,15 +602,17 @@ prompt_for_simple_creds(svn_auth_cred_si
       /* No default username?  Try the auth cache. */
       if (! default_username)
         {
-          const char *config_dir = apr_hash_get(parameters,
-                                                SVN_AUTH_PARAM_CONFIG_DIR,
-                                                APR_HASH_KEY_STRING);
           apr_hash_t *creds_hash = NULL;
           svn_string_t *str;
           svn_error_t *err;
+          svn_auth__store_t *auth_store;
 
-          err = svn_config_read_auth_data(&creds_hash, SVN_AUTH_CRED_SIMPLE,
-                                          realmstring, config_dir, pool);
+          err = svn_auth__get_store_from_parameters(&auth_store, parameters,
+                                                    pool);
+          if (! err)
+            err = svn_auth__store_get_cred_hash(&creds_hash, auth_store,
+                                                SVN_AUTH_CRED_SIMPLE,
+                                                realmstring, pool, pool);
           svn_error_clear(err);
           if (! err && creds_hash)
             {

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/ssl_client_cert_pw_providers.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/ssl_client_cert_pw_providers.c?rev=1363892&r1=1363891&r2=1363892&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/ssl_client_cert_pw_providers.c
(original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/ssl_client_cert_pw_providers.c
Fri Jul 20 18:31:27 2012
@@ -29,6 +29,7 @@
 #include "svn_error.h"
 #include "svn_config.h"
 #include "svn_string.h"
+#include "auth_store.h"
 
 #include "private/svn_auth_private.h"
 
@@ -130,14 +131,14 @@ svn_auth__ssl_client_cert_pw_cache_get(v
     {
       svn_error_t *err;
       apr_hash_t *creds_hash = NULL;
-      const char *config_dir = apr_hash_get(parameters,
-                                            SVN_AUTH_PARAM_CONFIG_DIR,
-                                            APR_HASH_KEY_STRING);
+      svn_auth__store_t *auth_store;
 
       /* Try to load passphrase from the auth/ cache. */
-      err = svn_config_read_auth_data(&creds_hash,
-                                      SVN_AUTH_CRED_SSL_CLIENT_CERT_PW,
-                                      realmstring, config_dir, pool);
+      err = svn_auth__get_store_from_parameters(&auth_store, parameters, pool);
+      if (! err)
+        err = svn_auth__store_get_cred_hash(&creds_hash, auth_store,
+                                            SVN_AUTH_CRED_SSL_CLIENT_CERT_PW,
+                                            realmstring, pool, pool);
       svn_error_clear(err);
       if (! err && creds_hash)
         {
@@ -176,7 +177,6 @@ svn_auth__ssl_client_cert_pw_cache_set(s
 {
   svn_auth_cred_ssl_client_cert_pw_t *creds = credentials;
   apr_hash_t *creds_hash = NULL;
-  const char *config_dir;
   svn_error_t *err;
   svn_boolean_t dont_store_passphrase =
     apr_hash_get(parameters,
@@ -195,9 +195,6 @@ svn_auth__ssl_client_cert_pw_cache_set(s
   if (no_auth_cache)
     return SVN_NO_ERROR;
 
-  config_dir = apr_hash_get(parameters,
-                            SVN_AUTH_PARAM_CONFIG_DIR,
-                            APR_HASH_KEY_STRING);
   creds_hash = apr_hash_make(pool);
 
   /* Don't store passphrase in any form if the user has told
@@ -311,6 +308,8 @@ svn_auth__ssl_client_cert_pw_cache_set(s
 
       if (may_save_passphrase)
         {
+          svn_auth__store_t *auth_store;
+
           SVN_ERR(passphrase_set(saved, creds_hash, realmstring,
                                  NULL, creds->password, parameters,
                                  non_interactive, pool));
@@ -323,11 +322,15 @@ svn_auth__ssl_client_cert_pw_cache_set(s
             }
 
           /* Save credentials to disk. */
-          err = svn_config_write_auth_data(creds_hash,
-                                           SVN_AUTH_CRED_SSL_CLIENT_CERT_PW,
-                                           realmstring, config_dir, pool);
+          err = svn_auth__get_store_from_parameters(&auth_store, parameters,
+                                                    pool);
+          if (! err)
+            {
+              err = svn_auth__store_set_cred_hash(
+                        saved, auth_store, SVN_AUTH_CRED_SSL_CLIENT_CERT_PW,
+                        realmstring, creds_hash, pool);
+            }
           svn_error_clear(err);
-          *saved = ! err;
         }
     }
 

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/ssl_server_trust_providers.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/ssl_server_trust_providers.c?rev=1363892&r1=1363891&r2=1363892&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/ssl_server_trust_providers.c
(original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/ssl_server_trust_providers.c
Fri Jul 20 18:31:27 2012
@@ -28,6 +28,7 @@
 #include "svn_error.h"
 #include "svn_config.h"
 #include "svn_string.h"
+#include "auth_store.h"
 
 
 /*-----------------------------------------------------------------------*/
@@ -58,19 +59,18 @@ ssl_server_trust_file_first_credentials(
                  SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO,
                  APR_HASH_KEY_STRING);
   apr_hash_t *creds_hash = NULL;
-  const char *config_dir;
+  svn_auth__store_t *auth_store;
   svn_error_t *error = SVN_NO_ERROR;
 
   *credentials = NULL;
   *iter_baton = NULL;
 
   /* Check if this is a permanently accepted certificate */
-  config_dir = apr_hash_get(parameters,
-                            SVN_AUTH_PARAM_CONFIG_DIR,
-                            APR_HASH_KEY_STRING);
-  error =
-    svn_config_read_auth_data(&creds_hash, SVN_AUTH_CRED_SSL_SERVER_TRUST,
-                              realmstring, config_dir, pool);
+  error = svn_auth__get_store_from_parameters(&auth_store, parameters, pool);
+  if (! error)
+    error = svn_auth__store_get_cred_hash(&creds_hash, auth_store,
+                                          SVN_AUTH_CRED_SSL_SERVER_TRUST,
+                                          realmstring, pool, pool);
   svn_error_clear(error);
   if (! error && creds_hash)
     {
@@ -126,15 +126,11 @@ ssl_server_trust_file_save_credentials(s
   svn_auth_cred_ssl_server_trust_t *creds = credentials;
   const svn_auth_ssl_server_cert_info_t *cert_info;
   apr_hash_t *creds_hash = NULL;
-  const char *config_dir;
+  svn_auth__store_t *auth_store;
 
   if (! creds->may_save)
     return SVN_NO_ERROR;
 
-  config_dir = apr_hash_get(parameters,
-                            SVN_AUTH_PARAM_CONFIG_DIR,
-                            APR_HASH_KEY_STRING);
-
   cert_info = apr_hash_get(parameters,
                            SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO,
                            APR_HASH_KEY_STRING);
@@ -146,12 +142,10 @@ ssl_server_trust_file_save_credentials(s
                svn_string_createf(pool, "%lu", (unsigned long)
                                   creds->accepted_failures));
 
-  SVN_ERR(svn_config_write_auth_data(creds_hash,
-                                     SVN_AUTH_CRED_SSL_SERVER_TRUST,
-                                     realmstring,
-                                     config_dir,
-                                     pool));
-  *saved = TRUE;
+  SVN_ERR(svn_auth__get_store_from_parameters(&auth_store, parameters, pool));
+  SVN_ERR(svn_auth__store_set_cred_hash(saved, auth_store,
+                                        SVN_AUTH_CRED_SSL_SERVER_TRUST,
+                                        realmstring, creds_hash, pool));
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/username_providers.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/username_providers.c?rev=1363892&r1=1363891&r2=1363892&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/username_providers.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/username_providers.c Fri
Jul 20 18:31:27 2012
@@ -33,6 +33,7 @@
 #include "svn_utf.h"
 #include "svn_config.h"
 #include "svn_user.h"
+#include "auth_store.h"
 
 
 /*-----------------------------------------------------------------------*/
@@ -54,9 +55,6 @@ username_first_creds(void **credentials,
                      const char *realmstring,
                      apr_pool_t *pool)
 {
-  const char *config_dir = apr_hash_get(parameters,
-                                        SVN_AUTH_PARAM_CONFIG_DIR,
-                                        APR_HASH_KEY_STRING);
   const char *username = apr_hash_get(parameters,
                                       SVN_AUTH_PARAM_DEFAULT_USERNAME,
                                       APR_HASH_KEY_STRING);
@@ -67,14 +65,18 @@ username_first_creds(void **credentials,
   if (! username)
     {
       apr_hash_t *creds_hash = NULL;
+      svn_auth__store_t *auth_store;
 
-      /* Try to load credentials from a file on disk, based on the
+      /* Try to load credentials from the store, based on the
          realmstring.  Don't throw an error, though: if something went
-         wrong reading the file, no big deal.  What really matters is that
+         wrong reading the store, no big deal.  What really matters is that
          we failed to get the creds, so allow the auth system to try the
          next provider. */
-      err = svn_config_read_auth_data(&creds_hash, SVN_AUTH_CRED_USERNAME,
-                                      realmstring, config_dir, pool);
+      err = svn_auth__get_store_from_parameters(&auth_store, parameters, pool);
+      if (! err)
+        err = svn_auth__store_get_cred_hash(&creds_hash, auth_store,
+                                            SVN_AUTH_CRED_USERNAME,
+                                            realmstring, pool, pool);
       svn_error_clear(err);
       if (! err && creds_hash)
         {
@@ -115,7 +117,7 @@ username_save_creds(svn_boolean_t *saved
 {
   svn_auth_cred_simple_t *creds = credentials;
   apr_hash_t *creds_hash = NULL;
-  const char *config_dir;
+  svn_auth__store_t *auth_store;
   svn_error_t *err;
 
   *saved = FALSE;
@@ -123,16 +125,20 @@ username_save_creds(svn_boolean_t *saved
   if (! creds->may_save)
     return SVN_NO_ERROR;
 
-  config_dir = apr_hash_get(parameters,
-                            SVN_AUTH_PARAM_CONFIG_DIR,
-                            APR_HASH_KEY_STRING);
-
   /* Put the credentials in a hash and save it to disk */
   creds_hash = apr_hash_make(pool);
   apr_hash_set(creds_hash, AUTHN_USERNAME_KEY, APR_HASH_KEY_STRING,
                svn_string_create(creds->username, pool));
-  err = svn_config_write_auth_data(creds_hash, SVN_AUTH_CRED_USERNAME,
-                                   realmstring, config_dir, pool);
+
+  err = svn_auth__get_store_from_parameters(&auth_store, parameters, pool);
+  if (! err)
+    {
+      svn_boolean_t stored;
+
+      err = svn_auth__store_set_cred_hash(&stored, auth_store,
+                                          SVN_AUTH_CRED_USERNAME,
+                                          realmstring, creds_hash, pool);
+    }
   svn_error_clear(err);
   *saved = ! err;
 



Mime
View raw message