2009-08-26

How to remove absolute path in svn+ssh

As you may or may not know there is a path difference between svn and svn+ssh links in case if subversion server is configured with default root directory:

/etc/sysconfig/svnserve
SVNSERVE_OPTIONS="-d -R -r /path-to-repos"
This way repository can be checked out using following commands (consider ssh is set up and working):
svn co svn://server.com/repository directory
or
svn co svn+ssh://server.com/path-to-repos/repository directory

The reason is simple - svn+ssh is just accessing a subversion repository locally, using SSH as the transport, and hence you have access to the entire filesystem. Svnserve daemon, in contrast, is told "start your paths with /path-to-repos", and so you don't have to specify it manually.
You can't argue with me that this can be really annoying in case if, for example, you work with repositories from your local intranet over svn, and from outside world over ssh.

Solution is simple. Wrapper script in place of original svnserve binary:

Rename svnserve to, let's say, svnserve.bin:
mv /usr/bin/svnserve /usr/bin/svnserve.bin
Save this script as /usr/bin/svnserve:
#!/bin/sh
exec /usr/bin/svnserve.bin -r /path-to-repos "$@"
Update permissions:
chmod 755 /usr/bin/svnserve
Voila! Now your repository links will look similar for both svn and svn+ssh:
svn co svn://server.com/repository directory
svn co svn+ssh://server.com/repository directory

No comments:

Post a Comment