Insufficient Permission Pushing to Git Shared Repo over Smart HTTP

三世轮回 提交于 2019-12-21 19:41:05

问题


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.


回答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




回答2:


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



来源:https://stackoverflow.com/questions/7042783/insufficient-permission-pushing-to-git-shared-repo-over-smart-http

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!