[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Handle failed authentication in ra_serf

From: Lieven Govaerts <lgo_at_mobsol.be>
Date: 2007-06-24 00:42:35 CEST

Attached is a small patch that handles failed authentication in ra_serf.
With current trunk when you provide wrong credentials for four times svn
will get in an endless loop.

I couldn't find an error code for 'Authentication failed', it seems to
me that other ra layers are incorrectly using Authori*z*ation failed as
error message.

Unless anyone objects, I'll commit this tomorrow.

Lieven

[[[
Handle failed authentication in ra_serf.

* subversion/include/svn_error_codes.h
  (global): add new error code SVN_ERR_AUTHN_FAILED.

* subversion/libsvn_ra_serf/util.c
  (handle_response): if authn fails, return an error.
]]]

Index: subversion/include/svn_error_codes.h
===================================================================
--- subversion/include/svn_error_codes.h (revision 25515)
+++ subversion/include/svn_error_codes.h (working copy)
@@ -819,6 +819,11 @@
              SVN_ERR_AUTHN_CATEGORY_START + 3,
              "All authentication providers exhausted")
 
+ /** @since New in 1.5. */
+ SVN_ERRDEF(SVN_ERR_AUTHN_FAILED,
+ SVN_ERR_AUTHN_CATEGORY_START + 4,
+ "Authentication failed")
+
   /* authorization errors */
 
   SVN_ERRDEF(SVN_ERR_AUTHZ_ROOT_UNREADABLE,
Index: subversion/libsvn_ra_serf/util.c
===================================================================
--- subversion/libsvn_ra_serf/util.c (revision 25515)
+++ subversion/libsvn_ra_serf/util.c (working copy)
@@ -952,9 +952,20 @@
 
   if (sl.code == 401)
     {
- handle_auth(ctx->session, ctx->conn, request, response, pool);
- svn_ra_serf__request_create(ctx);
- status = svn_ra_serf__handle_discard_body(request, response, NULL, pool);
+ status = handle_auth(ctx->session, ctx->conn, request, response, pool);
+ if (status != APR_SUCCESS)
+ {
+ ctx->session->pending_error =
+ svn_error_create(SVN_ERR_AUTHN_FAILED, NULL,
+ "Authentication failed");
+ svn_ra_serf__handle_discard_body(request, response, NULL, pool);
+ return ctx->session->pending_error->apr_err;
+ }
+ else
+ {
+ svn_ra_serf__request_create(ctx);
+ status = svn_ra_serf__handle_discard_body(request, response, NULL, pool);
+ }
     }
   else if (sl.code >= 500)
     {

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Jun 24 00:38:23 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.