Configuring CVS Server

如何安装 CVS 就不写了,不外乎就是 configure, make, make install 三步曲。本文的目的是介绍如何在 Linux 系统上配置一个 CVS Server,且使用虚拟用户帐号、而不是操作系统用户帐号。

1 Create a new repository

为每一个项目(或数个相关度高的项目)创建一个新的 repository 是一个良好的习惯,这样可以很好地将不同的项目分开管理。

# mkdir /cvsroot/repoa

2 Create group(s), user(s)

虽然我们将使用虚拟帐号作为 CVS 用户,但是每个虚拟帐号都必须映射到实际的操作系统用户帐号上,所以至少需要创建一个操作系统用户帐号。若在开发过程中涉及访问权限问题,这时就根据需求来决定是否需要创建组帐号或者其他操作系统用户帐号。本文中不考虑访问权限问题。

# groupadd cvs
# useradd -g cvs -d /cvsroot/repoa cvsroot
# chown -R cvsroot:cvs /cvsroot/repoa
# chmod 775 /cvsroot/repoa

3 Initialize repository

# su – cvsroot
$ cvs -d /cvsroot/repoa init

4 /etc/xinetd.d/cvspserver

本文将使用 xinetd 来控制 CVS Server,其配置文件是 /etc/xinetd.d/cvspserver,若该文件不存在就新建一个。注意,需要使用 root 用户。将以上新建的 repository 加入到 server_args 中(如下清单中的粗体部分)。

service cvspserver
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = cvsroot
server = /usr/bin/cvs
server_args = -f –allow-root=/cvsroot/btm –allow-root=/cvsroot/repoa pserver
log_on_failure += USERID
}

5 CVS virtual accounts

默认情况下,CVS 使用 OS 的用户进行验证,这对于 OS 来说,易造成安全隐患,所以我们通常使用虚拟用户帐号。其实是通过一个 passwd 文件将 CVS 虚拟用户映射到某个真实的 OS 用户帐号,比如其上我们建立的 cvsroot,当然,可以根据实际的项目需求将不同的虚拟帐号映射到不同的 OS 用户帐号。

5.1 修改配置文件 config
# su – cvsroot
$ cd /cvsroot/repoa/CVSROOT
$ chmod 644 config
$ vi config

将 "#SystemAuth=no" 前的 "#" 去掉,即,禁止直接使用 OS 的用户帐号进行验证。

5.2 建立一个密码生成脚本 passwdgen.pl,放置到系统 PATH 路径下,比如 /usr/local/bin 或者 /usr/bin

# cd /usr/local/bin
# vi passwdgen.pl

#!/usr/bin/perl
srand (time());
my $randletter = "(int (rand (26)) + (int (rand (1) + .5) % 2 ? 65 : 97))";
my $salt = sprintf ("%c%c", eval $randletter, eval $randletter);
my $plaintext = shift; my $crypttext = crypt ($plaintext, $salt);
print "${crypttext}\n";

# chmod 755 passwdgen.pl

5.3 建立 CVS 的虚拟用户文件 passwd,位置在 /cvsroot/repoa/CVSROOT/ 下
文件中的记录形势为:

vuser1:xxxxxxxxxxxxx:cvsroot

其中的 xxxxxxxxxxxxx 即为密码段,用脚本 passwdgen.pl 来生成,如:
$ passwdgen.pl the_password

END.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">