Subversion post-commit hooks, Error Merge of blah : 200 OK

I'm trying to get a php file with passthru("svn up"), or just a shell script with 'svn up /var/www' to run via a post-commit hook.. but I'm having problems. Been trying for about 2 hours by now lol.

The simple idea of

#!/bin/sh
svn up /var/www

Didn't work and various others neither. Now I'm running a small C program instead, also running fine from command line but not after I try to commit something.

I'm using Tortoise SVN and I'm getting :

Error : Commit Failed (details follow ) :

Error: MERGE of '/svn/web/test': 200 OK (https://domain)

While when I run an 'svn up' manually after, it just shows as committed as a new rev.

I've searched around on Google as well, but nothing seemed to solve the problem.. any idea what else I could try?

I only need 'svn up /var/www' to be ran after I commit something to my repo in /opt/svn/web/ Doesn't matter much in what way..

Thanks in advance :)

15 Replies

Does this FAQ help you out? http://subversion.tigris.org/faq.html#w … uto-update">http://subversion.tigris.org/faq.html#website-auto-update

Looks like it could be a permissions issue.

Tried to compile that program and ran it, just shows "At revision 103." which is correct.

Then did post-commit like this :

#!/bin/sh
webupdater
env - ./post-commit /opt/svn/web/

Gives the same output.

Then I tried adding a test file, did svn commit and same error again in TortoiseSVN. Tried locally this and received another error :

svn commit -m test
Sending        test.txt
Transmitting file data .
Committed revision 105.

Warning: 'post-commit' hook failed with error output:
svn: Working copy '/var/www' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)

After I do svn cleanup and commit again, same error over and over.. something I'm missing or?

Thanks btw, didn't expect the subversion faq to have a piece about versioning websites :)

Ummm. I gotta be honest with, you: I've never done anything like this, but I think it always helps to have someone to bounce ideas with. :)

Having said that, according to that SVN FAW, the post-commit is being run by the user that runs your apache/svnserve process. How do you access your repository? You mention TortoiseSVN, but what is the protocol? It's usually svn, http or svn+ssh.

Np, any help is welcome. And figured as much :)

I'm accessing it via https.

Clients : TortoiseSVN on my Windows box, just command line subversion client on the linode and the same on my Linux box.

And yeah, I made all the .svn folders accessible to all users.

And the chmod +s on the little updater program makes it run as root or something, I read somewhere.

OK, try this:

su to the user that usually runs the apache process. It's www-data on debian/ubuntu (?).

Execute the "env - ./post-commit /opt/svn/web/" command

What hapens then?

@Navi:

And the chmod +s on the little updater program makes it run as root or something, I read somewhere.

This isn't entirely accurate. That make the executable setuid. It will run with the permissions of the user that owns it. If root owns it then it will run as root, but if it's owned by someone else then it runs as that user.

@GrunkaLunka:

@Navi:

And the chmod +s on the little updater program makes it run as root or something, I read somewhere.

This isn't entirely accurate. That make the executable setuid. It will run with the permissions of the user that owns it. If root owns it then it will run as root, but if it's owned by someone else then it runs as that user.
To be entirely accurate, it runs with the effective userid of the user that owns the file. This is subtly different and normally means the same thing. But it's not quite the same.

See "man geteuid".

Yes, I am being pedantic, but… well, you did say "entirely accurate" :-)

@sweh:

it runs with the effective userid of the user that owns the file

Very true. Thanks for the correction sir.

# su apache

This account is currently not available.

I'm running Fedora 10 btw :)

And ah kay, I see. Thanks :)

What's the output of "ps aux | grep http"?

````
root 17126 0.1 4.9 88572 18136 ? Ss 04:12 0:00 /usr/sbin/httpd
apache 17128 0.0 1.8 88572 6860 ? S 04:12 0:00 /usr/sbin/httpd
apache 17129 0.0 1.8 88704 6956 ? S 04:12 0:00 /usr/sbin/httpd
apache 17130 0.0 2.9 89900 10788 ? S 04:12 0:00 /usr/sbin/httpd
apache 17131 0.0 2.0 88704 7568 ? S 04:12 0:00 /usr/sbin/httpd
apache 17132 0.0 2.4 89628 8908 ? S 04:12 0:00 /usr/sbin/httpd
apache 17133 0.0 1.8 88572 6864 ? S 04:12 0:00 /usr/sbin/httpd
apache 17134 0.0 1.6 88572 6016 ? S 04:12 0:00 /usr/sbin/httpd
apache 17135 0.0 1.6 88572 6012 ? S 04:12 0:00 /usr/sbin/httpd
root 17152 0.0 0.1 4124 700 pts/0 S+ 04:15 0:00 grep http

````

I think the reason why you are getting the error because the apache user doesn't have writing permissions to the files on /opt/svn/web, and that's what causing the errors.

What's the output of

su apache -c 'env - ./post-commit /opt/svn/web/'

Thanks so much!

I got it completely working now =D

I've chown apache.apache on /var/www to ensure I've had permissions. I've changed the shell of apache to enable me to run that command. I've changed permissions on /opt/svn/web to 777. Ran 'su apache -c 'webupdater' and it worked, then tried via an commit and it worked as well.

It's an awesome sight, again thanks alot for pointing me in the right direction!

Cool. Glad to hear it worked. Now that I think about it even more, I think only the first of those steps (chown) was necessary. You might want to try reverting the other two (chmod 777 and shell change) and and see if it still works. It would make your setup a little more secure.

Yeah I already reverted the shell change, figure it was a bit insecure.. still works so far.

Which permissions would you recommend on '/var/www' and '/opt/svn/web' ?

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct