You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2011/06/24 10:27:46 UTC

svn commit: r1139198 - in /subversion/trunk/subversion: libsvn_client/commit_util.c libsvn_ra_serf/commit.c tests/cmdline/authz_tests.py

Author: rhuijben
Date: Fri Jun 24 08:27:46 2011
New Revision: 1139198

URL: http://svn.apache.org/viewvc?rev=1139198&view=rev
Log:
Handle a few 'forbidden' http errors in ra_serf using a specific error code
instead of the generic request failed error to help in error reporting.

* subversion/libsvn_client/commit_util.c
  (fixup_commit_error): Document another expected error, but the way ra_svn
    drives the editor it will probably not reach this code yet.

* subversion/libsvn_ra_serf/commit.c
  (open_root): Return a specific error instead of a generic error for forbidden
    and not found.
  (add_directory): Handle this error exactly as we do it in neon instead of with
    a generic request failed error.

* subversion/tests/cmdline/authz_tests.py
  (wc_commit_mkdir): Test error message.

Modified:
    subversion/trunk/subversion/libsvn_client/commit_util.c
    subversion/trunk/subversion/libsvn_ra_serf/commit.c
    subversion/trunk/subversion/tests/cmdline/authz_tests.py

Modified: subversion/trunk/subversion/libsvn_client/commit_util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit_util.c?rev=1139198&r1=1139197&r2=1139198&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit_util.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit_util.c Fri Jun 24 08:27:46 2011
@@ -135,7 +135,8 @@ fixup_commit_error(const char *local_abs
                                                     path,
                                                     scratch_pool));
     }
-  else if (err->apr_err == SVN_ERR_RA_DAV_FORBIDDEN)
+  else if (err->apr_err == SVN_ERR_RA_DAV_FORBIDDEN
+           || err->apr_err == SVN_ERR_AUTHZ_UNWRITABLE)
     {
       if (ctx->notify_func2)
         {

Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1139198&r1=1139197&r2=1139198&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Fri Jun 24 08:27:46 2011
@@ -1362,7 +1362,18 @@ open_root(void *edit_baton,
 
       if (post_ctx->status != 201)
         {
-          return svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
+          apr_status_t status = SVN_ERR_RA_DAV_REQUEST_FAILED;
+          switch(post_ctx->status)
+            {
+              case 403:
+                status = SVN_ERR_RA_DAV_FORBIDDEN;
+                break;
+              case 404:
+                status = SVN_ERR_FS_NOT_FOUND;
+                break;
+            }
+
+          return svn_error_createf(status, NULL,
                                    _("%s of '%s': %d %s (%s://%s)"),
                                    handler->method, handler->path,
                                    post_ctx->status, post_ctx->reason,
@@ -1440,7 +1451,18 @@ open_root(void *edit_baton,
 
       if (mkact_ctx->status != 201)
         {
-          return svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
+          apr_status_t status = SVN_ERR_RA_DAV_REQUEST_FAILED;
+          switch(mkact_ctx->status)
+            {
+              case 403:
+                status = SVN_ERR_RA_DAV_FORBIDDEN;
+                break;
+              case 404:
+                status = SVN_ERR_FS_NOT_FOUND;
+                break;
+            }
+
+          return svn_error_createf(status, NULL,
                                    _("%s of '%s': %d %s (%s://%s)"),
                                    handler->method, handler->path,
                                    mkact_ctx->status, mkact_ctx->reason,
@@ -1707,17 +1729,24 @@ add_directory(const char *path,
   SVN_ERR(svn_ra_serf__context_run_wait(&add_dir_ctx->done,
                                         dir->commit->session, dir->pool));
 
-  /* 201 Created:    item was successfully copied
-     204 No Content: item successfully replaced an existing target */
-  if (add_dir_ctx->status != 201 &&
-      add_dir_ctx->status != 204)
-    {
-      SVN_ERR(add_dir_ctx->server_error.error);
-      return svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
-                               _("Adding a directory failed: %s on %s "
-                                 "(%d %s)"),
-                               handler->method, handler->path,
-                               add_dir_ctx->status, add_dir_ctx->reason);
+  switch (add_dir_ctx->status)
+    {
+      case 201: /* Created:    item was successfully copied */
+      case 204: /* No Content: item successfully replaced an existing target */
+        break;
+
+      case 403:
+        SVN_ERR(add_dir_ctx->server_error.error);
+        return svn_error_createf(SVN_ERR_RA_DAV_FORBIDDEN, NULL,
+                                _("Access to '%s' forbidden"),
+                                 handler->path);
+      default:
+        SVN_ERR(add_dir_ctx->server_error.error);
+        return svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
+                                 _("Adding directory failed: %s on %s "
+                                   "(%d %s)"),
+                                 handler->method, handler->path,
+                                 add_dir_ctx->status, add_dir_ctx->reason);
     }
 
   *child_baton = dir;

Modified: subversion/trunk/subversion/tests/cmdline/authz_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/authz_tests.py?rev=1139198&r1=1139197&r2=1139198&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/authz_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/authz_tests.py Fri Jun 24 08:27:46 2011
@@ -1240,6 +1240,27 @@ def wc_delete(sbox):
   expected_status = svntest.actions.get_virginal_state(sbox.wc_dir, 1)
 
 
+@Skip(svntest.main.is_ra_type_file)
+def wc_commit_mkdir(sbox):
+  "commit a mkdir"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  write_restrictive_svnserve_conf(sbox.repo_dir)
+
+  write_authz_file(sbox, {'/'   : '* = rw',
+                          '/A'  : '* = r', })
+
+  sbox.simple_mkdir('A/Z')
+
+  # Allow the generic 'nice' error and the ra_svn specif one that is returned
+  # on editor->edit_close().
+  expected_err = "(svn: E195023|: Changing directory '.*Z' is forbidden.)|" + \
+                 "(svn: E220004: Access denied)"
+  svntest.actions.run_and_verify_svn(None, None, expected_err,
+                                     'ci', wc_dir, '-m', '')
+
+
 ########################################################################
 # Run the tests
 
@@ -1267,6 +1288,7 @@ test_list = [ None,
               case_sensitive_authz,
               authz_tree_conflict,
               wc_delete,
+              wc_commit_mkdir,
              ]
 serial_only = True