windows 在 Subversion 存储库中存储文件权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/56149/
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-09-09 05:15:16  来源:igfitidea点击:

Storing file permissions in Subversion repository

windowssvnfile-permissions

提问by graham.reeds

How do you store file permissions in a repository? A few files need to be read-only to stop a third party program from trashing it but after checking out of the repository they are set to read-write.

如何在存储库中存储文件权限?一些文件需要只读以阻止第三方程序破坏它,但在检出存储库后,它们被设置为读写。

I looked on google and found a blog post from 2005that states that Subversion doesn't store file-permissions. There are patches and hook-scripts listed (only one url still exists). Three years later does Subversion still not store file permissions and are hooks the only way to go about this? (I've never done hooks and rather use something that is native to Subversion.)

我在谷歌上查看并发现了2005 年一篇博客文章,其中指出 Subversion 不存储文件权限。列出了补丁和钩子脚本(只有一个 url 仍然存在)。三年后,Subversion 是否仍然不存储文件权限,钩子是解决此问题的唯一方法吗?(我从来没有做过钩子,而是使用了 Subversion 原生的东西。)

采纳答案by morechilli

One possible solution would be to write a script that you check in with the rest of your code and which is run as the first step of your build process.

一种可能的解决方案是编写一个脚本,您可以将其与其余代码一起检入,并将其作为构建过程的第一步运行。

This script runs through your copy of the codebase and sets read permissions on certain files.

此脚本贯穿您的代码库副本并设置对某些文件的读取权限。

Ideally the script would read the list of files from a simple input file. This would make it easy to maintain and easy for other developers to understand which files get marked as read-only.

理想情况下,脚本将从一个简单的输入文件中读取文件列表。这将使其他开发人员易于维护并易于了解哪些文件被标记为只读。

回答by Richard Tasker

SVN does have the capability of storing metadata (properties) along with a file. The properties are basically just key/value pairs, however there are some special keys like the 'svn:executable', if this property exists for a file, Subversion will set the filesystem's executable bit for that file when checking the file out. While I know this is not exactly what you are looking for it might just be enough (was for me).

SVN 确实具有将元数据(属性)与文件一起存储的能力。属性基本上只是键/值对,但是有一些特殊的键,如“svn:executable”,如果文件存在此属性,Subversion 会在检出文件时为该文件设置文件系统的可执行位。虽然我知道这并不完全是你正在寻找的,但它可能就足够了(对我来说)。

There are other properties for line ending (svn:eol-style) and mime type(svn:mime-type).

行尾 (svn:eol-style) 和 mime 类型 (svn:mime-type) 还有其他属性。

回答by aib

There's no native way to store file permissions in SVN.

没有在 SVN 中存储文件权限的本机方法。

Both asvnand the patchfrom that blog post seem to be up (and hosted on the official SVN repository), and that's a good thing, but I don't think they will have such metadata handling in the core version any time soon.

无论asvn补丁从博客文章似乎是向上(与官方SVN仓库托管),这是一个很好的事情,但我不认为他们会有任何时间很快在核心版本处理这种元数据。

SVN has had the ability to handle symbolic linksand executablesspecially for a long while, but neither work properly on Win32. I wouldn't hold my breath for another such non-portable feature (though it wouldn't be too hard to implement on top of the already existing metadata system.)

SVN 已经能够专门处理符号链接可执行文件很长时间了,但它们都不能在 Win32 上正常工作。我不会为另一个这样的不可移植的功能屏住呼吸(尽管在已经存在的元数据系统之上实现它不会太难。)

I would consider writing a shell script to manually adjust file permissions, then putting it in the repository.

我会考虑编写一个 shell 脚本来手动调整文件权限,然后将其放入存储库中。

回答by fyrye

Since this wasn't fully said in previous responses yet. I hate to resurrect zombied threads though.

因为在之前的回复中还没有完全说明这一点。我讨厌复活僵尸线程。

Since adding permission support for SVN would have to accommodate multiple OS's and permission types, NFS, POSIX, ARWED, and RACF

由于为 SVN 添加权限支持必须适应多种操作系统和权限类型,因此 NFS、POSIX、ARWED 和 RACF

This would make SVN bloated, possibly clash with conflicting permission types like NFS and POSIX, or open up possible exploits/security vulnerabilities.

这会使 SVN 变得臃肿,可能与 NFS 和 POSIX 等冲突的权限类型发生冲突,或者打开可能的漏洞利用/安全漏洞。

There are a couple of workarounds. pre-commit, post-commit, start-commit are the more commonly used, and are a part of the Subversion system. But will allow you to control the permissions with what ever programming language you like.

有几种解决方法。pre-commit、post-commit、start-commit是比较常用的,是Subversion系统的一部分。但是将允许您使用您喜欢的任何编程语言来控制权限。

The system I implemented is what I call a packager, that validates the committed files of the working copy, then parses a metadata file, which lists out the default permissions desired for files/folders, and any changes to them you also desire.

