Chinaunix首页 | 论坛 | 博客
  • 博客访问: 333803
  • 博文数量: 64
  • 博客积分: 2301
  • 博客等级: 大尉
  • 技术积分: 570
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-25 11:48
文章分类

全部博文(64)

文章存档

2013年(5)

2012年(6)

2011年(36)

2010年(7)

2009年(10)

分类: LINUX

2009-08-20 17:04:36

st1\:*{behavior:url(#ieooui) }

CVS服务器的安装配置

一、Cvs服务器的安装配置

本文测试的系统环境是linux redhat enterprise as 5.3
首先确认系统中是否安装CVS服务。
[root@localhost /]# rpm -qa|grep cvs
cvs-1.11.22-5.el5
如果命令输出类似于上面的输出则说明系统已经安装有cvs,否则就需要从安装光盘中安装cvsrpm包,或者到下载。

1
、建立 CVSROOT 目录

因为这里涉及到用户对CVSROOT里的文件读写的权限问题,且不允许验证系统账户,即不允许利用系统账户登录。假设我们建一个组叫cvs,用户名是cvsroot。建组和用户的命令如下

#groupadd cvs
(如果不检测系统账号可以省略此部操作)
#useradd -g cvs -G cvs -d  /cvsroot cvsroot

生成的用户宿主目录在/cvsroot(根据自己的系统调整)

2
、建立CVS仓库,用cvsroot 用户登陆,用下面命令:

$cvs -d  /cvsroot init
(或export CVSROOT=/cvsroot   cvs init

3
、仍然是 cvsroot 用户,修改 /cvsroot CVSROOT)的权限,赋与同组人有读写的权限:(如果不检测系统账户可以省略此步操作) 

$chmod 775 -R /cvsroot

4
、用root登录,加入cvs服务,如过服务存在就不用添加了

vi /etc/services
cvspserver 2401/tcp #pserver cvs service
cvspserver 2401/udp #pserver cvs service

cvs
服务由inted来唤起,因此需要改动inetd提供的服务,如果你的redhat使用的是inetd 方式则在文件/etc/inetd.conf中加入如下的内容:cvspserver stream tcp nowait root /usr/bin/cvs cvs --allow-root=/home/cvsroot pserver

如果redhat enterprise as5使用的是xinetd方式,所以在xinetd.d目录下添加需要启动的服务:
cd /etc/xinetd.d
vi cvspserver
文件内容:
service cvspserver
{
  disable = no
  flags = REUSE
  socket_type = stream
  wait = no
  user = cvsroot
  server = /usr/bin/cvs
  server_args = -f --allow-root=/cvsroot pserver
  log_on_failure += USERID
}
 
注:也可以直接使用xinetd/cvs 文件,并进行修改。
重新启动inetd或者xinetd:
/etc/rc.d/init.d/xinetd restart

检查cvspserver服务是否已经启动
[root@localhost /]# netstat -lnp|grep 2401
tcp        0      0 0.0.0.0:2401            0.0.0.0:*               LISTEN      1041/xinetd 
则说明cvs服务器已经运行。

 
.管理CVS服务器
1.用户设置
/cvsroot目录里有一个 CVSROOT 目录,这个目录里有三个配置文件,passwd, readers, writers,用户可以通过设置这三个文件来配置 CVS 服务器,下面分别介绍这几个文件的作用:

passwd
cvs 用户的用户列表文件,它的格式很象 shadow 文件:

{cvs
用户名}:[加密的口令]:[等效系统用户名]

readers
:有 cvs 读权限的用户列表文件。就是一个一维列表。在这个文件中的用户对 cvs只有读权限。

writers
:有 cvs 写权限的用户的列表文件。和 readers 一样,是一个一维列表。在这个文件中的用户对 cvs 有写权限。

上面三个文件在缺省安装的时候可能都不存在,需要我们自己创建。注意, readers文件比writers优先,也就是说出现在readers中的用户将会是只读的,不管writers文件中是否存在该用户。
CVS
默认使用系统用户登录,为了系统安全性的考虑也可以使用独立的用户管理。CVS用户名和密码保存在CVSROOT目录下的passwd文件中,格式为:
cvs 用户名]:[加密的口令]:[等效系统用户名]

1)
先创建一个passwd文件
$ cd /cvsroot/CVSROOT/

$ htpasswd -c passwd cvsuser

New password:

Re-type new password:

Adding password for user cvsuser

$ cat passwd

cvsuser:R9oDKNeysScdw

