problem in running svn command through php on CentOS

View: New views
7 Messages — Rating Filter:   Alert me  

problem in running svn command through php on CentOS

by pinky goyal-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

HI All!
 
i am having problem in running all the commands of svn.exe on CentOS through php's exec() function but i am able to run the svnlook commands by exec() function.
 
i am trying to execute svn list file:///PathToRepositoryDir
 
$cmd = "/usr/bin/svn" list file:////var/subversion/devfoundry/
 
i am able to run $cmd thorugh command line but not thorugh exec() function.
 
i have checked the permissions on the executables.svn exe has same permissions as svnlook exe.
 
it's very urgent and i am running out of time :(
Please if anyone can help me out to resolve the issue or have suggestion regarding this i will be greatful.
 
Cheers
Pinky.

Re: problem in running svn command through php on CentOS

by Ryan Schmidt-23 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Dec 20, 2007, at 07:26, pinky goyal wrote:

> i am having problem in running all the commands of svn.exe on  
> CentOS through php's exec() function but i am able to run the  
> svnlook commands by exec() function.
>
> i am trying to execute svn list file:///PathToRepositoryDir
>
> $cmd = "/usr/bin/svn" list file:////var/subversion/devfoundry/
>
> i am able to run $cmd thorugh command line but not thorugh exec()  
> function.
>
> i have checked the permissions on the executables.svn exe has same  
> permissions as svnlook exe.
>
> it's very urgent and i am running out of time :(
> Please if anyone can help me out to resolve the issue or have  
> suggestion regarding this i will be greatful.

Some error is probably occurring, so you should probably examine the  
stderr output. Here, I redirect stderr (stream 2) to the same place  
stdout is going (stream 1) so that we get the error into $output too.

<?php
$cmd = '/usr/bin/svn list file:///var/subversion/devfoundry/ 2>&1';
exec($cmd, $output);
$output = implode("\n", $output) . "\n";
echo $output;
?>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Parent Message unknown Re: problem in running svn command through php on CentOS

by Ryan Schmidt-23 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Please remember to Reply All so that your reply goes to the mailing  
list too, not just to me. My reply below.

On Dec 25, 2007, at 23:27, pinky goyal wrote:

> On 12/20/07, Ryan Schmidt wrote:
>
>> On Dec 20, 2007, at 07:26, pinky goyal wrote:
>>
>> > i am having problem in running all the commands of svn.exe on
>> > CentOS through php's exec() function but i am able to run the
>> > svnlook commands by exec() function.
>> >
>> > i am trying to execute svn list file:///PathToRepositoryDir
>> >
>> > $cmd = "/usr/bin/svn" list file:////var/subversion/devfoundry/
>> >
>> > i am able to run $cmd thorugh command line but not thorugh exec()
>> > function.
>> >
>> > i have checked the permissions on the executables.svn exe has same
>> > permissions as svnlook exe.
>> >
>> > it's very urgent and i am running out of time :(
>> > Please if anyone can help me out to resolve the issue or have
>> > suggestion regarding this i will be greatful.
>>
>> Some error is probably occurring, so you should probably examine the
>> stderr output. Here, I redirect stderr (stream 2) to the same place
>> stdout is going (stream 1) so that we get the error into $output too.
>>
>> <?php
>> $cmd = '/usr/bin/svn list file:///var/subversion/devfoundry/ 2>&1';
>> exec($cmd, $output);
>> $output = implode("\n", $output) . "\n";
>> echo $output;
>> ?>
>
> thnx for the reply.
>
> i have tried this and now what error i am getting is.
>
> svn:can't open file '/root/.subversion/servers':permission denied
>
> i have tried after giving rights to the file also, but even than i  
> am getting the same error.

I figured it would be some error like that. The svn command needs to  
read data out of the .subversion directory in the current user's home  
directory. When running under your web server, it thinks /root is its  
home, but your web server is not running as root; it's probably  
running as www or apache or nobody. Those users probably don't have  
permission to read things in /root. One option might be to tell the  
svn command where its home is, e.g.

<?php
$cmd = 'HOME=/some/place /usr/bin/svn list file:///var/subversion/
devfoundry/ 2>&1';
?>

where /some/place is a directory the web server user can read and  
write, so that svn can create the .subversion directory there.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: problem in running svn command through php on CentOS

by Ryan Schmidt-23 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Dec 25, 2007, at 23:34, Ryan Schmidt wrote:

