# [SOLVED] SVN hooks won't run

## G F0rce 1

Hey everyone,

Yesterday I setup an SVN server, there is only one problem remaining and that is the fact that it won't run the hooks that are specified, or in fact one hook.

I have put the following script named post-commit in the /var/svn/repos/hooks directory:

```

cd /var/www/localhost/htdocs/projects/;

svn checkout http://localhost/svn/repos --username myuser --password mypass

```

With the following rights:

 *Quote:*   

> 
> 
> -rwxrwxrwx 1 apache apache  117 Oct 11 22:40 post-commit
> 
> 

 

And I also gave the apache user rights to /var/www/localhost/htdocs/projects:

 *Quote:*   

> 
> 
> drwxrwxrwx  2 apache apache 4096 Oct 12 09:13 projects
> 
> 

 

I run the SVN server via apache / WEBDAV so logically it is the apache user that needs the correct rights right? When I run the script as my daily user it runs just fine. What am I doing wrong here?

Thanks for the help!

----------

## G F0rce 1

Even when I change the script to something like this:

```

echo "test" >> /tmp/testfileforcommithook.txt

```

or

```

echo "test" >> ~/testfileforcommithook.txt

```

it doesn't seem to run... can it be that running hooks is disabled in the SVN server?

----------

## tarpman

Commit hooks are run as the svn user, so make sure that user has write access to the checkout location or use sudo(8) in the script.

----------

## G F0rce 1

 *tarpman wrote:*   

> Commit hooks are run as the svn user, so make sure that user has write access to the checkout location or use sudo(8) in the script.

 

The problem is that my system has nu svn user, should I add it? I run svn via the apache DAV mod...

----------

## tarpman

Whoever the svnserve(8) process is running as, then.  Sorry, I've never used Subversion with Apache, so I don't quite know how it works.

Another thought: hooks are run with an empty environment (even PATH), so make sure any commands you are running are specified with their full path (/usr/bin/svn instead of svn).  Also, remember to make sure your hook script is executable and begins with an appropriate shebang (e.g. #!/bin/sh).

----------

## G F0rce 1

 *tarpman wrote:*   

> Whoever the svnserve(8) process is running as, then.  Sorry, I've never used Subversion with Apache, so I don't quite know how it works.

 

Okay well then it would be the apache users so it looks like the rights are not causing the problem.

----------

## Hu

Those permissions are far too open.  It should be mode 555 or even 550.  Please show us the entirety of the test script.

----------

## tarpman

You need something along the lines of #!/bin/sh at the top of the script so it gets executed as a script, and remember that the user it will be running as needs access to all of the contents of the checkout location, particularly the .svn/ directories, not just the location itself.

----------

## G F0rce 1

 *Hu wrote:*   

> Those permissions are far too open.  It should be mode 555 or even 550.  Please show us the entirety of the test script.

 

I am aware of the fact that those permissions are not correct, but I was getting desperate and wanted to make sure that the permissions were not the problem, of course I will change them back when everything works correctly!

This is my whole script:

```

#!/bin/sh

cd /var/www/localhost/htdocs/projects/;

svn checkout http://localhost/svn/funkology --username user --password pass;

```

Nothing else to it...

----------

## G F0rce 1

And at this very moment it seems to work correctly. The only thing I did was add the first line to the script. 

```

#!/bin/sh 

```

I did not know that was necessary. Unbelievable, thank you everyone!

----------

## Hu

 *G F0rce 1 wrote:*   

>  *Hu wrote:*   Those permissions are far too open.  It should be mode 555 or even 550.  Please show us the entirety of the test script. 
> 
> I am aware of the fact that those permissions are not correct, but I was getting desperate and wanted to make sure that the permissions were not the problem, of course I will change them back when everything works correctly!

 

I understand.  However, some programs, most notably tools from the net-misc/openssh package, will check file permissions and actively refuse to use files which have insecure permissions.  Thus, opening up permissions may make things worse.

----------

## G F0rce 1

 *Hu wrote:*   

>  *G F0rce 1 wrote:*    *Hu wrote:*   Those permissions are far too open.  It should be mode 555 or even 550.  Please show us the entirety of the test script. 
> 
> I am aware of the fact that those permissions are not correct, but I was getting desperate and wanted to make sure that the permissions were not the problem, of course I will change them back when everything works correctly! 
> 
> I understand.  However, some programs, most notably tools from the net-misc/openssh package, will check file permissions and actively refuse to use files which have insecure permissions.  Thus, opening up permissions may make things worse.

 

Okay I really wasn't aware, thanks for the info!

----------

