Apache & SVN on Ubuntu - Post-commit hook fails silently, pre-commit hook “Permission Denied”

Posted by 113169587962668775787 on Server Fault See other posts from Server Fault or by 113169587962668775787
Published on 2010-04-24T15:42:59Z Indexed on 2010/04/24 15:53 UTC
Read the original article Hit count: 594

Filed under:
|
|
|
|

I've been struggling for the past couple days to get post-commit email notifications working on my SVN server (running via HTTP with Apache2 on Ubuntu 9.10). SVN commits work fine, but for some reason the hooks are not being properly executed.

Here are the configuration settings: - Users access the repo via HTTP with the apache dav_svn module (I created users/passwords via htpasswd in a dav_svn.passwd file).

dav_svn.conf:

 <Location /svn/repos>
  DAV svn
  SVNPath /home/svn/repos

  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile /etc/apache2/dav_svn.passwd

  Require valid-user
  </Location>
  • I created a post-commit hook file that writes a simple message to a file in the repository root:

/home/svn/repos/hooks/post-commit:

#!/bin/sh

REPOS="$1"
REV="$2"

/bin/echo 'worked' > ${REPOS}/postcommit.log

I set the entire repository to be owned by www-data (the apache user), and assigned 755 permissions to the post-commit script

when I test the post-commit script using the www-data user in an empty environment, it works:

sudo -u www-data env - /home/svn/repos/hooks/post-commit /home/svn/repos 7

But when I commit on a client machine, the commit is successful, but the post-commit script does not seem to be executed.

I also tried running a simple script for the pre-commit hook, and I get an error, even with an empty pre-commit script:

"Commit failed (details follow): Can't create null stdout for hook '/home/svn/repos/hooks/pre-commit': Permission denied"

I did a few searches on Google for this error and I presume that this is an issue with the apache user (www-data) not having adequate permissions, specifically to execute /dev/null. I also read that the reason post-commit fails silently is because that it doesn't report with stdout.

Anyway, I've also tried giving the apache user (www-data) ownership of the entire repository, and edited the apache virtualhost to allow operations on the server root, and I'm still getting permission denied

/etc/apache2/sites-available/primarydomain.conf

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
</Directory>

Any ideas/suggestions would be greatly appreciated! Thanks

© Server Fault or respective owner

Related posts about svn

Related posts about post-commit