Manicai.net

Browsing Subversion Repositories with AOLServer

I haven’t run AOLServer for a couple of years so this may be out of date and I certainly can’t rememember enough to answer questions about it. It remains available in the hope that it will be of use to someone

ViewCVS and AOLServer CGI

Start off by getting a copy of the ViewCVS code, as I want Subversion report I’m using a fairly recent snapshot from the development tree. Initially the installation follows the advice given in the install file closely.

$ tar xzf viewcvs.tgz
$ cd viewcvs
$ ./viewcvs-install

When prompted you enter the location for the cgi to live, I went for:

/srv/www/servers/manicai/modules/viewcvs

as that fits quite well with the standard AOLServer directory structure.

Now configure ViewCVS. This involves editting various options in viewcvs.conf. I made the following changes.

The various other options I tweaked are less important but were as follows.

allow_tar = 1
root_as_url_component = 1

Now you have to configure AOLServer to serve the CGIs. So far most of this has been straight from the ViewCVS installation guide so things diverge here. The first thing to do is enable CGI for the server.

ns_section "ns/server/${server}/modules"
ns_param nscgi  ${bindir}/nscgi.so

Now set up the mappings for the scripts. Note that since I wasn’t interested in commit database queries (not having install the database) I didn’t bother mapping the query CGI.

ns_section "ns/server/${server}/module/nscgi"
ns_param map "GET /viewsvn ${serverdir}/modules/viewcvs/www/cgi/viewcvs.py"
ns_param map "POST /viewsvn ${serverdir}/modules/viewcvs/www/cgi/viewcvs.py"
ns_param interps cgiinterps

ns_section "ns/interps/cgiinterps"
ns_param .py /usr/bin/python

To make it easier to add other CGIs in due course I’ve renamed the viewcvs.cgi and query.cgi to viewcvs.py and query.py respectively.

ViewCVS assumes that you’ll have the Apache icons around to use on the icon pages. There does not seem to be a way to turn these off so I copied them from the Apache distribution to the folder in the root folder of the pages.

I changed the template for the pages so that I didn’t have the powered by Apache logo, since it isn’t. This involved editting footer.ezt to:

[# standard footer used by all ViewCVS pages ]

<hr noshade>

<table width="100%">
 <tr>
  <td>
   <a href="/">Back to www.manicai.net</a>
  </td>
  <td align="right">
   <address>[cfg.general.address]</address>
  </td>
 </tr>
 <tr>
  <td>
   Repository browsing powered by <a
   href="http://viewcvs.sourceforge.net/">ViewCVS [vsn]</a> and <a
   href="http://www.aolserver.com">AOLServer</a>
  </td>
  <td align="right">
   <a target="_blank" href="[help_href]">ViewCVS and CVS Help</a>
  </td>
 </tr>
</table>

</body>
</html>

Finally as I didn’t want search bots crawling all over the repositories I added the following to the robots.txt file for the site

User-agent: *
Disallow: /viewsvn/
Disallow: /icons/

ViewCVS and chroot

All of this is fine until you try it on a server which runs AOLServer in a chroot jail. It just becomes messy. You need to ensure that Subversion and Python will both run in the jail, and that ViewCVS’s install path is relative to the jail root.

For the former, you could probably install relative to the real root directory and then move everything across to the right location, or run the viewcvs-install program in the chroot jail. It hadn’t occurred to me that this would be a problem so I hadn’t done either of these so ended up massaging by hand all the places in the source code that hard code the install path (and swearing slightly about single points of truth).

For the former you have to install all the right libraries and executables. This seems to be a process of trial and error, repeated trying to run chroot /your/root/ python until it does at which point you start trying to import the svn modules until they work. For reference here are the lists I ended up with for each directory.

/usr/bin:
python
python2.1

/usr/lib:
libapr-0.so.0
libaprutil-0.so.0
libcrypto.so.0.9.6
libdb-4.2.so
libexpat.so.1
liblber.so.2
libldap.so.2
libpython2.1.so.0.0
libsasl.so.7
libssl.so.0.9.6
libsvn_client-1.so.0
libsvn_client-1.so.0.0.0
libsvn_delta-1.so.0
libsvn_delta-1.so.0.0.0
libsvn_diff-1.so.0
libsvn_diff-1.so.0.0.0
libsvn_fs-1.so.0
libsvn_fs-1.so.0.0.0
libsvn_ra-1.so.0
libsvn_ra-1.so.0.0.0
libsvn_ra_dav-1.so.0
libsvn_ra_dav-1.so.0.0.0
libsvn_ra_local-1.so.0
libsvn_ra_local-1.so.0.0.0
libsvn_ra_svn-1.so.0
libsvn_ra_svn-1.so.0.0.0
libsvn_repos-1.so.0
libsvn_repos-1.so.0.0.0
libsvn_subr-1.so.0
libsvn_subr-1.so.0.0.0
libsvn_swig_py-1.so.0
libsvn_swig_py-1.so.0.0.0
libsvn_wc-1.so.0
libsvn_wc-1.so.0.0.0
libswigphp4-1.3.21.so
libswigpl-1.3.21.so
libswigpy-1.3.21.so
libswigrb-1.3.21.so
libswigtcl8-1.3.21.so
libtcl8.4.so
python2.1/

/lib:
ld-2.2.5.so
ld-linux.so.2
libc-2.2.5.so
libc.so.6
libcrypt.so.1
libdb2.so.2
libdl-2.2.5.so
libdl.so.2
libm-2.2.5.so
libm.so.6
libncurses.so.5
libncurses.so.5.2
libnsl.so.1
libpam.so.0
libpthread-0.9.so
libpthread.so.0
libreadline.so.4
libreadline.so.4.2
libresolv.so.2
librt.so.1
libutil.so.1

/etc:
ld.so.cache
passwd

You’re mileage with these may vary. Note you need to run ldconfig under chroot to generate the ld.so.cache file.

SVN, SSH and ViewCVS

Depending on how you access the repository this may or may not be relevant. Personally I tunnel through SSH to use svnserve as my webserver isn’t Apache and I don’t want to open up extra ports in the firewall. This means I have to make sure that when svnserve updates the repository the user the webserver runs under can still access it.

The Subversion book has a good explanation of how to support multiple repositories which applies equally well to use with ViewCVS. Basically it boils down to three steps.

#!
umask 002
/usr/bin/svnserve-real "$@"