> On Dec 25, 2007, at 23:27, pinky goyal wrote:
>
>> On 12/20/07, Ryan Schmidt wrote:
>>
>>> <?php
>>> $cmd = '/usr/bin/svn list file:///var/subversion/devfoundry/ 2>&1';
>>> exec($cmd, $output);
>>> $output = implode("\n", $output) . "\n";
>>> echo $output;
>>> ?>
>>
>> thnx for the reply.
>>
>> i have tried this and now what error i am getting is.
>>
>> svn:can't open file '/root/.subversion/servers':permission denied
>>
>> i have tried after giving rights to the file also, but even than i  
>> am getting the same error.
>
> I figured it would be some error like that. The svn command needs  
> to read data out of the .subversion directory in the current user's  
> home directory. When running under your web server, it thinks /root  
> is its home, but your web server is not running as root; it's  
> probably running as www or apache or nobody. Those users probably  
> don't have permission to read things in /root. One option might be  
> to tell the svn command where its home is, e.g.
>
> <?php
> $cmd = 'HOME=/some/place /usr/bin/svn list file:///var/subversion/
> devfoundry/ 2>&1';
> ?>
>
> where /some/place is a directory the web server user can read and  
> write, so that svn can create the .subversion directory there.

I forgot svn offers a more direct switch you can use:

<?php
$cmd = '/usr/bin/svn list --config-dir /some/place file:///var/
subversion/devfoundry/ 2>&1';
?>

That would be better.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: problem in running svn command through php on CentOS

by pinky goyal-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thnx for the help.....
the issue was that you have suggested.
again thnx a lot.
 
On 12/26/07, Ryan Schmidt <subversion-2007b@...> wrote:
On Dec 25, 2007, at 23:34, Ryan Schmidt wrote:

> On Dec 25, 2007, at 23:27, pinky goyal wrote:
>

>> On 12/20/07, Ryan Schmidt wrote:
>>
>>> <?php
>>> $cmd = '/usr/bin/svn list file:///var/subversion/devfoundry/ 2>&1';
>>> exec($cmd, $output);
>>> $output = implode("\n", $output) . "\n";
>>> echo $output;
>>> ?>
>>
>> thnx for the reply.
>>
>> i have tried this and now what error i am getting is.
>>
>> svn:can't open file '/root/.subversion/servers':permission denied
>>
>> i have tried after giving rights to the file also, but even than i
>> am getting the same error.
>
> I figured it would be some error like that. The svn command needs
> to read data out of the .subversion directory in the current user's
> home directory. When running under your web server, it thinks /root
> is its home, but your web server is not running as root; it's
> probably running as www or apache or nobody. Those users probably
> don't have permission to read things in /root. One option might be
> to tell the svn command where its home is, e.g.
>
> <?php
> $cmd = 'HOME=/some/place /usr/bin/svn list file:///var/subversion/
> devfoundry/ 2>&1';
> ?>
>
> where /some/place is a directory the web server user can read and
> write, so that svn can create the .subversion directory there.

I forgot svn offers a more direct switch you can use:

<?php
$cmd = '/usr/bin/svn list --config-dir /some/place file:///var/
subversion/devfoundry/ 2>&1';
?>

That would be better.



Re: problem in running svn command through php on CentOS

by pinky goyal-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
 
i am able to get the command run if give the execute rights to the /root folder but giving rights to whole root folder is a big security issue.
and .subversion/servers exists in root folder.
 
$cmd = '/usr/bin/svn list --config-dir /some/place file:///var/
subversion/devfoundry/ 2>&1';
 
according to you by this --config-dir /some/place in the command, svn will create .subversion directory in the specified directory but this .subversion directory exists in root folders. and command don't create it in the specified directory.
 
giving the execute rights to .subversion instead of root folder doesn't solve the problem.
 
 
On 12/26/07, pinky goyal <pinks.forums@...> wrote:
Thnx for the help.....
the issue was that you have suggested.
again thnx a lot.
 
On 12/26/07, Ryan Schmidt <subversion-2007b@...> wrote:
On Dec 25, 2007, at 23:34, Ryan Schmidt wrote:

> On Dec 25, 2007, at 23:27, pinky goyal wrote:
>

