views:

957

answers:

3

I am stuck with that task.

I've written svn post-commit hook, that should update working copy on server, if something was changed. But seems to be it doesn't have permissions on that folder, but I've set them to allow everybody to write and read there.

So here is the test script:

#!/bin/sh
REPOS="$1"
REV="$2"

DIR="/root/root/trunk"

touch $DIR/worked

I've got the output:

Committed revision 51.

Warning: 'post-commit' hook failed with error output:
touch: cannot touch `/root/root/trunk/worked': Permission denied

And the permissions for target folder:

[root@ovz6022 trunk]# ls -la
total 24
drwxrwxrwx 5 apache apache 4096 Jul 26 07:08 .
drwxrwxrwx 6 apache apache 4096 Jul 24 02:14 ..
-rwxrwxrwx 1 apache apache 1367 Jul 24 02:45 pom.xml
drwxrwxrwx 4 apache apache 4096 Jul 24 02:23 src
drwxrwxrwx 6 apache apache 4096 Jul 24 13:31 .svn
drwxrwxrwx 7 apache apache 4096 Jul 24 11:18 target

Any ideas?

+1  A: 

I think your problem might be that the /root directory permissions override anybody but root from accessing anything beneath it.

On my pc /root has permissions rwx------ root:root which i believe means only executable running as root can access anything underneath.

However my home folder /home/rich has read access for anybody so if you tried

  1. mkdir -p /home/myuser/workingdir/trunk
  2. chmod -R 777 /home/myuser/workingdir
  3. chown -R myuser:apache /home/myuser/workingdir

then try the hook i think it'll work

You need to ask yourself why you want to checkout code in /root. You should alway be working as a user that has the minimum permissions necessary to get the job done. Except for installation you should be able to compile and edit your working copy without needing the highest level of permissions linux has to offer.

Ryu
Because it was created there. Does it make sense?
glaz666
Thanks, that works. Still don't get why it failed for root's subdirectories with all rights set
glaz666
If apache doesn't even have read access to /root, then how can it know that "/root/root/trunk/worked" exists, since finding out that directory exists would require reading it.
Ryu
'access denied' and 'not found' are different errors. You can 'read' directories if you have the x bit set.
gbjbaanb
A: 

try creating the worked directory, are you sure you need two /root/root for your WC path, and what command are you trying to run - create a very small, simple hook (eg just svn export or svn co) and try that - post us the script as well.

From the error, it looks like you're trying to update something that doesn't exist yet.

gbjbaanb
the script just executes: touch $DIR/worked. The same I call "touch ./worked" from the same script it will create worked file in /usr/local/svn/hooks. So that is ok with the command.
glaz666
A: 

Is worked a directory? Does touch work for directories? my linux powers are weak, but I thought it was just for creating/updating timestamps on files. If so that might be your problem.

Rich Seller
Thanks for fixing my posts :) That's very touchy'worked' is a file. If it is absent, system creates it, otherwise modifies timestamps
glaz666
That's a way I'm testing permissions to write in folder
glaz666