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

How ra-svn finds a tunnel agent

From: Eric Gillespie <epg_at_pretzelnet.org>
Date: 2003-04-22 21:35:52 CEST

I don't really like having to edit ~/.subversion/servers before i
can use ra-svn over ssh. With cvs, i could just set CVS_RSH to
ssh and use the ext method. That's as permanent as a config file
if you arrange to have that environment variable set for you at
login, or as temporary as a command-line option if you don't.
Very handy.

I recently saw Greg Hudson say that he wasn't really happy with
the current method, so i decided to take a look at it.

I have a patch that makes ra-svn check the SVN_TUNNEL_AGENT
environment variable before it checks .subversion/servers. That
addresses my primary concern. I have also changed it so that
these two sources are parsed for arguments to the tunnel agent.
This solves Overfiend's problem (from IRC); he can just set
either the environment variable or the config file (both parsed
with the same code) to say 'ssh -p 1817'.

Greg was -0 on SVN_TUNNEL_AGENT when i asked him about it.
Here's what he suggested in response:

> Perhaps there's a middle ground... a tunnel scheme definition
> could include the name of an environment variable which
> overrides the default command name. And the predefined tunnel
> scheme would respect SVN_TUNNEL_AGENT and default to "ssh" if
> that's not defined. (The predefined scheme might be called
> something more generic like "ext" because of that, a la CVS's
> :ext: method, or perhaps we'd still call it "ssh"; no strong
> opinion there.)

If i understand correctly, this means svn://foo/bar/ and
svn+ext://foo/bar/ are identical, just as :ext:foo:/bar and
foo:/bar are identical to CVS. And this default 'ext' method
would call ssh unless SVN_TUNNEL_AGENT were set. The user could
then define additional tunneling schemes with some as yet
undefined syntax in the config file.

I'm not sure i like this. I certainly don't object to it since
it solves my complaint, but i don't see what the extra complexity

--- client.c.~1~ Wed Apr 16 00:56:27 2003
+++ client.c Sat Apr 19 04:35:42 2003
@@ -255,18 +255,25 @@
 static svn_error_t *find_tunnel_agent(const char *hostname, const char **agent,
                                       apr_hash_t *config, apr_pool_t *pool)
- svn_config_t *cfg = config ? apr_hash_get (config,
+ svn_config_t *cfg;
   const char *server_group;
- server_group = svn_config_find_group(cfg, hostname,
- if (! server_group)
+ *agent = getenv ("SVN_TUNNEL_AGENT");
- svn_config_get(cfg, agent, server_group, SVN_CONFIG_OPTION_SVN_TUNNEL_AGENT,
- NULL);
+ /* If not found in the environment, try the config file. */
+ if (!*agent)
+ {
+ cfg = config ? apr_hash_get(config, SVN_CONFIG_CATEGORY_SERVERS,
+ server_group = svn_config_find_group(cfg, hostname,
+ if (! server_group)
+ svn_config_get(cfg, agent, server_group,
+ }
   return SVN_NO_ERROR;
@@ -307,7 +314,7 @@
   svn_ra_svn_conn_t *conn;
   apr_socket_t *sock;
- const char *hostname, *user, *status, *tunnel_agent, *args[5];
+ const char *hostname, *user, *status, *tunnel_agent, **args;
   unsigned short port;
   apr_uint64_t minver, maxver;
   apr_array_header_t *mechlist, *caplist, *status_param;
@@ -321,17 +328,18 @@
   SVN_ERR(find_tunnel_agent(hostname, &tunnel_agent, config, pool));
   if (tunnel_agent)
- /* ### It would be nice if tunnel_agent could contain flags. */
- args[0] = tunnel_agent;
- args[1] = hostname;
- args[2] = "svnserve";
- args[3] = "-t";
- args[4] = NULL;
+ char *tmp;
+ tmp = apr_pstrcat(pool,
+ tunnel_agent, " ", hostname, " svnserve -t",
+ NULL);
+ apr_tokenize_to_argv(tmp, (char ***)&args, pool);
       apr_procattr_create(&attr, pool);
       apr_procattr_io_set(attr, 1, 1, 0);
       apr_procattr_cmdtype_set(attr, APR_PROGRAM_PATH);
       proc = apr_palloc(pool, sizeof(*proc));
- apr_proc_create(proc, tunnel_agent, args, NULL, attr, pool);
+ apr_proc_create(proc, args[0], args, NULL, attr, pool);
       conn = svn_ra_svn_create_conn(NULL, proc->out, proc->in, pool);
       conn->proc = proc;

To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Apr 22 21:36:42 2003

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.