<p>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.</p>

<p>I looked on google and found a <a href="http://mamchenkov.net/wordpress/2005/04/27/subversion-and-file-permissions/" rel="noreferrer">blog post from 2005</a> 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.)</p>

[{'answer_id': 56158, 'author': 'Sören Kuklau', 'author_id': 1600, 'author_profile': 'https://Stackoverflow.com/users/1600', 'pm_score': -1, 'selected': False, 'text': '<p>Consider using <a href="http://svnbook.red-bean.com/nightly/en/svn.advanced.locking.html" rel="nofollow noreferrer"><code>svn lock</code></a> to disallow others from writing to the file.</p>\n'}, {'answer_id': 56193, 'author': 'graham.reeds', 'author_id': 342, 'author_profile': 'https://Stackoverflow.com/users/342', 'pm_score': 0, 'selected': False, 'text': '<p>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.</p>\n'}, {'answer_id': 56212, 'author': 'morechilli', 'author_id': 5427, 'author_profile': 'https://Stackoverflow.com/users/5427', 'pm_score': 5, 'selected': True, 'text': '<p>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.</p>\n\n<p>This script runs through your copy of the codebase and sets read permissions on certain files.</p>\n\n<p>Ideally the script would read the list of files from a simple input file.\nThis would make it easy to maintain and easy for other developers to understand which files get marked as read-only.</p>\n'}, {'answer_id': 56217, 'author': 'Garth Kidd', 'author_id': 5700, 'author_profile': 'https://Stackoverflow.com/users/5700', 'pm_score': 0, 'selected': False, 'text': "<p>Graham, <code>svn</code> doesn't store permissions. Your only option is to wrap your call to <code>svn</code> in a script. The script should call <code>svn</code> with its arguments, then set the permissions afterward. Depending on your environment, you might need to call your script <code>svn</code> and tweak your <code>PATH</code> to ensure it gets called. </p>\n\n<p>I quite like morechilli's idea to have the list of files and permissions checked into the repository itself.</p>\n"}, {'answer_id': 56277, 'author': 'graham.reeds', 'author_id': 342, 'author_profile': 'https://Stackoverflow.com/users/342', 'pm_score': 0, 'selected': False, 'text': '<p>We created a batch file to do this for us. Would prefer actual support in subversion though...</p>\n'}, {'answer_id': 56295, 'author': 'aib', 'author_id': 1088, 'author_profile': 'https://Stackoverflow.com/users/1088', 'pm_score': 4, 'selected': False, 'text': '<p>There\'s no native way to store file permissions in SVN.</p>\n\n<p>Both <a href="http://svn.apache.org/repos/asf/subversion/trunk/contrib/client-side/asvn" rel="noreferrer">asvn</a> and <a href="http://svn.collab.net/repos/svn/branches/meta-data-versioning/" rel="noreferrer">the patch</a> 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.</p>\n\n<p>SVN has had the ability to handle <a href="http://svnbook.red-bean.com/en/1.4/svn.tour.cycle.html#svn.tour.cycle.edit" rel="noreferrer">symbolic links</a> and <a href="http://svnbook.red-bean.com/en/1.4/svn.advanced.props.file-portability.html#svn.advanced.props.special.executable" rel="noreferrer">executables</a> 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.)</p>\n\n<p>I would consider writing a shell script to manually adjust file permissions, then putting it in the repository.</p>\n'}, {'answer_id': 56297, 'author': 'Richard Tasker', 'author_id': 2939, 'author_profile': 'https://Stackoverflow.com/users/2939', 'pm_score': 5, 'selected': False, 'text': '<p>SVN does have the capability of storing metadata (<a href="http://svnbook.red-bean.com/en/1.0/ch07s02.html" rel="noreferrer">properties</a>) 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).</p>\n\n<p>There are other properties for line ending (svn:eol-style) and mime type(svn:mime-type).</p>\n'}, {'answer_id': 56308, 'author': 'aib', 'author_id': 1088, 'author_profile': 'https://Stackoverflow.com/users/1088', 'pm_score': 1, 'selected': False, 'text': "<p>@morechilli:</p>\n\n<p>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.</p>\n"}, {'answer_id': 3019795, 'author': 'billywhizz', 'author_id': 237301, 'author_profile': 'https://Stackoverflow.com/users/237301', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://svn.apache.org/repos/asf/subversion/trunk/contrib/client-side/asvn" rel="nofollow noreferrer">This</a> is 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:</p>\n\n<p>I just saved it /usr/bin/asvn and use asvn instead of svn command if i need permissions handled correctly.</p>\n'}, {'answer_id': 3272832, 'author': 'Alexander Zhuravlev', 'author_id': 114931, 'author_profile': 'https://Stackoverflow.com/users/114931', 'pm_score': 1, 'selected': False, 'text': '<p>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.</p>\n'}, {'answer_id': 8214126, 'author': 'manifest', 'author_id': 236554, 'author_profile': 'https://Stackoverflow.com/users/236554', 'pm_score': 2, 'selected': False, 'text': '<p>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:</p>\n\n<ol>\n<li>chmod 755 badpermission.dll</li>\n<li>mv badpermission.dll ../</li>\n<li>svn update</li>\n<li>svn rm badpermission.dll</li>\n<li>svn commit badpermission.dll -m "Remove dll to fix permissions"</li>\n<li>mv ../badpermission.dll .</li>\n<li>svn add badpermission.dll</li>\n<li>svn commit badpermission.dll -m "Add the dll back to fix permissions"</li>\n<li>rm badpermission.dll</li>\n<li>svn update </li>\n<li>badpermission.dll comes back with execute permissions</li>\n</ol>\n'}, {'answer_id': 9424852, 'author': 'Will B.', 'author_id': 1144627, 'author_profile': 'https://Stackoverflow.com/users/1144627', 'pm_score': 2, 'selected': False, 'text': "<p>Since this wasn't fully said in previous responses yet. I hate to resurrect zombied threads though.</p>\n\n<p>Since adding permission support for SVN would have to accommodate multiple OS's and permission types, NFS, POSIX, ARWED, and RACF</p>\n\n<p>This would make SVN bloated, possibly clash with conflicting permission types like NFS and POSIX, or open up possible exploits/security vulnerabilities.</p>\n\n<p>There are a couple of workarounds.\npre-commit, post-commit, start-commit are the more commonly used, and are a part of the Subversion system.\nBut will allow you to control the permissions with what ever programming language you like.</p>\n\n<p>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.</p>\n\n<pre><code>Owner, Group, Folders, Files\ndefault: &lt;user&gt; www-user 750 640\n/path/to/file: &lt;user&gt; non-www 770 770\n/path/to/file2: &lt;user&gt; &lt;user&gt; 700 700\n</code></pre>\n\n<p>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</p>\n\n<p>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.</p>\n\n<p>Imagine people setting their repositories with an executable in it set with permissions of root:www-user 4777</p>\n"}]
['https://Stackoverflow.com/questions/56149', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/342/']