>> On 12/20/07, Ryan Schmidt wrote:
>>
>>> <?php
>>> $cmd = '/usr/bin/svn list file:///var/subversion/devfoundry/ 2>&1';
>>> exec($cmd, $output);
>>> $output = implode("\n", $output) . "\n";
>>> echo $output;
>>> ?>
>>
>> thnx for the reply.
>>
>> i have tried this and now what error i am getting is.
>>
>> svn:can't open file '/root/.subversion/servers':permission denied
>>
>> i have tried after giving rights to the file also, but even than i
>> am getting the same error.
>
> I figured it would be some error like that. The svn command needs
> to read data out of the .subversion directory in the current user's
> home directory. When running under your web server, it thinks /root
> is its home, but your web server is not running as root; it's
> probably running as www or apache or nobody. Those users probably
> don't have permission to read things in /root. One option might be
> to tell the svn command where its home is, e.g.
>
> <?php
> $cmd = 'HOME=/some/place /usr/bin/svn list file:///var/subversion/
> devfoundry/ 2>&1';
> ?>
>
> where /some/place is a directory the web server user can read and
> write, so that svn can create the .subversion directory there.

I forgot svn offers a more direct switch you can use:

<?php
$cmd = '/usr/bin/svn list --config-dir /some/place file:///var/
subversion/devfoundry/ 2>&1';
?>

That would be better.




Re: problem in running svn command through php on CentOS

by Ryan Schmidt-23 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Dec 26, 2007, at 08:07, pinky goyal wrote:

> On 12/26/07, pinky goyal wrote:
>
>> On 12/26/07, Ryan Schmidt wrote:
>>
>>> On Dec 25, 2007, at 23:34, Ryan Schmidt wrote:
>>>
>>> > On Dec 25, 2007, at 23:27, pinky goyal wrote:
>>> >
>>> >> On 12/20/07, Ryan Schmidt wrote:
>>> >>
>>> >>> <?php
>>> >>> $cmd = '/usr/bin/svn list file:///var/subversion/devfoundry/  
>>> 2>&1';
>>> >>> exec($cmd, $output);
>>> >>> $output = implode("\n", $output) . "\n";
>>> >>> echo $output;
>>> >>> ?>
>>> >>
>>> >> thnx for the reply.
>>> >>
>>> >> i have tried this and now what error i am getting is.
>>> >>
>>> >> svn:can't open file '/root/.subversion/servers':permission denied
>>> >>
>>> >> i have tried after giving rights to the file also, but even  
>>> than i
>>> >> am getting the same error.
>>> >
>>> > I figured it would be some error like that. The svn command needs
>>> > to read data out of the .subversion directory in the current  
>>> user's
>>> > home directory. When running under your web server, it thinks /
>>> root
>>> > is its home, but your web server is not running as root; it's
>>> > probably running as www or apache or nobody. Those users probably
>>> > don't have permission to read things in /root. One option might be
>>> > to tell the svn command where its home is, e.g.
>>> >
>>> > <?php
>>> > $cmd = 'HOME=/some/place /usr/bin/svn list file:///var/subversion/
>>> > devfoundry/ 2>&1';
>>> > ?>
>>> >
>>> > where /some/place is a directory the web server user can read and
>>> > write, so that svn can create the .subversion directory there.
>>>
>>> I forgot svn offers a more direct switch you can use:
>>>
>>> <?php
>>> $cmd = '/usr/bin/svn list --config-dir /some/place file:///var/
>>> subversion/devfoundry/ 2>&1';
>>> ?>
>>>
>>> That would be better.
>>
>> Thnx for the help.....
>> the issue was that you have suggested.
>> again thnx a lot.
>
> i am able to get the command run if give the execute rights to the /
> root folder but giving rights to whole root folder is a big  
> security issue.
> and .subversion/servers exists in root folder.
>
> $cmd = '/usr/bin/svn list --config-dir /some/place file:///var/
> subversion/devfoundry/ 2>&1';
>
> according to you by this --config-dir /some/place in the command,  
> svn will create .subversion directory in the specified directory  
> but this .subversion directory exists in root folders. and command  
> don't create it in the specified directory.
>
> giving the execute rights to .subversion instead of root folder  
> doesn't solve the problem.

Well, actually, if you use --config-dir /some/place, Subversion will  
use /some/place as the config directory (it won't create  
a .subversion directory inside it and then use that as the config  
directory).

Here, look:

$ mkdir /tmp/mysvnconfig
$ ls -l /tmp/mysvnconfig
$ svn list --config-dir /tmp/mysvnconfig http://svn.collab.net/repos/ 
svn/
README
branches/
developer-resources/
svn-logos/
tags/
trunk/
$ ls -l /tmp/mysvnconfig
total 0
drwx------   5 rschmidt  wheel  170 Dec 26 08:16 auth
$

So, you're right, you don't want to open up /root or /
root/.subversion so everyone can write to it. That would indeed be a  
security issue. Instead, you should have a new directory somewhere,  
which only the web user can read from and write to, and point svn to  
that directory using --config-dir.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...