相关文章推荐

SVN挂钩pre-revprop-change不起作用

13 人关注

我知道这个问题以前已经问过很多次了,但我相信我的情况是不同的。

我正试图在我们的SVN版本库中添加一个pre-revprop-change钩子,以便能够对日志信息进行修改。

在我添加 pre-revprop-change 文件之前,我得到了这个错误。

$ svn propset -r 557 --revprop svn:log "New message!" https://myserver/repos/myrepo
svn: DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent
svn: At least one property change failed; repository is unchanged
svn: Error setting property 'log': 
Repository has not been enabled to accept revision propchanges;
ask the administrator to create a pre-revprop-change hook

没问题,我想。我把它加进去。

$ cd /var/www/svn/myrepo/hooks
$ # Create the simplest hook possible
$ echo '#!/bin/sh' > pre-revprop-change
$ echo 'exit 0' >> pre-revprop-change
$ # Check that it looks correct
$ cat pre-revprop-change
#!/bin/sh
exit 0
$ # Looks good, now make it executable
$ chmod a+x pre-revprop-change
$ # Check the permissions
$ ls -al pre-revprop-change
-rwxr-xr-x 1 apache apache 17 2012-05-24 12:05 pre-revprop-change
$ # Run it, to make sure it runs, and check the error code
$ ./pre-revprop-change 
$ echo $?

所以,根据我在SO上读到的其他内容,这应该是我需要的全部内容。但是,当我试图再次编辑日志信息时,我仍然得到一个错误(这次是一个不同的错误)。

$ svn propset -r 557 --revprop svn:log "New message!" https://myserver/repos/myrepo
svn: DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent
svn: At least one property change failed; repository is unchanged
svn: Error setting property 'log': 
Revprop change blocked by pre-revprop-change hook (exit code 255) with no output.

有几点需要注意。

1) 版本库托管在一个SELinux服务器上(Fedora core 10)。也许在这些权限方面我需要做些什么?下面是钩子的SE权限。

$ ls -alZ pre-revprop-change
-rwxr-xr-x  apache apache unconfined_u:object_r:httpd_sys_content_rw_t:s0 pre-revprop-change

2) 版本库是通过WebDAV访问的(注意版本库名称中的https://)。我是否需要在 WebDAV 端设置一些东西,以允许预先修改prop的变化?

linux
svn
version-control
webdav
selinux
Lee Netherton
Lee Netherton
发布于 2012-05-24
2 个回答
Lee Netherton
Lee Netherton
发布于 2013-07-17
已采纳
0 人赞同

经过几个小时的尝试,我已经找到了答案。由于它似乎不存在于互联网上的任何其他地方,我将在这里发布它......

这个问题是由SELinux引起的(没有什么好奇怪的)。似乎apache( /usr/sbin/httpd )没有必要的权限来运行具有上述SE权限的钩子脚本。为了让它执行,需要用以下方法改变SELinux的权限

$ chcon -t httpd_exec_t pre-revprop-change

(我首先尝试把它改为httpd_sys_script_exec_t,但这不足以让脚本执行。但是用httpd_exec_t的类型就可以了)。

最后一个问题:这样做是否安全?

这是否安全取决于你对 "安全 "的标准 :)...但是,是的,SELinux可能导致一些微妙的问题,不过可以通过启用日志来诊断。
谢谢。是的,我不认为我们的服务器会成为黑客的中心,但我只是想确认我没有打开一个巨大的安全漏洞你知道为什么使用 httpd_sys_script_exec_t 不起作用吗?从文档中可以看出,它应该有...
我也认为这应该是有效的。我不知道为什么必须是 httpd_exec_t 而不是 httpd_sys_script_exec_t 。但有可能是SELinux能够以某种方式区分输出到Apache的脚本和输出到其他地方的脚本。你在那里使用Apache而不是 svnserve (即使Apache可能代理它),对吗?
是的,肯定是通过apache进行的。svn的WebDAV网址配置在 /etc/httpd/conf.d/ 目录下。而我是通过 https:// 的网址来访问的。
Nux
Nux
发布于 2013-07-17
0 人赞同

在CentOS上也有类似的情况。问题可能出在缓存的某个地方,因为当我编辑了这个文件,然后把它改回来,就开始工作了。

 
推荐文章