A
A
Anton Kucherov2013-06-10 17:12:06
git
Anton Kucherov, 2013-06-10 17:12:06

Confused about GIT permissions when executing a hook?

Such is the situation.
We have a repository on the server /var/www/git/repository/testdeploy.git
We have the following hook (post-update)

unset GIT_DIR
export GIT_WORK_TREE=/var/www/testdeploy
cd /var/www/testdeploy && git pull origin master

We have a /var/www/testdeploy directory where, let's say, a deployed project is located (in fact, just a working copy of the repository)
The rights are /var/www/testdeploy , /var/www/testdeploy/.git/
drwxrwxr-x  3 httpd httpd 4096 июня  10 22:08 testdeploy

git user added to httpd group
[email protected]:/var/www$ groups git
git : git httpd

I try to do git push origin master from the local machine. I get an
error:
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 309 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)

remote: error: cannot open .git/FETCH_HEAD: Permission denied

To http://git.initdev.lan/dexter/testdeploy.git
6817616..88d2fc2  master -> master

How is that? Why does git running from under the git user not see that he is inside the httpd group.
The rights of this file:
-rwxrwxr-x  1 httpd  httpd   105 июня  10 22:02 FETCH_HEAD

And an interesting feature, if I execute this hook from the console on a remote machine from under the “git” user, then the process will go fine.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Kucherov, 2013-06-10
@DexterHD

Under another user, I do it from my computer remotely. That's the problem I checked, it comes to the hook.
I checked it by simply writing echo “Something” in the hook file (post-update)
git updates the branch in the repository /var/www/git/repository/testdeploy.git and then executes the hook and falls out on the command
git pull origin master
If written by the owner git for the /var/www/testdeploy directory, then everything is OK. One gets the feeling that when executing the hook,
git does not understand that it is in the httpd group.

R
radarlog, 2013-06-10
@radarlog

if gitolite is used (judging by the paths, I guess), then you need to look at the $REPO_UMASK parameter in its config (should be 0022)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question