You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2012/12/06 23:03:42 UTC

svn commit: r1418106 - in /subversion/branches/in-repo-authz/subversion/libsvn_repos: authz.c deprecated.c repos.h

Author: breser
Date: Thu Dec  6 22:03:41 2012
New Revision: 1418106

URL: http://svn.apache.org/viewvc?rev=1418106&view=rev
Log:
On the in-repo-authz branch: Refactor the implementation of
svn_repos_authz_read() and svn_repos_authz_read2() to be shared.

* subversion/libsvn_repos/authz.c
  (svn_repos__authz_read) New internal function to implement the
    guts of svn_repos_authz_read*().
  (svn_repos_authz_read): Removed.
  (svn_repos_authz_read2): Changed to just a wrapper of the new internal
    function.

* subversion/libsvn_repos/deprecated.c
  (svn_repos_authz_read): Moved from authz.c and changed to a wrapper for
    svn_repos__authz_read().
  
* subversion/libsvn_repos/repos.h
  (svn_repos__authz_read): Added.


Modified:
    subversion/branches/in-repo-authz/subversion/libsvn_repos/authz.c
    subversion/branches/in-repo-authz/subversion/libsvn_repos/deprecated.c
    subversion/branches/in-repo-authz/subversion/libsvn_repos/repos.h

Modified: subversion/branches/in-repo-authz/subversion/libsvn_repos/authz.c
URL: http://svn.apache.org/viewvc/subversion/branches/in-repo-authz/subversion/libsvn_repos/authz.c?rev=1418106&r1=1418105&r2=1418106&view=diff
==============================================================================
--- subversion/branches/in-repo-authz/subversion/libsvn_repos/authz.c (original)
+++ subversion/branches/in-repo-authz/subversion/libsvn_repos/authz.c Thu Dec  6 22:03:41 2012
@@ -904,21 +904,22 @@ authz_retrieve_config(svn_config_t **cfg
   return SVN_NO_ERROR;
 }
 
-
-
-/*** Public functions. ***/
-
 svn_error_t *
-svn_repos_authz_read2(svn_authz_t **authz_p, const char *path,
-                      svn_boolean_t must_exist, const char *repos_root,
-                      apr_pool_t *pool)
+svn_repos__authz_read(svn_authz_t **authz_p, const char *path,
+                      svn_boolean_t must_exist, svn_boolean_t accept_urls,
+                      const char *repos_root, apr_pool_t *pool)
 {
   svn_authz_t *authz = apr_palloc(pool, sizeof(*authz));
   struct authz_validate_baton baton = { 0 };
 
   baton.err = SVN_NO_ERROR;
-  SVN_ERR(authz_retrieve_config(&authz->cfg, path, must_exist, repos_root,
-                                pool));
+
+  /* Load the rule file */
+  if (accept_urls)
+    SVN_ERR(authz_retrieve_config(&authz->cfg, path, must_exist, repos_root,
+                                  pool));
+  else
+    SVN_ERR(svn_config_read2(&authz->cfg, path, must_exist, TRUE, pool));
   baton.config = authz->cfg;
 
   /* Step through the entire rule file, stopping on error. */
@@ -930,27 +931,20 @@ svn_repos_authz_read2(svn_authz_t **auth
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_repos_authz_read(svn_authz_t **authz_p, const char *file,
-                     svn_boolean_t must_exist, apr_pool_t *pool)
-{
-  svn_authz_t *authz = apr_palloc(pool, sizeof(*authz));
-  struct authz_validate_baton baton = { 0 };
 
-  baton.err = SVN_NO_ERROR;
+
+/*** Public functions. ***/
 
-  /* Load the rule file. */
-  SVN_ERR(svn_config_read2(&authz->cfg, file, must_exist, TRUE, pool));
-  baton.config = authz->cfg;
+svn_error_t *
+svn_repos_authz_read2(svn_authz_t **authz_p, const char *path,
+                      svn_boolean_t must_exist, const char *repos_root,
+                      apr_pool_t *pool)
+{
+  return svn_repos__authz_read(authz_p, path, must_exist, TRUE, repos_root,
+                               pool);
+}
 
-  /* Step through the entire rule file, stopping on error. */
-  svn_config_enumerate_sections2(authz->cfg, authz_validate_section,
-                                 &baton, pool);
-  SVN_ERR(baton.err);
 
-  *authz_p = authz;
-  return SVN_NO_ERROR;
-}
 
 svn_error_t *
 svn_repos_authz_check_access(svn_authz_t *authz, const char *repos_name,

Modified: subversion/branches/in-repo-authz/subversion/libsvn_repos/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/branches/in-repo-authz/subversion/libsvn_repos/deprecated.c?rev=1418106&r1=1418105&r2=1418106&view=diff
==============================================================================
--- subversion/branches/in-repo-authz/subversion/libsvn_repos/deprecated.c (original)
+++ subversion/branches/in-repo-authz/subversion/libsvn_repos/deprecated.c Thu Dec  6 22:03:41 2012
@@ -1006,3 +1006,12 @@ svn_repos_fs_begin_txn_for_update(svn_fs
 
   return SVN_NO_ERROR;
 }
+
+/*** From authz.c ***/
+
+svn_error_t *
+svn_repos_authz_read(svn_authz_t **authz_p, const char *file,
+                     svn_boolean_t must_exist, apr_pool_t *pool)
+{
+  return svn_repos__authz_read(authz_p, file, must_exist, FALSE, NULL, pool);
+}

Modified: subversion/branches/in-repo-authz/subversion/libsvn_repos/repos.h
URL: http://svn.apache.org/viewvc/subversion/branches/in-repo-authz/subversion/libsvn_repos/repos.h?rev=1418106&r1=1418105&r2=1418106&view=diff
==============================================================================
--- subversion/branches/in-repo-authz/subversion/libsvn_repos/repos.h (original)
+++ subversion/branches/in-repo-authz/subversion/libsvn_repos/repos.h Thu Dec  6 22:03:41 2012
@@ -304,6 +304,31 @@ svn_repos__hooks_post_unlock(svn_repos_t
                              apr_pool_t *pool);
 
 
+/*** Authz Functions ***/
+
+/* Read authz configuration data from PATH into *AUTHZ_P, allocated
+   in POOL.
+  
+   PATH may be a file or a registry path and iff ACCEPT_URLS is set
+   it may also be a repos relative url or an absolute file url.  When
+   ACCEPT_URLS is FALSE REPOS_ROOT can be NULL.
+  
+   If PATH is not a valid authz rule file, then return 
+   SVN_AUTHZ_INVALID_CONFIG.  The contents of *AUTHZ_P is then
+   undefined.  If MUST_EXIST is TRUE, a missing authz file is also
+   an error.
+  
+   If PATH is a repos relative URL then REPOS_ROOT must be set to
+   the root of the repository the authz configuration will be used with. */
+svn_error_t *
+svn_repos__authz_read(svn_authz_t **authz_p,
+                      const char *path,
+                      svn_boolean_t must_exist,
+                      svn_boolean_t accept_urls,
+                      const char *repos_root,
+                      apr_pool_t *pool);
+
+
 /*** Utility Functions ***/
 
 /* Set *CHANGED_P to TRUE if ROOT1/PATH1 and ROOT2/PATH2 have