views:

552

answers:

2

I have a personal wiki that I take notes on. The wiki's pages are in a subversion working copy directory, "pages", and I set their permissions to 664, owned by www-data:www-data. My username is in the "www-data" group, so I can checkin and mess with the pages manually.

For a while, I had an issue because every time I ran a checkin, the files would be owned by me:www-data instead of www-data:www-data, and I would no longer be able to change the wiki files through my web interface! I solved the issue by flipping the setgid bit on the "pages" directory, but I'm still confused as to why this happened in the first place:

Every time I check something into subversion, it appears as if svn deletes it and recreates it. Why? Does this behavior support some functionality that I'm not aware of? Is there a way to change it?

Thanks!

+2  A: 

I think you are using it wrong. What you could do is still have everything in subversion and have your local working copy separate from the www directory which you develop on.

Then just have the www working-copy auto-updated (or exported if you don't want the .svn directories in the www foldeR) for the www-user by some script (perhaps as a post-commit hook) which then setups permissions accordingly.

Work flow would be:

  1. edit files in /home/youruser/yourwiki-working-copy/
  2. do svn commit
    • post-commit hook updates the files in /var/www/ (or wherever the wiki is located)
  3. goto 1.

This way, you don't have to worry about permissions and you can even have more than one person work on the web site with all the benefits of version control.

Isak Savo
Isak, this would work, but the problem here is that my working copy IS my /var/www! When I access files through http://localhost/wiki, it is viewing the files in /var/www and editing them, too.
Max
@Max: "Don't do it, if it hurts!" SVN is not designed for the style of usage you try to force unto it.
David Schmitt
@David: I don't think this is something subversion "wasn't designed" for... there's just a small discrepancy (solved by setting the sticky permissions bit) with permissions that I was curious about.
Max
+3  A: 

Set the "sticky" permissions bit.

find -type d -exec chgrp www-data {} + 
find -type d -exec chmod g+s {} +

this will encourage checkout's file creation phase to inherit the directories permissions instead of switching to the person whom last edited it.

Edit: dow +s == setgid. Information left here for posterity and other readers.

Kent Fredric