Automatically set user permissions on new git repos?

Hello, everyone!
We have the problem that newly created git-repositories do not have the correct user permissions. When we create a new repositiory and try to push the first commit, we get an error like this:

 git push                                       
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 455 bytes | 455.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
remote: error: insufficient permission for adding an object to repository database ./objects
remote: fatal: failed to write object
error: remote unpack failed: unpack-objects abnormal exit
To https://phab.our-domain.local/diffusion/TEST/test.git
 ! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'https://phab.our-domain.local/diffusion/TEST/test.git'
zsh: exit 1 

If we change the permissions like this

sudo chown phab:www-data /var/repo/ -R &&  sudo chmod g+sw /var/repo/ -R

everything works fine. But we do not want to do this everytime someone of the team creates a new git repository. Is there a way that the permissions are set correctly automatilcally?

I already found the follwing:

  • a similar problem here, which was solved by an update of phabricator on feburary 22nd (but we updated phabricator last on September 1st.)
  • a bug here, which is not fixed
  • the idea to solve this with a git Hook

Does anyone know hot to configure pabricator correctly, so the problem above does not occur?
Any help is appreciated!
Thanks in advance!

I suspect that the issue is configuring phd.user in phabricator, so that the webserver knows to sudo to the right thing (and configuring /etc/sudoers correctly) - see https://secure.phabricator.com/book/phabricator/article/diffusion_hosting/#configuring-phabricator
There should be more information in the webserver’s error logs.

1 Like

Yes, that was it! Our www-user did not have sudo rights for the git binary.

I just followed the instructions, given in your link and that solved the issue.

Thanks!