$vi passwd

在末尾添加 :cvsroot

作用是映射到cvsroot用户,最终结果如下:

cvsuser:R9oDKNeysScdw:cvsroot

在创建其他用户时,不用带参数


#htpasswd passwd
用户名

New password:

Re-type new password:
vi passwd    and  add   :cvsroot

writerreader文件里边添加刚才的账户为用户添加权限。
要彻底防止使用系统帐号登陆,可以编辑CVSROOT目录下的config文件,把:
#SystemAuth=yes

这一行前面的#去掉,改为如下形式:

SystemAuth=no

CVS
就不会验证系统用户了,否则当用户名不在passwd文件中时,CVS会进行系统用户的验证。


2.
提交工程
进入到你的已有项目的目录,比如叫 cvstest

$cd  cvstest
运行命令:
$ export CVSROOT=cvsroot/  

$ cvs import -m "my cvs project" cvstest cvsroot start

N myProject/makefile

 

N myProject/helloworld.cpp

 

 

 

No conflicts created by this import

装载cvs import -m "[repository test]" [cvstest] [vendortag] [releasetag]

-m后面引号内填入log内容,接下来是源代码模块名称,接着是装载者,最后是标识符号,我这里是:
三、客户端测试
1
、连接CVS服务器
刚才建立的CVS服务器端的IP为:10.15.5.89

客户端主机使用非root用户,我的用户名为test
首先建立环境变量CVSROOT,以刚才建立的CVS用户cvsuser登录:

[test@liu ~]$ export CVSROOT=:pserver:cvsuser@10.15.5.89: /cvsroot

[test@liu ~]$ cvs login

Logging in to :pserver:cvsuser@10.15.5.89:2401 /cvsroot

CVS password:

[test@liu ~]$

如果没有错误提示,则代表成功登录CVS服务器。

---------------------------------------

在此却很有可能出现:unrecognized auth response from 10.15.5.89: cvs pserver: cannot open /cvsroot/CVSROOT/config: Permission denied

尤其是当你的linux版本较高时。
这是由于selinux的原因,这是一种安全机制,具体可以上网查。
只要关闭selinux就可以了:

编辑/etc/selinux/config

SELINUX设置为SELINUX=disabled,禁用SELINUX

 

 

2、检出模块
我们上面已经建立了一个仓库了: cvstest

我们在客户端将该模块checkout

[test@liu ~]$ cvs checkout cvstest

cvs checkout: Updating cvstest t

U cvstest /helloworld.cpp

U cvstest t/makefile

[test@liu ~]$

好了,在当前目录下生成了目录cvstest,现在你就可以进入cvstest 进行修改,删除,提交等操作了。

对于使用CVS的用户要修改它的环境变量,例如laser用户的环境变量,打开/home/laserlaser的宿主目录)下的.bash_profile文件,加入

CVSROOT=/cvsroot
export CVSROOT

3.用户数据的提交

 用户数据checkout出来后,如果对文件进行了修改,添加,删除等操作修要对文件进行提交,此时运行一下命令。

  Export  CVSROOT=:pserver:cvstest@10.15.5.89:/cvsroot

  Cvs login

   Passwd:

   登陆成功后提交问修改后的文件。

   Cvs  add  newfile

   Cvs  commit

  然后一路回车,会显示提交成功。

 

 

 

四.建立更多的仓库的技巧

由于xinetdserver_args长度限制,当你想运行很多的单个仓库的时候,可以这么做

 

1)修改cvspservercvs文件 

#vi /etc/xinetd.d/cvspserver

 

修改它们的内容中如下:

 

service cvspserver

{

disable = no

socket_type = stream

wait = no

user = root

server = /cvsroot/cvs.run

log_on_success += USERID

log_on_failure += USERID

}

 

2)然后写脚本/home/cvsroot/cvs.run

#vi /home/cvsroot/cvs.run

 

脚本内容如下:

 

#!/bin/bash

 

/usr/bin/cvs -f "

--allow-root=/home/cvsroot/pro1 "

--allow-root=/home/cvsroot/pro2 "

--allow-root=/home/cvsroot/pro3 "

--allow-root=/home/cvsroot/pro4 "

--allow-root=/home/cvsroot/pro5 "

--allow-root=/home/cvsroot/pro6 "

pserver

 

3)更改cvs.run的权限:

#chmod +x /home/cvsroot/cvs.run

 

4)重启服务:

#service xinetd restart







 

 
阅读(893) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~