本文介绍了接收后挂钩许可被拒绝为“无法创建文件".错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅在我的Web服务器上安装了gitolite,并试图获取一个post-receive钩子,该钩子可以将git dir指向apache的方向.

Just got gitolite installed on my webserver and am trying to get a post-receive hook that can point the git dir in apache's direction.

这是我的post-receive钩子的样子.从使用Git管理网站中获得该脚本.

This is what my post-receive hook looks like. Got this script from the Using Git to manage a web site.

#!/bin/sh
echo "post-receive example.com triggered"
GIT_WORK_TREE=/srv/sites/example.com/public git checkout -f

我也尝试过:

#!/bin/sh
echo "post-receive example.com triggered"
unset GIT_INDEX_FILE
export GIT_WORK_TREE=/srv/sites/example.com/public
export GIT_DIR=/home/git/repositories/example.com.git
git checkout -f

这是我从本地工作站从git push origin master返回的错误响应.这些是我存储库中的文件.

This is the error response i'm getting back from git push origin master from my local workstation. These are files from within my repository.

remote: post-receive example.com triggered
remote: error: unable to create file .htaccess (Permission denied)
remote: error: unable to create file .tm_sync.config (Permission denied)
remote: fatal: cannot create directory at 'application': Permission denied

独立脚本错误

remote: sudo: no tty present and no askpass program specified
remote: Sorry, try again.
remote: sudo: no tty present and no askpass program specified
remote: Sorry, try again.
remote: sudo: no tty present and no askpass program specified
remote: Sorry, try again.
remote: sudo: 3 incorrect password attempts

更新:

git@vannevar:~$ sudo -l
Matching Defaults entries for git on this host:
    env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User git may run the following commands on this host:
    (root) NOPASSWD: /usr/local/sbin/prgetsimpleappscom
git@vannevar:~$ /usr/local/sbin/prgetsimpleappscom
-su: /usr/local/sbin/prgetsimpleappscom: Permission denied
git@vannevar:~$ sh /usr/local/sbin/prgetsimpleappscom
post-receive getsimpleapps.com triggered
error: unable to unlink old 'application/config/development/database.php' (Permission denied)
error: unable to unlink old 'application/config/production/database.php' (Permission denied)
error: unable to unlink old 'application/config/quickbooks.php' (Permission denied)
git@vannevar:~$ sudo sh /usr/local/sbin/prgetsimpleappscom
[sudo] password for git:
Sorry, user git is not allowed to execute '/bin/sh /usr/local/sbin/prgetsimpleappscom' as root on vannevar.
git@vannevar:~$ sudo /usr/local/sbin/prgetsimpleappscom
[sudo] password for git:
sudo: /usr/local/sbin/prgetsimpleappscom: command not found
git@vannevar:~$ nano /usr/local/sbin/prgetsimpleappscom
git@vannevar:~$

推荐答案

这就是我的工作方式:

post-receive更改为:

sudo sh /usr/local/sbin/prgetsimpleappscom

已将sudoers更改为visudo

git ALL = (root) NOPASSWD: /usr/local/sbin/prgetsimpleappscom
git ALL = (root) NOPASSWD: /bin/sh
git ALL = (root) NOPASSWD: /bin/sh /usr/local/sbin/prgetsimpleappscom

确认visudo正常

git@vannevar:~$ sudo -l
Matching Defaults entries for git on this host:
    env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User git may run the following commands on this host:
    (root) NOPASSWD: /usr/local/sbin/prgetsimpleappscom
    (root) NOPASSWD: /bin/sh
    (root) NOPASSWD: /bin/sh /usr/local/sbin/prgetsimpleappscom

运行:

sudo sh /usr/local/sbin/prgetsimpleappscom
post-receive getsimpleapps.com triggered

和:

$ git push origin master
remote: post-receive getsimpleapps.com triggered

这篇关于接收后挂钩许可被拒绝为“无法创建文件".错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:38