我实现的系统就是我所说的打包程序,它验证工作副本的提交文件,然后解析元数据文件,其中列出了文件/文件夹所需的默认权限,以及您希望对它们进行的任何更改。

Owner, Group, Folders, Files
default: <user> www-user 750 640
/path/to/file: <user> non-www 770 770
/path/to/file2: <user> <user> 700 700

You can also expand upon this and allow things such as automated moving, renaming them, tagging revision by types, like alpha, beta, release candidate, release

您还可以对此进行扩展,并允许诸如自动移动、重命名、按类型标记修订等内容,例如 alpha、beta、发布候选、发布

As far as supporting clients to checkout your repository files with permissions attached to them. You are better off looking into creating an installer of your package and offering that as a resource.

至于支持客户签出您的存储库文件并附加权限。您最好考虑创建软件包的安装程序并将其作为资源提供。

Imagine people setting their repositories with an executable in it set with permissions of root:www-user 4777

想象一下,人们使用 root:www-user 4777 权限设置其中的可执行文件来设置他们的存储库

回答by manifest

Many answers have stated that svn does not store file permissions. This may be true, but I was able to solve a dll file without execute permissions problem simply by these steps:

许多答案都表示 svn 不存储文件权限。这可能是真的,但我能够通过以下步骤解决一个没有执行权限问题的 dll 文件:

  1. chmod 755 badpermission.dll
  2. mv badpermission.dll ../
  3. svn update
  4. svn rm badpermission.dll
  5. svn commit badpermission.dll -m "Remove dll to fix permissions"
  6. mv ../badpermission.dll .
  7. svn add badpermission.dll
  8. svn commit badpermission.dll -m "Add the dll back to fix permissions"
  9. rm badpermission.dll
  10. svn update
  11. badpermission.dll comes back with execute permissions
  1. chmod 755 badpermission.dll
  2. mv badpermission.dll ../
  3. SVN 更新
  4. svn rm badpermission.dll
  5. svn commit badpermission.dll -m "删除 dll 以修复权限"
  6. mv ../badpermission.dll 。
  7. svn 添加 badpermission.dll
  8. svn commit badpermission.dll -m "添加 dll 以修复权限"
  9. rm错误权限.dll
  10. SVN 更新
  11. badpermission.dll 返回执行权限

回答by billywhizz

Thisis the updated link for SVN patch which handles unix style file permissions correctly. I have tested out on fedora12 and seems to work as expected:

是正确处理 unix 样式文件权限的 SVN 补丁的更新链接。我已经在 fedora12 上进行了测试,似乎按预期工作:

I just saved it /usr/bin/asvn and use asvn instead of svn command if i need permissions handled correctly.

如果我需要正确处理权限,我只是将它保存在 /usr/bin/asvn 并使用 asvn 而不是 svn 命令。

回答by Alexander Zhuravlev

I would recommend to generate permissions map using mtree utility (FreeBSD has it by default), store the map in the repository, and, as was mentioned above, run a script that would restore proper file permissions from the map as the first step of the build process.

我建议使用 mtree 实用程序生成权限映射(FreeBSD 默认有它),将映射存储在存储库中,并且如上所述,运行一个脚本来从映射中恢复正确的文件权限作为第一步构建过程。

回答by aib

@morechilli:

@morechilli:

The asvn wrapper from my earlier post and the blog in the OP's post seems to do what you're suggesting. Though it stores the permissions in the corresponding files' repository properties as opposed to a single external file.

我之前的帖子和 OP 帖子中的博客中的 asvn 包装器似乎按照您的建议行事。尽管它将权限存储在相应文件的存储库属性中,而不是单个外部文件中。

回答by graham.reeds

Locking would not solve this problem. Locking stops others from editing the file. This is a third party application which gets run as part of the build process that tries to write to a file - changing it - which breaks the build process. Therefore we need to stop the program from changing the file which is simply marking the file read-only. We would like that information to be held in the repository and carried across checkins, branches, etc.

锁定并不能解决这个问题。锁定会阻止其他人编辑文件。这是一个第三方应用程序,它作为构建过程的一部分运行,尝试写入文件 - 更改它 - 这会破坏构建过程。因此,我们需要阻止程序更改文件,这只是将文件标记为只读。我们希望将这些信息保存在存储库中,并在签入、分支等之间传递。

回答by Garth Kidd

Graham, svndoesn't store permissions. Your only option is to wrap your call to svnin a script. The script should call svnwith its arguments, then set the permissions afterward. Depending on your environment, you might need to call your script svnand tweak your PATHto ensure it gets called.

Graham,svn不存储权限。您唯一的选择是将您的呼叫包装svn在脚本中。脚本应svn使用其参数调用,然后设置权限。根据您的环境,您可能需要调用您的脚本svn并调整您的脚本PATH以确保它被调用。

I quite like morechilli's idea to have the list of files and permissions checked into the repository itself.

我非常喜欢 morechilli 的想法,即将文件列表和权限检入存储库本身。