Search code examples
linuxsvnunixpermissionspost-commit

svn post-commit hook doesn't have permissions to create file in working copy directory


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?


Solution

  • 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.