You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2011/02/08 22:25:13 UTC
svn commit: r1068585 - in /subversion/trunk/subversion/libsvn_ra_serf:
auth.c commit.c serf.c util.c
Author: hwright
Date: Tue Feb 8 21:25:12 2011
New Revision: 1068585
URL: http://svn.apache.org/viewvc?rev=1068585&view=rev
Log:
Remove various conditionals no longer needed due to requiring Serf >= 0.7.1.
* subversion/libsvn_ra_serf/serf.c
(load_config): Unconditionally compile some code.
* subversion/libsvn_ra_serf/auth.c
(handle_basic_auth, init_basic_connection, setup_request_basic_auth,
handle_proxy_basic_auth, init_proxy_basic_connection,
setup_request_proxy_basic_auth): Remove.
(serf_auth_protocols): Update to remove old code.
* subversion/libsvn_ra_serf/util.c
(svn_ra_serf__conn_setup): Remove ugly conditionals for pre-0.4.0 serf.
(svn_ra_serf__setup_serf_req): Same.
(svn_ra_serf__discover_vcc): Unconditionally compile some code.
* subversion/libsvn_ra_serf/commit.c
(create_put_body, delete_entry, abort_edit): Same.
Modified:
subversion/trunk/subversion/libsvn_ra_serf/auth.c
subversion/trunk/subversion/libsvn_ra_serf/commit.c
subversion/trunk/subversion/libsvn_ra_serf/serf.c
subversion/trunk/subversion/libsvn_ra_serf/util.c
Modified: subversion/trunk/subversion/libsvn_ra_serf/auth.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/auth.c?rev=1068585&r1=1068584&r2=1068585&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/auth.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/auth.c Tue Feb 8 21:25:12 2011
@@ -33,50 +33,7 @@
/*** Forward declarations. ***/
-#if ! SERF_VERSION_AT_LEAST(0, 4, 0)
-static svn_error_t *
-handle_basic_auth(svn_ra_serf__handler_t *ctx,
- serf_request_t *request,
- serf_bucket_t *response,
- const char *auth_hdr,
- const char *auth_attr,
- apr_pool_t *pool);
-
-static svn_error_t *
-init_basic_connection(svn_ra_serf__session_t *session,
- svn_ra_serf__connection_t *conn,
- apr_pool_t *pool);
-
-static svn_error_t *
-setup_request_basic_auth(svn_ra_serf__connection_t *conn,
- const char *method,
- const char *uri,
- serf_bucket_t *hdrs_bkt);
-#endif
-
-#if ! SERF_VERSION_AT_LEAST(0, 4, 0)
-static svn_error_t *
-handle_proxy_basic_auth(svn_ra_serf__handler_t *ctx,
- serf_request_t *request,
- serf_bucket_t *response,
- const char *auth_hdr,
- const char *auth_attr,
- apr_pool_t *pool);
-
-static svn_error_t *
-init_proxy_basic_connection(svn_ra_serf__session_t *session,
- svn_ra_serf__connection_t *conn,
- apr_pool_t *pool);
-
-static svn_error_t *
-setup_request_proxy_basic_auth(svn_ra_serf__connection_t *conn,
- const char *method,
- const char *uri,
- serf_bucket_t *hdrs_bkt);
-
-#endif
-
-#if ! SERF_VERSION_AT_LEAST(0, 4, 0) || defined(SVN_RA_SERF_SSPI_ENABLED)
+#if defined(SVN_RA_SERF_SSPI_ENABLED)
static svn_error_t *
default_auth_response_handler(svn_ra_serf__handler_t *ctx,
serf_request_t *request,
@@ -89,27 +46,6 @@ default_auth_response_handler(svn_ra_ser
/*** Global variables. ***/
static const svn_ra_serf__auth_protocol_t serf_auth_protocols[] = {
-#if ! SERF_VERSION_AT_LEAST(0, 4, 0)
- /* serf handles Basic authentication. */
- {
- 401,
- "Basic",
- svn_ra_serf__authn_basic,
- init_basic_connection,
- handle_basic_auth,
- setup_request_basic_auth,
- default_auth_response_handler,
- },
- {
- 407,
- "Basic",
- svn_ra_serf__authn_basic,
- init_proxy_basic_connection,
- handle_proxy_basic_auth,
- setup_request_proxy_basic_auth,
- default_auth_response_handler,
- },
-#endif
#ifdef SVN_RA_SERF_SSPI_ENABLED
{
401,
@@ -130,17 +66,6 @@ static const svn_ra_serf__auth_protocol_
default_auth_response_handler,
},
#endif /* SVN_RA_SERF_SSPI_ENABLED */
-#if ! SERF_VERSION_AT_LEAST(0, 4, 0)
- {
- 401,
- "Digest",
- svn_ra_serf__authn_digest,
- svn_ra_serf__init_digest_connection,
- svn_ra_serf__handle_digest_auth,
- svn_ra_serf__setup_request_digest_auth,
- svn_ra_serf__validate_response_digest_auth,
- },
-#endif
#ifdef SVN_RA_SERF_HAVE_GSSAPI
{
401,
@@ -368,217 +293,3 @@ svn_ra_serf__handle_auth(int code,
return SVN_NO_ERROR;
}
-
-#if ! SERF_VERSION_AT_LEAST(0, 4, 0)
-static svn_error_t *
-handle_basic_auth(svn_ra_serf__handler_t *ctx,
- serf_request_t *request,
- serf_bucket_t *response,
- const char *auth_hdr,
- const char *auth_attr,
- apr_pool_t *pool)
-{
- void *creds;
- svn_auth_cred_simple_t *simple_creds;
- const char *tmp;
- apr_size_t tmp_len;
- apr_port_t port;
- int i;
- svn_ra_serf__session_t *session = ctx->session;
-
- if (!session->realm)
- {
- char *realm_name;
- const char *eq = strchr(auth_attr, '=');
-
- if (eq && strncasecmp(auth_attr, "realm", 5) == 0)
- {
- realm_name = apr_pstrdup(pool, eq + 1);
- if (realm_name[0] == '\"')
- {
- apr_size_t realm_len;
-
- realm_len = strlen(realm_name);
- if (realm_name[realm_len - 1] == '\"')
- {
- realm_name[realm_len - 1] = '\0';
- realm_name++;
- }
- }
- }
- else
- {
- return svn_error_create
- (SVN_ERR_RA_DAV_MALFORMED_DATA, NULL,
- _("Missing 'realm' attribute in Authorization header"));
- }
- if (!realm_name)
- {
- return svn_error_create
- (SVN_ERR_RA_DAV_MALFORMED_DATA, NULL,
- _("Missing 'realm' attribute in Authorization header"));
- }
-
- if (session->repos_url.port_str)
- {
- port = session->repos_url.port;
- }
- else
- {
- port = apr_uri_port_of_scheme(session->repos_url.scheme);
- }
-
- session->realm = apr_psprintf(session->pool, "<%s://%s:%d> %s",
- session->repos_url.scheme,
- session->repos_url.hostname,
- port,
- realm_name);
- }
-
- /* Use svn_auth_first_credentials if this is the first time we ask for
- credentials during this session OR if the last time we asked
- session->auth_state wasn't set (eg. if the credentials provider was
- cancelled by the user). */
- if (!session->auth_state)
- {
- SVN_ERR(svn_auth_first_credentials(&creds,
- &session->auth_state,
- SVN_AUTH_CRED_SIMPLE,
- session->realm,
- session->wc_callbacks->auth_baton,
- session->pool));
- }
- else
- {
- SVN_ERR(svn_auth_next_credentials(&creds,
- session->auth_state,
- session->pool));
- }
-
- session->auth_attempts++;
-
- if (!creds || session->auth_attempts > 4)
- {
- /* No more credentials. */
- return svn_error_create(SVN_ERR_AUTHN_FAILED, NULL,
- _("No more credentials or we tried too many times.\n"
- "Authentication failed"));
- }
-
- simple_creds = creds;
-
- tmp = apr_pstrcat(session->pool,
- simple_creds->username, ":", simple_creds->password, NULL);
- tmp_len = strlen(tmp);
-
- svn_ra_serf__encode_auth_header(session->auth_protocol->auth_name,
- &session->auth_value, tmp, tmp_len, pool);
- session->auth_header = "Authorization";
-
- /* FIXME Come up with a cleaner way of changing the connection auth. */
- for (i = 0; i < session->num_conns; i++)
- {
- session->conns[i]->auth_header = session->auth_header;
- session->conns[i]->auth_value = session->auth_value;
- }
-
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-init_basic_connection(svn_ra_serf__session_t *session,
- svn_ra_serf__connection_t *conn,
- apr_pool_t *pool)
-{
- conn->auth_header = session->auth_header;
- conn->auth_value = session->auth_value;
-
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-setup_request_basic_auth(svn_ra_serf__connection_t *conn,
- const char *method,
- const char *uri,
- serf_bucket_t *hdrs_bkt)
-{
- /* Take the default authentication header for this connection, if any. */
- if (conn->auth_header && conn->auth_value)
- {
- serf_bucket_headers_setn(hdrs_bkt, conn->auth_header, conn->auth_value);
- }
-
- return SVN_NO_ERROR;
-}
-#endif
-
-#if ! SERF_VERSION_AT_LEAST(0, 4, 0)
-static svn_error_t *
-handle_proxy_basic_auth(svn_ra_serf__handler_t *ctx,
- serf_request_t *request,
- serf_bucket_t *response,
- const char *auth_hdr,
- const char *auth_attr,
- apr_pool_t *pool)
-{
- const char *tmp;
- apr_size_t tmp_len;
- int i;
- svn_ra_serf__session_t *session = ctx->session;
-
- tmp = apr_pstrcat(session->pool,
- session->proxy_username, ":",
- session->proxy_password, NULL);
- tmp_len = strlen(tmp);
-
- session->proxy_auth_attempts++;
-
- if (session->proxy_auth_attempts > 1)
- {
- /* No more credentials. */
- return svn_error_create(SVN_ERR_AUTHN_FAILED, NULL,
- _("Proxy authentication failed"));
- }
-
- svn_ra_serf__encode_auth_header(session->proxy_auth_protocol->auth_name,
- &session->proxy_auth_value,
- tmp, tmp_len, pool);
- session->proxy_auth_header = "Proxy-Authorization";
-
- /* FIXME Come up with a cleaner way of changing the connection auth. */
- for (i = 0; i < session->num_conns; i++)
- {
- session->conns[i]->proxy_auth_header = session->proxy_auth_header;
- session->conns[i]->proxy_auth_value = session->proxy_auth_value;
- }
-
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-init_proxy_basic_connection(svn_ra_serf__session_t *session,
- svn_ra_serf__connection_t *conn,
- apr_pool_t *pool)
-{
- conn->proxy_auth_header = session->proxy_auth_header;
- conn->proxy_auth_value = session->proxy_auth_value;
-
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-setup_request_proxy_basic_auth(svn_ra_serf__connection_t *conn,
- const char *method,
- const char *uri,
- serf_bucket_t *hdrs_bkt)
-{
- /* Take the default authentication header for this connection, if any. */
- if (conn->proxy_auth_header && conn->proxy_auth_value)
- {
- serf_bucket_headers_setn(hdrs_bkt, conn->proxy_auth_header,
- conn->proxy_auth_value);
- }
-
- return SVN_NO_ERROR;
-}
-#endif
Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1068585&r1=1068584&r2=1068585&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Tue Feb 8 21:25:12 2011
@@ -1008,9 +1008,7 @@ create_put_body(serf_bucket_t **body_bkt
* bucket for us on the buffered svndiff handle.
*/
apr_file_flush(ctx->svndiff);
-#if APR_VERSION_AT_LEAST(1, 3, 0)
apr_file_buffer_set(ctx->svndiff, NULL, 0);
-#endif
offset = 0;
apr_file_seek(ctx->svndiff, APR_SET, &offset);
@@ -1544,11 +1542,9 @@ delete_entry(const char *path,
{
svn_error_clear(err);
-#if SERF_VERSION_AT_LEAST(0, 4, 0)
/* An error has been registered on the connection. Reset the thing
so that we can use it again. */
serf_connection_reset(handler->conn->conn);
-#endif
handler->body_delegate = create_delete_body;
handler->body_delegate_baton = delete_ctx;
@@ -2250,11 +2246,9 @@ abort_edit(void *edit_baton,
if (! (ctx->activity_url || ctx->txn_url))
return SVN_NO_ERROR;
-#if SERF_VERSION_AT_LEAST(0, 4, 0)
/* An error occurred on conns[0]. serf 0.4.0 remembers that the connection
had a problem. We need to reset it, in order to use it again. */
serf_connection_reset(ctx->session->conns[0]->conn);
-#endif
/* DELETE our aborted activity */
handler = apr_pcalloc(pool, sizeof(*handler));
Modified: subversion/trunk/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/serf.c?rev=1068585&r1=1068584&r2=1068585&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/serf.c Tue Feb 8 21:25:12 2011
@@ -307,12 +307,10 @@ load_config(svn_ra_serf__session_t *sess
/* Setup authentication. */
SVN_ERR(load_http_auth_types(pool, config, server_group,
&session->authn_types));
-#if SERF_VERSION_AT_LEAST(0, 4, 0)
/* TODO: convert string authn types to SERF_AUTHN bitmask.
serf_config_authn_types(session->context, session->authn_types);*/
serf_config_credentials_callback(session->context,
svn_ra_serf__credentials_callback);
-#endif
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1068585&r1=1068584&r2=1068585&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Tue Feb 8 21:25:12 2011
@@ -326,10 +326,6 @@ conn_setup(apr_socket_t *sock,
return SVN_NO_ERROR;
}
-#if SERF_VERSION_AT_LEAST(0, 4, 0)
-/* This ugly ifdef construction can be cleaned up as soon as serf >= 0.4
- gets the minimum supported serf version! */
-
/* svn_ra_serf__conn_setup is a callback for serf. This function
creates a read bucket and will wrap the write bucket if SSL
is needed. */
@@ -340,18 +336,6 @@ svn_ra_serf__conn_setup(apr_socket_t *so
void *baton,
apr_pool_t *pool)
{
-#else
-/* This is the old API, for compatibility with serf
- versions <= 0.3. */
-serf_bucket_t *
-svn_ra_serf__conn_setup(apr_socket_t *sock,
- void *baton,
- apr_pool_t *pool)
-{
- serf_bucket_t **write_bkt = NULL;
- serf_bucket_t *rb = NULL;
- serf_bucket_t **read_bkt = &rb;
-#endif
svn_ra_serf__connection_t *conn = baton;
svn_ra_serf__session_t *session = conn->session;
apr_status_t status = SVN_NO_ERROR;
@@ -371,12 +355,7 @@ svn_ra_serf__conn_setup(apr_socket_t *so
status = session->pending_error->apr_err;
}
-#if ! SERF_VERSION_AT_LEAST(0, 4, 0)
- SVN_ERR_ASSERT_NO_RETURN(rb != NULL);
- return rb;
-#else
return status;
-#endif
}
serf_bucket_t*
@@ -631,26 +610,6 @@ svn_ra_serf__setup_serf_req(serf_request
url,
hdrs_bkt));
-#if ! SERF_VERSION_AT_LEAST(0, 4, 0)
- /* Set up SSL if we need to */
- if (conn->using_ssl)
- {
- *req_bkt = serf_bucket_ssl_encrypt_create(*req_bkt, conn->ssl_context,
- serf_request_get_alloc(request));
- if (!conn->ssl_context)
- {
- conn->ssl_context = serf_bucket_ssl_encrypt_context_get(*req_bkt);
-
- serf_ssl_client_cert_provider_set(conn->ssl_context,
- svn_ra_serf__handle_client_cert,
- conn, conn->session->pool);
- serf_ssl_client_cert_password_set(conn->ssl_context,
- svn_ra_serf__handle_client_cert_pw,
- conn, conn->session->pool);
- }
- }
-#endif
-
if (ret_hdrs_bkt)
{
*ret_hdrs_bkt = hdrs_bkt;
@@ -1805,12 +1764,10 @@ svn_ra_serf__discover_vcc(const char **v
/* Okay, strip off a component from PATH. */
path = svn_urlpath__dirname(path, pool);
-#if SERF_VERSION_AT_LEAST(0, 4, 0)
/* An error occurred on conns. serf 0.4.0 remembers that
the connection had a problem. We need to reset it, in
order to use it again. */
serf_connection_reset(conn->conn);
-#endif
}
}
}
Re: svn commit: r1068585 - in /subversion/trunk/subversion/libsvn_ra_serf:
auth.c commit.c serf.c util.c
Posted by Hyrum K Wright <hy...@hyrumwright.org>.
On Tue, Feb 8, 2011 at 9:33 PM, Mark Phippard <ma...@gmail.com> wrote:
> On Tue, Feb 8, 2011 at 4:25 PM, <hw...@apache.org> wrote:
>> Author: hwright
>> Date: Tue Feb 8 21:25:12 2011
>> New Revision: 1068585
>> Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
>> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1068585&r1=1068584&r2=1068585&view=diff
>> ==============================================================================
>> --- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
>> +++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Tue Feb 8 21:25:12 2011
>> @@ -1008,9 +1008,7 @@ create_put_body(serf_bucket_t **body_bkt
>> * bucket for us on the buffered svndiff handle.
>> */
>> apr_file_flush(ctx->svndiff);
>> -#if APR_VERSION_AT_LEAST(1, 3, 0)
>> apr_file_buffer_set(ctx->svndiff, NULL, 0);
>> -#endif
>> offset = 0;
>> apr_file_seek(ctx->svndiff, APR_SET, &offset);
>
> Mistake ????
Yep. Fixed in r1068592.
-Hyrum
Re: svn commit: r1068585 - in /subversion/trunk/subversion/libsvn_ra_serf:
auth.c commit.c serf.c util.c
Posted by Mark Phippard <ma...@gmail.com>.
On Tue, Feb 8, 2011 at 4:25 PM, <hw...@apache.org> wrote:
> Author: hwright
> Date: Tue Feb 8 21:25:12 2011
> New Revision: 1068585
> Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1068585&r1=1068584&r2=1068585&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
> +++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Tue Feb 8 21:25:12 2011
> @@ -1008,9 +1008,7 @@ create_put_body(serf_bucket_t **body_bkt
> * bucket for us on the buffered svndiff handle.
> */
> apr_file_flush(ctx->svndiff);
> -#if APR_VERSION_AT_LEAST(1, 3, 0)
> apr_file_buffer_set(ctx->svndiff, NULL, 0);
> -#endif
> offset = 0;
> apr_file_seek(ctx->svndiff, APR_SET, &offset);
Mistake ????
--
Thanks
Mark Phippard
http://markphip.blogspot.com/