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 2013/01/29 18:39:59 UTC

svn commit: r1440023 - in /subversion/trunk/subversion: include/svn_repos.h libsvn_repos/authz.c tests/cmdline/svnauthz_tests.py

Author: breser
Date: Tue Jan 29 17:39:58 2013
New Revision: 1440023

URL: http://svn.apache.org/viewvc?rev=1440023&view=rev
Log:
Resolve incorrect exit code from svnauthz when testing a non-existant url.

* subversion/include/svn_repos.h
  (svn_repos_authz_read2): Improve the documentation to be clear that
    SVN_ERR_AUTHZ_INVALID_CONFIG is only returned for validation failures
    and not for missing files.

* subversion/libsvn_repos/authz.c
  (authz_retrieve_config_repo): Never return SVN_AUTHZ_INVALID_CONFIG since
    all of these error paths are not validation errors but some sort of  
    operational error like invalid paths.  Documentation adjusted to match.
  (authz_retrieve_config): This never returns SVN_AUTHZ_INVALID_CONFIG,
    documentation adjusted to reflect this.

* subversion/tests/cmdline/svnauthz_tests.py
  (svnauthz_validate_repo_test, svnauthz_compat_mode_repo_test): Adjust
    the expected return code for the two tests that test non-existant urls.

Modified:
    subversion/trunk/subversion/include/svn_repos.h
    subversion/trunk/subversion/libsvn_repos/authz.c
    subversion/trunk/subversion/tests/cmdline/svnauthz_tests.py

Modified: subversion/trunk/subversion/include/svn_repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_repos.h?rev=1440023&r1=1440022&r2=1440023&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_repos.h (original)
+++ subversion/trunk/subversion/include/svn_repos.h Tue Jan 29 17:39:58 2013
@@ -3177,7 +3177,8 @@ svn_repos_authz_read(svn_authz_t **authz
  * If @a path or @a groups_path is not a valid authz rule file, then return
  * #SVN_ERR_AUTHZ_INVALID_CONFIG.  The contents of @a *authz_p is then
  * undefined.  If @a must_exist is TRUE, a missing authz or groups file
- * is also an error.
+ * is also an error other than #SVN_ERR_AUTHZ_INVALID_CONFIG (exact error
+ * depends on the access type).
  *
  * If @a path is a repos relative URL then @a repos_root must be set to
  * the root of the repository the authz configuration will be used with.

Modified: subversion/trunk/subversion/libsvn_repos/authz.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/authz.c?rev=1440023&r1=1440022&r2=1440023&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/authz.c (original)
+++ subversion/trunk/subversion/libsvn_repos/authz.c Tue Jan 29 17:39:58 2013
@@ -771,9 +771,9 @@ authz_validate(svn_authz_t *authz, apr_p
 /* Retrieve the file at DIRENT (contained in a repo) then parse it as a config
  * file placing the result into CFG_P allocated in POOL.
  *
- * If DIRENT is not a valid authz rule file then return SVN_AUTHZ_INVALD_CONFIG
- * as the error.  The contents of CFG_P is then undefined.  If MUST_EXIST is
- * TRUE, a missing authz file is also an error.
+ * If DIRENT cannot be parsed as a config file then an error is returned.  The
+ * contents of CFG_P is then undefined.  If MUST_EXIST is TRUE, a missing
+ * authz file is also an error.
  *
  * SCRATCH_POOL will be used for temporary allocations. */
 static svn_error_t *
@@ -794,7 +794,7 @@ authz_retrieve_config_repo(svn_config_t 
   /* Search for a repository in the full path. */
   repos_root_dirent = svn_repos_find_root_path(dirent, scratch_pool);
   if (!repos_root_dirent)
-    return svn_error_createf(SVN_ERR_AUTHZ_INVALID_CONFIG, NULL,
+    return svn_error_createf(SVN_ERR_RA_LOCAL_REPOS_NOT_FOUND, NULL,
                              "Unable to find repository at '%s'", dirent);
 
   /* Attempt to open a repository at repos_root_dirent. */
@@ -804,7 +804,7 @@ authz_retrieve_config_repo(svn_config_t 
 
   /* Root path is always a directory so no reason to go any further */
   if (*fs_path == '\0')
-    return svn_error_createf(SVN_ERR_AUTHZ_INVALID_CONFIG, NULL,
+    return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
                              "'/' is not a file in repo '%s'",
                              repos_root_dirent);
 
@@ -831,14 +831,14 @@ authz_retrieve_config_repo(svn_config_t 
         }
       else
         {
-          return svn_error_createf(SVN_ERR_AUTHZ_INVALID_CONFIG, NULL,
+          return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
                                    "'%s' path not found in repo '%s'", fs_path,
                                    repos_root_dirent);
         }
     }
   else if (node_kind != svn_node_file)
     {
-      return svn_error_createf(SVN_ERR_AUTHZ_INVALID_CONFIG, NULL,
+      return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
                                "'%s' is not a file in repo '%s'", fs_path,
                                repos_root_dirent);
     }
@@ -862,9 +862,9 @@ authz_retrieve_config_repo(svn_config_t 
  * Retrieve the configuration data that PATH points at and parse it into
  * CFG_P allocated in POOL.
  *
- * If PATH is not a valid authz rule file then return SVN_AUTHZ_INVALD_CONFIG
- * as the error.  The contents of CFG_P is then undefined.  If MUST_EXIST is
- * TRUE, a missing authz file is also an error.
+ * If PATH cannot be parsed as a config file then an error is returned.  The
+ * contents of CFG_P is then undefined.  If MUST_EXIST is TRUE, a missing
+ * authz file is also an error.
  *
  * REPOS_ROOT points at the root of the repos you are
  * going to apply the authz against, can be NULL if you are sure that you

Modified: subversion/trunk/subversion/tests/cmdline/svnauthz_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnauthz_tests.py?rev=1440023&r1=1440022&r2=1440023&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnauthz_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnauthz_tests.py Tue Jan 29 17:39:58 2013
@@ -144,11 +144,9 @@ def svnauthz_validate_repo_test(sbox):
                                           1, False, "validate", iota_url)
 
   # Non-existant authz url
-  # TODO: This should be exit code 2 but svnauthz is misbehaving and
-  # returning 1 for now.
   # exit code 2, operational error since we can't test the file.
   svntest.actions.run_and_verify_svnauthz("Non-existant authz file", None,
-                                          None, 1, False, "validate",
+                                          None, 2, False, "validate",
                                           repo_url + "/zilch")
 
 def svnauthz_validate_txn_test(sbox):
@@ -946,9 +944,9 @@ def svnauthz_compat_mode_repo_test(sbox)
                                           authz_path)
 
   # Check a non-existant url.
-  # TODO: Exit code really should be 2 but it's 1 right now.
+  # Exit code really should be 2 since this is an operational error. 
   svntest.actions.run_and_verify_svnauthz(
-      "svnauthz-validate on non-existant file", None, None, 1, True,
+      "svnauthz-validate on non-existant file", None, None, 2, True,
       repo_url + "/zilch"
   )