Using git post-receive hook with nginx and php-fpm environment

て烟熏妆下的殇ゞ 提交于 2019-12-04 17:13:49

You could use sudo to get the hook to run as user1, user2, user3, or whatever your system needs. You would need to consider the security implications of having the gitosis user able to masquerade as your web users, even if to a limited extent.

Example recipe

Given that the post-receive hook runs as user gitorious and assuming your web users are called user1, user2, user3 etc...

Move your current post-receive hook into /usr/local/sbin/update-user1.sh, or some other suitable place, and make sure it's executable.

Add something like these lines to /etc/sudoers:

gitosis    localhost = (user1) NOPASSWD: /usr/local/sbin/update-user1.sh
gitosis    localhost = (user2) NOPASSWD: /usr/local/sbin/update-user2.sh
gitosis    localhost = (user3) NOPASSWD: /usr/local/sbin/update-user3.sh
... etc ...

And then your post-receive hook for user1 could become something like:

#!/bin/sh
sudo -u user1 /usr/local/sbin/update-user1.sh

Similarly for other users.

Untested, so please test before implementing!

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