Set up a local CVS repository server for remote access
The one minute's guide on using CVS to manage your files should be enough for your daily usage of CVS most of the time. This is especially true when your home directory is mounted through NFS and is accessible from any machine you use. You can simply log into any machine, check out a local copy and then start working on it. However, sometimes your remote home directory is not available locally and you may find it convenient to access your CVS repository remotely from your local machine. In this article, we describe how to create a CVS repository in your remote home directory and then make it available remotely. All this can be done as a non-root user as long as system administrator for the remote machine doesn't block connections initiated from outside to it.
Now suppose you have a machine called
cvsserver.example.com
on which you want
to create a CVS repository and make it available to another
machine dev.example.net.
You first need to create a directory
that is to be the CVS repository on
cvsserver.example.com. For example, let's create one
/var/tmp/local/cvsroot which doesn't require
root privilege. Now you can define and export
the CVSROOT environment variable for your
bash shell. Then you can initialize the repository with
cvs init. The commands to run are summarized as below.
mkdir /var/tmp/local/cvsroot
export CVSROOT=/var/tmp/local/cvsroot
cvs init
Next go to any temporary directory, e.g,
/tmp and check out the
CVSROOT directory which contains the CVS
administrative files.
cd /tmp
cvs co CVSROOT
Modify the config file under the
CVSROOT directory to make sure
SystemAuth=no because you don't have the
privilege to authenticate users in the system.
Now commit the file and CVS will rebuild its administrative
files:
cvs commit CVSROOT/config
Next you need to use the htpasswd command
from the
Apache web server distribution
to create the users that use CVS. They don't need to match
any actual users in the system.
It is very important that you create the
passwd file under the $CVSROOT
directory directly. It is not managed by CVS per se, but
it is used by CVS server to authenticate the user who
tries to log in.
For example, you can create an account john
with password 123456 using the following
commands:
cd $CVSROOT
htpasswd -c passwd john
In addition, you also need to modify the file directly to
map the CVS user john to the actual Unix user in
the system. That is, you can have different CVS users map
to the same Unix user. We assume that you set up CVS
server as non-root user and your Unix user name is andy,
then you need to append the user name andy to
the line that contains the user john and his
password. The resulting file looks like this:
john:4EWw4ylktA74U:andy
To start CVS server to accept connections, you need to use
xinetd, the extended Internet services daemon which
is probably installed on your Linux box already. The master
configuration file for xinetd is probably
named as /etc/xinet.conf which may include
separate files for individual services.
Since as a non-root user you cannot modify the
system configuration files, so you have to copy and
modify the file or section that is related to CVS pserver
configuration and then run xinetd with your
own modified copy.
Please note that by default CVS server listens at port
2401 and the service name is cvsperver which
you can look up from /etc/services. For
your convenience, we show
the sample xinetd.conf
file for CVS server below.
service cvspserver
{
socket_type = stream
protocol = tcp
wait = no
user = andy
server = /usr/bin/cvs
server_args = -f --allow-root=/var/tmp/local/cvsroot pserver
disable = no
}
Please note here that the CVS server should run as you, assuming your
Unix user name on the system is andy. Suppose you save the
file in /var/tmp/local/cvsroot, then you can start
xinetd as follows:
xinetd -d -f /var/tmp/local/cvsroot/xinetd.conf
With the -d option, you turn on the debug option so you
can see why it fails if there is anything wrong. After done with testing,
you can remove this option and have it running in the background as a daemon.
Because your new CVS repository may be different from your old local CVS
repository, you can copy all the files and directories from the old one
excluding the CVSROOT directory to the new one.
Now you can try to access your CVS server from another machine
dev.example.com. On your local machine set the CVSROOT
environment variable to point to the remote repository.
export CVSROOT=:pserver:john@cvsserver.example.com:/var/tmp/local/cvsroot
Please note here that the CVS user name john is different from
your local Unix user name andy. Before checking out any files,
you need to log in first with cvs login and type in the password
you created earlier with htpasswd. Then you should be able
to check out and check in files. If you check the CVS log with
cvs log <any_cvs_file>, you will also
see that the CVS server records the fact correctly that the files are checked
in by the CVS user john, not the Unix system user andy.
References
- Jennifer Vesperman' book "Essential CVS, 2nd Edition": It seems to me that CVS manual is more geared towards users of the CVS client. This book complements the CVS manual with more information on CVS administration.