4

I'm trying to evaluate git for our team and one of the requirements is to use HTTPS as the transport method. I've been trying to follow the git-http-backend documentation as well as some sparse blogs on setting this up using the new Smart HTTP transport, but am just not getting it working. I know that it's probably something stupid, but I've racked my brain over it to no avail. Don't assume any real knowledge with git, I'm pretty new to the tool.


Right now I can clone over HTTP just fine, but when I try and push, the client gets:

$ git push
Username:
Password:
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 291 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
error: unpack failed: unpack-objects abnormal exit


The server Apache error log says:

error: insufficient permission for adding an object to repository database ./objects

fatal: failed to write object


Apache config:

SetEnv GIT_PROJECT_ROOT /opt/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/

<Location /git>
        AuthType Basic
        AuthName "Private Git Access"
        Require valid-user
        AuthUserFile /opt/git/passwords
</Location>


Obviously my first thought was file permissions, so I did a quick chown -R apache: /opt/git

# ls -l /opt/git
drwxr-xr-x. 7 apache apache 4096 Aug 12 11:06 project.git

But I still get the same error.

Thanks, I very much appreciate any help I can get on this.

Mat
  • 202,337
  • 40
  • 393
  • 406
bfos
  • 363
  • 2
  • 9

2 Answers2

1

The solution is probably in the group permissions of the repository on the server.

  1. cd to /opt/git
  2. sudo chgrp -R apache project.git

I thing apache usually runs as www-data, not apache, so the group may be wrong also

I use gitosis and manage accounts through server accounts instead of Apache, but solved my same problem with this kind of solution

Bruce Chidester
  • 621
  • 1
  • 5
  • 16
  • I keep on thinking it must be something along those lines, but it just doesn't seem to want to work. This distro I'm using (CentOS) is running as "apache". From the 'ls' in the post you can see the user and group are both "apache", but for safe measures I did an explicit recursive chgrp, but still same error. As a slight aside, setting this up using gitosis/gitolite will be the next step, hopefully plugging into our Atlassian Crowd SSO directory. – bfos Aug 12 '11 at 16:15
1

Try running:

git repo-config core.sharedRepository true

This had solved similar issue for me. From the docs:

core.sharedRepository

If true, the repository is made shareable between several users in a group (making sure all the files and objects are group-writable).

Can you verify the steps as given here ( this is definitely a permissions / groups issue):

http://parizek.com/?p=177

manojlds
  • 290,304
  • 63
  • 469
  • 417
  • Thanks, but unfortunately this doesn't seem to fix this error. # git repo-config core.sharedRepository true # cat config [core] repositoryformatversion = 0 filemode = true bare = true sharedRepository = true – bfos Aug 12 '11 at 16:09
  • I'm making the assumption here that this is happening on the server under the apache process user (apache). $ groups apache = "apache : apache". Ran all (3) commands in that post with apache as the group - same error. I went so far as to give everyone r/w permissions to the entire repo and STILL the same error! – bfos Aug 12 '11 at 16:42
  • 1
    Ugh. SELinux kicks my @ss again. Disabled that and everything worked beautifully. – bfos Aug 12 '11 at 17:06
  • @bfos - Ah, yeah, I should have remembered! – manojlds Aug 12 '11 at 17:12