2012-06-26 98 views
1

剛剛在我的網絡服務器上安裝了gitolite,我試圖獲得一個post-receive鉤子,它可以指向git dir的apache方向。post-receive hook權限被拒絕「無法創建文件」錯誤

這就是我的post-receive掛鉤的樣子。從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。這些是來自我的存儲庫中的文件。

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 

更新:

[email protected]:~$ 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 
[email protected]:~$ /usr/local/sbin/prgetsimpleappscom 
-su: /usr/local/sbin/prgetsimpleappscom: Permission denied 
[email protected]:~$ 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) 
[email protected]:~$ 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. 
[email protected]:~$ sudo /usr/local/sbin/prgetsimpleappscom 
[sudo] password for git: 
sudo: /usr/local/sbin/prgetsimpleappscom: command not found 
[email protected]:~$ nano /usr/local/sbin/prgetsimpleappscom 
[email protected]:~$ 
+0

請問您的'git-daemon'(或者'gitolite'服務於相同目的的任何內容)運行的userid是否具有'/ srv/sites/example.com/public'中的寫入權限並且有權覆蓋可能已經存在的內容在那裏? – twalberg

+0

我感覺很傻。不,它是根源:根。我會嘗試運行一個'chown git:git public /'? – ThomasReggi

+0

哇,它的工作=/ – ThomasReggi

回答

1

這是我如何得到它的工作:

改變post-receive到:

sudo sh /usr/local/sbin/prgetsimpleappscom 

改變sudoersvisudo

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工作

[email protected]:~$ 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 
相關問題