svn: E170001 : Authorization failed 非主流的解决方案!

问题描述

新手在使用SVN,执行checkout想要获取一份仓库副本时一直报错:

root@VM-32-73-ubuntu:/home/ubuntu# svn checkout svn://localhost/svntest --username=nigelzhou
svn: E170013: Unable to connect to a repository at URL 'svn://localhost/svntest'
svn: E220003: Invalid authz configuration

问题尝试

在网上搜索了一下,所有的人都说使用svnauthz-validate工具去检查authz文件是否出错,但是我使用该工具后检查不出任何错误:

root@VM-32-73-ubuntu:/home/ubuntu# svnauthz-validate /opt/svn/svntest/conf/authz
root@VM-32-73-ubuntu:/home/ubuntu# svn checkout svn://localhost/svntest --username=nigelzhou
svn: E170013: Unable to connect to a repository at URL 'svn://localhost/svntest'
svn: E220003: Invalid authz configuration

再次尝试,仍然报错。

思考过程

在网上看到很多人使用svnauthz-validate工具检测后都说用户组配置有错,虽然我没有检测出来,但是报同样的错,我是不是也是用户组出问题了呢?于是去检查我的authz配置文件:

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r


[/]
nigelzhou = rw
nigel = rw

仔细检查后,发现我的配置并没有错,完全是按照注释中的范例来写的。
关于用户组的配置有两处,最主要的是authz,另一处就是总配置文件svnserve.conf,现在authz确定没有错误,那么去检查svnserve.conf:

authz-db = authz
### The groups-db option controls the location of the groups file.
### Unless you specify a path starting with a /, the file's location is
### relative to the directory containing this file.  The specified path
### may be a repository relative URL (^/) or an absolute file:// URL to a
### text file in a Subversion repository.
groups-db = groups
### 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

发现groups-db = groups这个配置之前被我取消注释,启用了。仔细阅读它的注释,发现该配置是指定“group file”的位置的。
注释中还提到“ Unless you specify a path starting with a /, the file’s location is relative to the directory containing this file. ”即除非我们指定一个以‘/’开头的绝对路径,否则该配置是基于本目录的相对路径,而该目录下并没有groups文件,因此该配置不能被启用!

解决方案

将“groups-db = groups”注释掉,再次测试:

root@VM-32-73-ubuntu:/home/ubuntu# svn checkout svn://localhost/svntest --username=nigelzhou
svn: E170013: Unable to connect to a repository at URL 'svn://localhost/svntest'
svn: E220003: Invalid authz configuration
root@VM-32-73-ubuntu:/home/ubuntu# vim /opt/svn/svntest/conf/svnserve.conf
root@VM-32-73-ubuntu:/home/ubuntu# svn checkout svn://localhost/svntest --username=nigelzhou
Authentication realm: <svn://localhost:3690> My First Repository
Password for 'nigelzhou': ************

成功连接!

总结

在修改配置文件是要注意配置项上面的注释,不能随意修改,否则会出现这次这样难以定位的错误。

猜你喜欢

转载自blog.csdn.net/zhoucheng05_13/article/details/80952014
今日推荐