LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Subversion Post-Commit hook script... will not run (https://www.linuxquestions.org/questions/linux-server-73/subversion-post-commit-hook-script-will-not-run-619431/)

mattp52 02-07-2008 04:02 PM

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:
Code:

#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;
{
  execv( PATH_TO_POST_COMMIT_SCRIPT, 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:
Code:

#! /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

Debugging
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?

frndrfoe 02-09-2008 09:30 AM

What happens if you run the script with an empty environment.
Code:

env - ./post-commit /var/lib/svn-repos 1234

mattp52 02-10-2008 01:33 PM

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.


All times are GMT -5. The time now is 04:15 AM.