Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 02-07-2008, 05:02 PM   #1
LQ Newbie
Registered: Jul 2007
Posts: 17

Rep: Reputation: 0
Subversion Post-Commit hook script... will not run

After the better part of two days of trying various permutation and combinations to get our SVN repository to update a local copy on the same server when a user commits I can get no further than running the script from the command line successfully. The script does not appear to execute when a user on another system runs a commit. There are hundreds of tutorials outlining a process to get this working and I've tried around five with no success. Here is the process I'm using at present ("usera" is the user who checked out the local copy of the repository which I want post-commit to update.

$ cd /path/to/repository/hooks
$ emacs post-commit.c

Contents of post-commit.c:
#define PATH_TO_POST_COMMIT_SCRIPT "/path/to/repository/hooks/post-commit.script
#include <sys/types.h>
#include <unistd.h>
main( ac, av ) char **av;
Save file:

$ chown usera:usera
$ gcc -o post-commit post-commit.c
$ chmod 4755 post-commit

$ emacs post-commit.script
Contents of post-commit.c:
#! /bin/sh
/bin/echo 'Testing to see if script is executed' > debug.txt
Save file:

$ chown apache:apache post-commit.script

So, ownership and permissions of files so far...
-rwsr-xr-x 1 usera usera 6758 Feb 8 10:17 post-commit
-rw-r--r-- 1 root root 204 Feb 8 10:16 post-commit.c
-rwxr-xr-x 1 apache apache 2531 Feb 8 09:58 post-commit.script

C wrapper runs successfully from command shell as user 'usera'

[usera]$ ./post-commit
[usera]$ cat debug.txt
Testing to see if script is executed
[usera]$ echo '' > debug.txt

But no post-commit process appears to run when a user on the network commits (i.e. debug.txt does not contain the test string). I've defined absolute paths to all files, executables referenced in both the C binary and the script but to no avail.

The checked out repository itself was done clean at the start of this process, all files owned by "usera". As far as I can tell (there are gaps in just about every tutorial I could find) I've set permissions/UIDs etc. correctly.

Can anyone point out where things might be going wrong?
Old 02-09-2008, 10:30 AM   #2
Registered: Jan 2008
Distribution: RHEL, CentOS, Ubuntu
Posts: 379

Rep: Reputation: 38
What happens if you run the script with an empty environment.
env - ./post-commit /var/lib/svn-repos 1234
Old 02-10-2008, 02:33 PM   #3
LQ Newbie
Registered: Jul 2007
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks for the suggestion, I did try that technique earlier in the debugging process to see whether all the paths were being resolved but couldn't determine anything conclusive. In the meantime, I have got things working. Difficult to say what the problem was because I only repeated steps I had tried several times before.

All I could think was that it is necessary to set the user/group on an executable before setting the setuid sticky-bit, i.e. setting it after setting the permissions mask does not work correctly.

The other important factor was changing the script declaration to bash and using the '-p' flag (to force POSIX compliance?) and make the script inherit the permissions of the owner of the process running it - which by default BASH doesn't appear to do.

The owner of script called by the C-wrapper doesn't seem to matter so long as it is executable by the owner of the C-wrapper.

Seems like a very fickle train of actions are required to get things working but got there in the end.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
subversion post-commit twantrd Linux - Software 0 02-13-2007 03:37 PM
subversion post-commit hook problems pajamabama Linux - Server 2 01-19-2007 06:14 PM
subversion commit failures irfanhab Linux - Software 0 06-05-2006 10:43 PM
subversion: commit failed kenneho Linux - Software 0 09-07-2005 02:02 PM
Subversion -> commit? hylke Linux - Newbie 1 05-15-2005 09:44 AM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:01 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration