Linux SVN 钩子 pre-revprop-change 不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10736505/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 06:29:17  来源:igfitidea点击:

SVN hook pre-revprop-change not working

linuxsvnversion-controlwebdavselinux

提问by Lee Netherton

I know that this has been asked many times before, but I believe my situation is different.

我知道这已经被问过很多次了,但我相信我的情况有所不同。

I am trying to add a pre-revprop-change hook to our SVN repository to enable changes to be made to log messages.

我正在尝试向我们的 SVN 存储库添加一个 pre-revprop-change 挂钩,以允许对日志消息进行更改。

Before I added the pre-revprop-changefile I was getting this error:

在我添加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

No problem, I thought. I'll add it:

没问题,我想。我来补充一下:

$ 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 $?
0

So, according to everything else I've read on SO, that should be all I need to make it work. But, when I try to edit the log message again, I still get an error (a different one this time):

因此,根据我在 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.

There are a few points to note:

有几点需要注意:

1) The repository is hosted on an SELinux server (Fedora core 10). Perhaps there is something that I need to do with regards to those permissions? Here are the SE permissions of the hook:

1) 存储库托管在 SELinux 服务器(Fedora 核心 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) The repository is being accessed via WebDAV (note the https://in the repository name). Is there something that I need to setup on the WebDAV side to allow pre-revprop-change changes?

2) 正在通过 WebDAV 访问存储库(注意https://存储库名称中的 )。是否需要在 WebDAV 端设置一些内容以允许 pre-revprop-change 更改?

采纳答案by Lee Netherton

After several hours of trying, I've found the answer. And, as it doesn't seem to exist anywhere else on the internet, I'll post it here...

经过几个小时的尝试,我找到了答案。而且,因为它似乎在互联网上的其他任何地方都不存在,所以我会在这里发布...

The problem was caused by SELinux (no great surprise there). It seems that apache (/usr/sbin/httpd) did not have the necessary permissions to run the hook script with the afore-mentioned SE permissions. To get it to execute, the SELinux permissions needed to be changed with

问题是由 SELinux 引起的(这并不奇怪)。apache ( /usr/sbin/httpd) 似乎没有必要的权限来运行具有上述 SE 权限的钩子脚本。要让它执行,需要更改 SELinux 权限

$ chcon -t httpd_exec_t pre-revprop-change

(I first tried changing it to httpd_sys_script_exec_t, but this was not enough to get the script to execute. But with the httpd_exec_ttype it worked.)

(我首先尝试将其更改为httpd_sys_script_exec_t,但这还不足以让脚本执行。但对于httpd_exec_t它的工作类型。)

Final question: is this a secure thing to be doing?

最后一个问题:这是一件安全的事情吗?

回答by Nux

Had a similar thing on CentOS. The problem was probably somewhere in caching as when I edited the file and then change it back it started to work.

在 CentOS 上有类似的事情。问题可能出在缓存中,因为当我编辑文件然后将其改回它开始工作时。

So if anyone have a similar problem simply try:

因此,如果有人遇到类似问题,请尝试:

touch hooks/pre-revprop-change