SVN配置

svnadmin create D:\SVN_SERVER_FODLER   创建档案库
D:\SVN_SERVER_FODLER\conf 目录下设置权限
D:\SVN_SERVER_FODLER\conf\svnserve.conf  设置存取权限
D:\SVN_SERVER_FODLER\conf\passwd  设置用户及密码
D:\SVN_SERVER_FODLER\conf\authz  设置用户组 及用户对应的目录权限


安装服务
sc create Svn binpath= "C:\Program Files\Subversion\bin\svnserve.exe --service -r D:\SVN" displayname= "Svn" depend= Tcpip

删除服务
 sc delete Svn

修改配置
 sc config Svn binpath= "C:\Program Files\Subversion\bin\svnserve.exe --service -r D:\SVN" displayname= "Svn" depend= Tcpip

设置为自启动
 sc config Svn start= auto

启动服务
 net start Svn

 

Group权限设定:


      我们会在目录结构中找到一个叫做conf的文件夹,打开这个文件夹,你会看到三个文件,分别叫做authz,passwd,svnserve.conf。


下面我们就来介绍一下这三个文件的作用格式什么。


首先,我们介绍passwd这个文件。


用你习惯的文本编辑器打开这个文件,你会看到一些使用“#”注释掉的说明,其中关键的就是在[users]下面,有


# harry = harryssecret
# sally = sallyssecret


样的样板代码,意思就是有两个用户,其中一个的用户名叫“harry”,密码为“harryssecret”,而另一个用户名为“sally”,密码为“sallyssecret”。我们接下来为我们的测试下面添加一些用户,这样方便我们下面的说明。比如,我要添加三个用户,一个叫做“nicholas”,密码为“nicholas”,第二个用户名为“friend”,密码为“friend”,第三个为“stranger”,密码为“strangers”。


代码如下:


nicholas = nicholas
friend = friend
stranger = stranger


这样,我们就添加好了三个认证用户。


### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
 
[users]
# harry = harryssecret
# sally = sallyssecret
nicholas = nicholas
friend = friend
stranger = stranger


 
      下面,我们来介绍authz这个文件,这个文件是控制权限的关键。


同样打开这个文件,你会看到一些注释掉的语句,


# [groups]
# [/foo/bar]
# [repository:/baz/fuz]


      下面,我们介绍一下用户组的概念。所谓用户组,顾名思义,就是一个成员组,一般情况下,在同一个成员组的人员享有同样的权力,比如读,写权。Subversion为我们提供了一个很好的用户组应用。
在之前,我们一共建立三个用户,nicholas,friend和stranger,我们现在设想一下我们的组情况,假设我们希望nicholas和friend在开发组中,这两个用户具有读和写的权力,而用户stranger在测试组中,只具备读的权力。那么我们该如何来控制这个权限呢?看看下面的代码:
我们先在[groups]标记下面,输入组的名称:
dev_group = nicholas, friend
test_group = stranger
到目前为止,我们已经为三个用户分好了用户组,其中nicholas和friend在dev_group中,而stranger则在test_group中。


      下面,我们为两个组来分配权限。
首先我们要为这两个组所能访问的工程做一个规定,正如在之前的文章《Eclipse中使用Subversion进行版本控制》中,曾经向版本参考提交了一个名为“TestSVNProj”的项目,下面我就假设刚刚建立的两个用户组都需要最这个工程进行操作。
      我们在authz文件中,写下[TestSVNProj],这个是指定我们下面将对TestSVNProj项目进行定义。
我们使用如下代码:


@dev_group = rw
@test_group = r


这就定义了,对TestSVNProj项目,dev_group用户组可以进行读,写操作,而test_group用户组则只具备读的权限。
为了阻止其他用户组对这个文件有读的权力,我们可以再添加一句:


* =
这个语句就是指定其他的用户组的权力为空,也就是没有权力。


### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to a
### single user, to a group of users defined in a special [groups]
### section, or to anyone using the '*' wildcard. Each definition can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').
 
[groups]
# harry_and_sally = harry,sally
 
dev_group = nicholas,friend
test_group = stranger
 
# [/foo/bar]
# harry = rw
# * =
 
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
 
