1

I want to fire "svn update" command from a php script , the user for which is "apache". How can I assign permissions to apache user to execute "svn update" ?

4

I would create a command in the sudoers file, and then use sudo -u user-who-owns-svn-repo svn update in your PHP script.

The changes to /etc/sudores would be similar to:

Cmnd_Alias      SVN = /usr/local/bin/svn
apache          ALL=(ALL,!root,!#0) NOPASSWD: SVN

See the Sudoers manual for more info.

If you want tighter controls, make shell scripts that have the specific SVN commands and only allow Apache access to those. For example:

File /path/to/my/project/update.sh:

#!/bin/bash
svn update /path/to/my/project/svn-files

File /etc/sudores:

Cmnd_Alias      SVN = /path/to/my/project/update.sh
apache          ALL=(ALL,!root,!#0) NOPASSWD: SVN

(and don't forget to chmod +x path/to/my/project/update.sh)

  • Hi Josh, hope you are still around, thanks so much, this saved my day (week really!). – mario Apr 18 at 8:28
  • I am still around and pleased that my answer helped you @mario! – Josh Apr 19 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.