Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Dec 18, 2008 6:02 pm 
Offline
Junior Member

Joined: Tue May 20, 2008 3:00 am
Posts: 37
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


Code:
#!/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 :)[/code]


Top
   
 Post subject:
PostPosted: Fri Dec 19, 2008 2:42 pm 
Offline
Junior Member

Joined: Mon Nov 21, 2005 4:23 pm
Posts: 46
Does this FAQ help you out? http://subversion.tigris.org/faq.html#w ... uto-update

Looks like it could be a permissions issue.


Top
   
 Post subject:
PostPosted: Fri Dec 19, 2008 4:11 pm 
Offline
Junior Member

Joined: Tue May 20, 2008 3:00 am
Posts: 37
Tried to compile that program and ran it, just shows "At revision 103." which is correct.

Then did post-commit like this :

Code:
#!/bin/sh
webupdater


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


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


Top
   
 Post subject:
PostPosted: Fri Dec 19, 2008 4:44 pm 
Offline
Junior Member

Joined: Mon Nov 21, 2005 4:23 pm
Posts: 46
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.


Top
   
 Post subject:
PostPosted: Fri Dec 19, 2008 4:59 pm 
Offline
Junior Member

Joined: Tue May 20, 2008 3:00 am
Posts: 37
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.


Top
   
 Post subject:
PostPosted: Fri Dec 19, 2008 7:18 pm 
Offline
Junior Member

Joined: Mon Nov 21, 2005 4:23 pm
Posts: 46
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?


Top
   
 Post subject:
PostPosted: Fri Dec 19, 2008 7:24 pm 
Offline
Junior Member

Joined: Mon Nov 21, 2005 4:23 pm
Posts: 46
Navi wrote:
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.


Top
   
 Post subject:
PostPosted: Fri Dec 19, 2008 8:42 pm 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
GrunkaLunka wrote:
Navi wrote:
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" :-)

_________________
Rgds
Stephen
(Linux user since kernel version 0.11)


Top
   
 Post subject:
PostPosted: Fri Dec 19, 2008 10:00 pm 
Offline
Junior Member

Joined: Mon Nov 21, 2005 4:23 pm
Posts: 46
sweh wrote:
it runs with the effective userid of the user that owns the file


Very true. Thanks for the correction sir.


Top
   
 Post subject:
PostPosted: Sat Dec 20, 2008 5:24 am 
Offline
Junior Member

Joined: Tue May 20, 2008 3:00 am
Posts: 37
# su apache
This account is currently not available.

I'm running Fedora 10 btw :)

And ah kay, I see. Thanks :)


Top
   
 Post subject:
PostPosted: Sun Dec 21, 2008 2:38 am 
Offline
Junior Member

Joined: Mon Nov 21, 2005 4:23 pm
Posts: 46
What's the output of "ps aux | grep http"?


Top
   
 Post subject:
PostPosted: Sun Dec 21, 2008 5:14 am 
Offline
Junior Member

Joined: Tue May 20, 2008 3:00 am
Posts: 37
Code:
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


Top
   
 Post subject:
PostPosted: Mon Dec 22, 2008 2:25 am 
Offline
Junior Member

Joined: Mon Nov 21, 2005 4:23 pm
Posts: 46
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/'


Top
   
 Post subject:
PostPosted: Mon Dec 22, 2008 4:37 am 
Offline
Junior Member

Joined: Tue May 20, 2008 3:00 am
Posts: 37
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!


Top
   
 Post subject:
PostPosted: Mon Dec 22, 2008 12:33 pm 
Offline
Junior Member

Joined: Mon Nov 21, 2005 4:23 pm
Posts: 46
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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group