Monday, 19 August 2013

Git post-receive group permissions approach

Git post-receive group permissions approach

I am trying to get a post-receive hook working from a Git repository
running on a VPS (CentOS 5.9). I have read through many threads but
nothing quite resolves my issue.
The repo and post-receive hook was created by a user assigned to a
dedicated 'developers' group. The set up command was:
git init --bare --shared=group
When I git push locally via ssh, the post-receive hook needs to update
files in both the root and public_html directories. At the moment, it
fails thus:
error: unable to unlink old 'filename.php' (Permission denied)
error: unable to unlink old 'another_filename.php' (Permission denied)
I'm assuming it's a group write permissions issue - as in my 'developers'
group doesn't have permission to write files to the root and public_html
directories. Having tinkered for hours with responses from other threads
nothing has worked. What I'm really looking for is a best-practice
suggestion not just a one off command. EG: One thread suggested running
sudo chmod -R g+w * but that just broke our php website.
My Question Then: What approach should I use to allow the post-receive
hook to write to root?
do I change ownership of all root files/directories to the developer user
and group that owns the git repo eg: chown -R developers * or something?
or should the developer group user that created the repo/hook be relocated
to some master group that the root user belongs too (wheel seems to be the
only default group on my vps)?
or am I barking entirely up the wrong tree?
Thanks in advance

No comments:

Post a Comment