Updating SVN via a web form on a computer running Windows and Linux

I have been working on this for a while, and I cannot find a solution (if any).

So the question is: Is there a way to make an svn update request through an HTML web form?

I tested several web SVN clients (including creating my own), but all of them do not have the ability to update.

I understand that this is a problem with the user rights that PHP uses, but even if I installed all the files on my system on 777 (I tried it on a virtual machine), I still can’t archive it.

Does anyone have any experience?

Thanks already.

I also looked through all the directories and set the owner to Everyone with full access. Now the problem with resolution cannot be ... I think.

Last edit: It seems I can not execute SVN if the script file is not in the root directory of the svn directory. The final code now looks like this: http://codepad.org/Kb2K8e6m

+4
source share
3 answers

The next function should more or less do this for you. It also prints out:

  • Exact shell command
  • The output of the command (including errors) so that it can be debugged.

 function updatesvn() { if ( isset($_POST) ) { //Get svn username and password from request parameters $username = <your_svn_username>; $password = <your_svn_password>; //Get version number to move to $values = $_POST; $version = $values['revision']; //validate version number //Path where you have checked out your project $rpath = '/var/www/myproj'; //Command to svn update $cmd = "cd $rpath; svn cleanup; svn --non-interactive --username $username --password $password update -r $version 2>&1"; echo $cmd; $out = shell_exec($cmd); echo $out; } } 

EDIT: Beware of the security loopholes in this code. I simplified it here. We used it in one of our applications, where the user who reached this point was pre-authenticated as the Admin user of the web application. In addition, this code was executed in the MVC environment, where input checks were performed in central places before the action was taken in the controller.

+4
source

You can just use svn_update () from the PECL svn extension (or exec and svn command line - there really isn’t much difference).

The solution that I prefer for permission problems is to install umask 002 for all users who will update (including www-data or regardless of your web server user), put them in a common phpuser group, set this group for the working root copies ( chgrp phpuser <rootdir> - before checking!), make sure it is writable in the group ( chmod g+rwx <rootdir> ) and set it to setgid ( chmod g+s <rootdir> ), but if you don’t take care of saving the permissions file, then of course chmod -R 777 <rootdir> much easier.

+1
source

Are you building a continuous integration server? Why do you want any Joe Bloggs to update your local repository?

You will need to have the code on the back to complete the “svn update” in the shell.

Typically, the SVN web client will be directly loaded into the SVN repository and should be updated by default - it should even allow you to view previous versions and differences.

0
source

All Articles