Storing file permissions in Subversion repository

2019-01-09 11:36发布

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 2005 that 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.)

12条回答
聊天终结者
2楼-- · 2019-01-09 11:56

@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.

查看更多
【Aperson】
3楼-- · 2019-01-09 12:01

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

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

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.

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

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

查看更多
甜甜的少女心
4楼-- · 2019-01-09 12:07

We created a batch file to do this for us. Would prefer actual support in subversion though...

查看更多
聊天终结者
5楼-- · 2019-01-09 12:07

Consider using svn lock to disallow others from writing to the file.

查看更多
男人必须洒脱
6楼-- · 2019-01-09 12:09

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).

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

查看更多
兄弟一词,经得起流年.
7楼-- · 2019-01-09 12:09

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

Both asvn and the patch from 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.

SVN has had the ability to handle symbolic links and executables specially 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.)

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

查看更多
登录 后发表回答