[/TestSVNProj]
@dev_group = rw
@test_group = r
* =


 
最后,我们在来说说这个svnserve.conf文件,打开这个文件,我们就可以看出这个是Subversion权限配置的主文件,类似于读取相关信息的枢纽。
为了让我们刚刚配置的两个文件(passwd和authz)起作用,我们需要去掉password-db = passwd和authz-db = authz前面的注释符“#”,让Subversion知道要从上面两个文件中读取相关信息。
当然,你也可以指定其他的认证文件,写法如下:


password-db = ..\..\passwd
authz-db = ..\..\authz


以此类推。
       在实战过程中,处于安全的考虑,我们往往要限制对匿名用户的访问权限,所以我们可以将anon-access = read前面的“#”去掉,并将read参数修改为none,表明禁止匿名用户对版本控制库的访问。
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
 
### Visit
http://subversion.tigris.org/ for more information.
 
[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
anon-access = none
# auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the conf
### directory. If you don't specify an authz-db, no path-based access
### control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
# realm = My First Repository
 
至此,你可以控制你的项目,对其进行访问权限的控制了。

 

我们会在目录结构中找到一个叫做conf的文件夹,打开这个文件夹,你会看到三个文件,分别叫做authz,passwd,svnserve.conf。
下面我们就来介绍一下这三个文件的作用格式什么。
首先,我们介绍passwd这个文件。
用你习惯的文本编辑器打开这个文件,你会看到一些使用“#”注释掉的说明,其中关键的就是在[users]下面,有
# harry = harryssecret
# sally = sallyssecret
样的样板代码,意思就是有两个用户,其中一个的用户名叫“harry”,密码为“harryssecret”,而另一个用户名为“sally”,密码为“sallyssecret”。我们接下来为我们的测试下面添加一些用户,这样方便我们下面的说明。比如,我要添加三个用户,一个叫做“nicholas”,密码为“nicholas”,第二个用户名为“friend”,密码为“friend”,第三个为“stranger”,密码为“strangers”。
代码如下:
nicholas = nicholas
friend = friend
stranger = stranger


这样,我们就添加好了三个认证用户。


### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
 
[users]
# harry = harryssecret
# sally = sallyssecret
nicholas = nicholas
friend = friend
stranger = stranger
 
      下面,我们来介绍authz这个文件,这个文件是控制权限的关键。
同样打开这个文件,你会看到一些注释掉的语句,


# [groups]
# [/foo/bar]
# [repository:/baz/fuz]


       下面,我们介绍一下用户组的概念。所谓用户组,顾名思义,就是一个成员组,一般情况下,在同一个成员组的人员享有同样的权力,比如读,写权。Subversion为我们提供了一个很好的用户组应用。
在之前,我们一共建立三个用户,nicholas,friend和stranger,我们现在设想一下我们的组情况,假设我们希望nicholas和friend在开发组中,这两个用户具有读和写的权力,而用户stranger在测试组中,只具备读的权力。那么我们该如何来控制这个权限呢?看看下面的代码:
我们先在[groups]标记下面,输入组的名称:
dev_group = nicholas, friend
test_group = stranger
到目前为止,我们已经为三个用户分好了用户组,其中nicholas和friend在dev_group中,而stranger则在test_group中。
      下面,我们为两个组来分配权限。
首先我们要为这两个组所能访问的工程做一个规定,正如在之前的文章《Eclipse中使用Subversion进行版本控制》中,曾经向版本参考提交了一个名为“TestSVNProj”的项目,下面我就假设刚刚建立的两个用户组都需要最这个工程进行操作。
      我们在authz文件中,写下[TestSVNProj],这个是指定我们下面将对TestSVNProj项目进行定义。
我们使用如下代码:
@dev_group = rw
@test_group = r
      这就定义了,对TestSVNProj项目,dev_group用户组可以进行读,写操作,而test_group用户组则只具备读的权限。
为了阻止其他用户组对这个文件有读的权力,我们可以再添加一句:
* =


这个语句就是指定其他的用户组的权力为空,也就是没有权力。
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to a
### single user, to a group of users defined in a special [groups]
### section, or to anyone using the '*' wildcard. Each definition can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').
 
[groups]
# harry_and_sally = harry,sally
 
dev_group = nicholas,friend
test_group = stranger
 
# [/foo/bar]
# harry = rw
# * =
 
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
 
[/TestSVNProj]
@dev_group = rw
@test_group = r
* =


 
      最后,我们在来说说这个svnserve.conf文件,打开这个文件,我们就可以看出这个是Subversion权限配置的主文件,类似于读取相关信息的枢纽。
为了让我们刚刚配置的两个文件(passwd和authz)起作用,我们需要去掉password-db = passwd和authz-db = authz前面的注释符“#”,让Subversion知道要从上面两个文件中读取相关信息。
当然,你也可以指定其他的认证文件,写法如下:


password-db = ..\..\passwd
authz-db = ..\..\authz


以此类推。
       在实战过程中,处于安全的考虑,我们往往要限制对匿名用户的访问权限,所以我们可以将anon-access = read前面的“#”去掉,并将read参数修改为none,表明禁止匿名用户对版本控制库的访问。


Windows下SVN权限配置说明(一个目录下多库)

1、本文档适用于对Subvesion的自带服务svnserve进行权限配置,全部在authz文件中完成。

2、如果要对含有中文的目录或文件进行管理或分配时,需要将该文件保存为UTF-8格式,微软的记事本保存为UTF-8格式无效,所以不要用。可用如UltraEdit或EditPlus等软件完成,保存时,格式应选择UTF-8 NO BOM。

3、权限分配时,应遵守从根目录到子目录、从设置最广泛权限到最精细权限、从只读权限到读写权限设置原则,即从根目录开始设置最广泛的访问权限,然后逐步设置下属子目录的访问权限。提示:目录的访问权限既可以分配给组,也可以分配指定用户。
现举例进行说明:
启动服务:服务应指向所有版本库的根目录,本例中为D:\SVN,命令如下:
sc create SVNService binpath= "D:\Subversion\bin\svnserve.exe --service -r D:/SVN" displayname= "SVNService" depend= Tcpip start= auto
项目情况:D盘根目录下有一个文件夹SVN,在该文件夹中有jsyxv3、svntest两个版本库(可以有更多个),这些版本库共享使用同一个权限配置文件,目录结构如下:
D:\SVN
|---jsyxv3       (项目一,子目录略)
|---svntest       (项目二,子目录略)
|---authz       (共享的权限配置文件)
|---passwd       (共享的密码文件)

 

#=====配置开始=====


#分组:
[groups]
group_admin = wws,aaa,bbb
group_user1 = sj,ccc
group_user2 = sy,dd,eeee
group_user3 = lxt
group_user4 = ss

 

#设置对根(即SVN)目录下,所有版本库的访问权限
[/]
* = r             #所有登录用户默认权限为只读
@group_admin = rw #可以分配给组,该组有读写权限
wws = rw     #也可以像这样分配给指定用户

#以下将对各版本库的及其目录进行权限分配
[jsyxv3:/]     #设置对jsyxv3版本库中,所有项目的访问权限
* =               #未授权用户没有任何权限
@group_user1 = rw

[jsyxv3:/程序管理] #设置对jsyxv3版本库中程序管理目录的访问权限
* =               #未授权用户没有任何权限
@group_user2 = rw

[jsyxv3:/项目管理] #设置对jsyxv3版本库中项目管理目录的访问权限
* =               #未授权用户没有任何权限
@group_user3 = rw

[svntest:/]   #设置对svntest版本库中,所有项目的访问权限
* =              #未授权用户没有任何权限
@group_user1 = rw

[svntest:/程序管理] #设置对svntest版本库中程序管理目录的访问权限
* =              #未授权用户没有任何权限
@group_user2 = rw
@group_user3 = rw

[svntest:/项目管理] #设置对svntest版本库中项目管理目录的访问权限
* =              #未授权用户没有任何权限


@group_user4 = rw


#=====配置结束=====

 

4、     最后重要提示:
4.1启动的服务与客户端检出的关系:
4.1.1  如果启动的服务指向一个具体的版本库,如红字部分描述:
sc create SVNService binpath= "D:\Subversion\bin\svnserve.exe --service -r D:/SVN/svntest" displayname= "SVNService" depend= Tcpip start= auto
则客户端检出的地址应为:svn://192.168.0.1/
4.1.2  如果启动的服务指向的是多个版本库的父目录,如红字部分描述:
sc create SVNService binpath= "D:\Subversion\bin\svnserve.exe --service -r D:/SVN" displayname= "SVNService" depend= Tcpip start= auto
则客户端检出的地址应为:svn://192.168.0.1/svntest
4.2如果权限管理完成时,对各版本库还未完成导入工作,请记得使用对SVN目录有读写权限的用户身份进行操作,否则有可能会提示操作失败(因为权限不够)。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值