Monday, May 10, 2010

Accessing subversion repository via svnserve

The svnserve program is a lightweight server, capable of speaking to clients over TCP/IP using a custom, stateful protocol. Clients contact an svnserve server by using URLs that begin with the svn:// scheme.

Wrapper script

Using the svn protocol discloses the absolute path of subversion project repository. This is not good due to security reasons. Find where is svnserve:
deby:~# whereis svnserve
svnserve: /usr/bin/svnserve
We are going to hide the root of the repository tree by using a wrapper script.
mv /usr/bin/svnserve /usr/bin/svnserve.bin
touch /usr/bin/svnserve
chmod +x /usr/bin/svnserve
Add the following to /usr/bin/svnserve (assuming /var/svn/repos is the root of the repository tree):

exec /usr/bin/svnserve.bin -r /var/svn/repos "$@"

svnserve as daemon

It is easy to run svnserve as a standalone “daemon” process. Use the -d option for this:
svnserve -d
Here is how you can checkout files now:
master@deby:~$ svn co svn://localhost/project1
A    project1/trunk
Checked out revision 4.
Stop svnserve:
deby:~# ps -A | grep svnserve
 2144 ?        00:00:00 svnserve.bin
deby:~# kill 2144

svnserve via ssh

You need configure password-less ssh login (see this). Here is how you can access the svn repository now (note, you do not have to start svnserve daemon, ssh does that for you):
svn co svn+ssh://localhost/project1
Read more about subversion here.

No comments :

Post a Comment