You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2012/10/01 21:50:17 UTC
svn commit: r1392556 - in /subversion/trunk/subversion:
libsvn_ra_svn/client.c libsvn_ra_svn/ra_svn.h tests/cmdline/svnlook_tests.py
Author: cmpilato
Date: Mon Oct 1 19:50:16 2012
New Revision: 1392556
URL: http://svn.apache.org/viewvc?rev=1392556&view=rev
Log:
Finish issue #4124 ("Give servers sufficient means to disallow commits
from clients based on version numbers").
* subversion/libsvn_ra_svn/ra_svn.h
(SVN_RA_SVN__DEFAULT_USERAGENT): New #define.
(svn_ra_svn__session_baton_t): Add 'useragent' member.
* subversion/libsvn_ra_svn/client.c
(ra_svn_commit): Deliver the SVN_PROP_TXN_USER_AGENT ephemeral
txnprop, too, using the new 'useragent' session baton variable's
value.
(open_session): Combine the default useragent string with the
results of the get_client_string() callback (if any), storing the
result in the new 'useragent' session baton variable.
* subversion/tests/cmdline/svnlook_tests.py
(test_txn_flag): Also expect ra_svn to set the
SVN_PROP_TXN_USER_AGENT ephemeral txnprop.
Modified:
subversion/trunk/subversion/libsvn_ra_svn/client.c
subversion/trunk/subversion/libsvn_ra_svn/ra_svn.h
subversion/trunk/subversion/tests/cmdline/svnlook_tests.py
Modified: subversion/trunk/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/client.c?rev=1392556&r1=1392555&r2=1392556&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/client.c Mon Oct 1 19:50:16 2012
@@ -594,7 +594,7 @@ static svn_error_t *open_session(svn_ra_
sess->callbacks = callbacks;
sess->callbacks_baton = callbacks_baton;
sess->bytes_read = sess->bytes_written = 0;
-
+
if (tunnel_argv)
SVN_ERR(make_tunnel(tunnel_argv, &conn, pool));
else
@@ -605,6 +605,23 @@ static svn_error_t *open_session(svn_ra_
0, 0, pool);
}
+ /* Build the useragent string, querying the client for any
+ customizations it wishes to note. For historical reasons, we
+ still deliver the hard-coded client version info
+ (SVN_RA_SVN__DEFAULT_USERAGENT) and the customized client string
+ separately in the protocol/capabilities handshake below. But the
+ commit logic wants the combined form for use with the
+ SVN_PROP_TXN_USER_AGENT ephemeral property because that's
+ consistent with our DAV approach. */
+ if (sess->callbacks->get_client_string != NULL)
+ SVN_ERR(sess->callbacks->get_client_string(sess->callbacks_baton,
+ &client_string, pool));
+ if (client_string)
+ sess->useragent = apr_pstrcat(pool, SVN_RA_SVN__DEFAULT_USERAGENT "/",
+ client_string, (char *)NULL);
+ else
+ sess->useragent = SVN_RA_SVN__DEFAULT_USERAGENT;
+
/* Make sure we set conn->session before reading from it,
* because the reader and writer functions expect a non-NULL value. */
sess->conn = conn;
@@ -631,10 +648,6 @@ static svn_error_t *open_session(svn_ra_
return svn_error_create(SVN_ERR_RA_SVN_BAD_VERSION, NULL,
_("Server does not support edit pipelining"));
- if (sess->callbacks->get_client_string != NULL)
- SVN_ERR(sess->callbacks->get_client_string(sess->callbacks_baton,
- &client_string, pool));
-
/* In protocol version 2, we send back our protocol version, our
* capability list, and the URL, and subsequently there is an auth
* request. */
@@ -647,7 +660,9 @@ static svn_error_t *open_session(svn_ra_
SVN_RA_SVN_CAP_DEPTH,
SVN_RA_SVN_CAP_MERGEINFO,
SVN_RA_SVN_CAP_LOG_REVPROPS,
- url, "SVN/" SVN_VER_NUMBER, client_string));
+ url,
+ SVN_RA_SVN__DEFAULT_USERAGENT,
+ client_string));
SVN_ERR(handle_auth_request(sess, pool));
/* This is where the security layer would go into effect if we
@@ -991,6 +1006,10 @@ static svn_error_t *ra_svn_commit(svn_ra
apr_pstrdup(pool, SVN_PROP_TXN_CLIENT_COMPAT_VERSION),
APR_HASH_KEY_STRING,
svn_string_create(SVN_VER_NUMBER, pool));
+ apr_hash_set(revprop_table,
+ apr_pstrdup(pool, SVN_PROP_TXN_USER_AGENT),
+ APR_HASH_KEY_STRING,
+ svn_string_create(sess_baton->useragent, pool));
}
/* Tell the server we're starting the commit.
Modified: subversion/trunk/subversion/libsvn_ra_svn/ra_svn.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/ra_svn.h?rev=1392556&r1=1392555&r2=1392556&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/ra_svn.h (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/ra_svn.h Mon Oct 1 19:50:16 2012
@@ -56,6 +56,9 @@ typedef svn_error_t *(*ra_svn_block_hand
apr_pool_t *pool,
void *baton);
+/* The default "user agent". */
+#define SVN_RA_SVN__DEFAULT_USERAGENT "SVN/" SVN_VER_NUMBER
+
/* The size of our per-connection read and write buffers. */
#define SVN_RA_SVN__PAGE_SIZE 4096
#define SVN_RA_SVN__READBUF_SIZE (4 * SVN_RA_SVN__PAGE_SIZE)
@@ -126,6 +129,7 @@ struct svn_ra_svn__session_baton_t {
void *callbacks_baton;
apr_off_t bytes_read, bytes_written; /* apr_off_t's because that's what
the callback interface uses */
+ const char *useragent;
};
/* Set a callback for blocked writes on conn. This handler may
Modified: subversion/trunk/subversion/tests/cmdline/svnlook_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnlook_tests.py?rev=1392556&r1=1392555&r2=1392556&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnlook_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnlook_tests.py Mon Oct 1 19:50:16 2012
@@ -701,10 +701,10 @@ fp.close()"""
' svn:check-locks\n', # internal prop, not really expected
' bogus_rev_prop\n',
' svn:date\n',
- ' svn:txn-client-compat-version\n',
+ ' svn:txn-client-compat-version\n',
]
- # ra_dav adds the user-agent ephemeral property
- if svntest.main.is_ra_type_dav():
+ # ra_dav and ra_svn add the user-agent ephemeral property
+ if svntest.main.is_ra_type_dav() or svntest.main.is_ra_type_svn():
expected_data.append(' svn:txn-user-agent\n')
verify_logfile(logfilepath, svntest.verify.UnorderedOutput(expected_data))