开发者

PHP: Using SVN subcommands and options in exec() causes "segmentation fault"?

开发者 https://www.devze.com 2022-12-12 07:34 出处:网络
There is something that drives me nuts these days since I cannot continue my work on a project. I\'ve switched to another computer and can\'t get PHP and svn executable to work together nicely :)

There is something that drives me nuts these days since I cannot continue my work on a project. I've switched to another computer and can't get PHP and svn executable to work together nicely :)

$output = "";  
$value = "";  
exec("/opt/subversion/bin/svn info --username something --password something --non-interactive <REPO_URL> 2>&1", $output, $value);  

var_dump($output);  
var_dump($value);

Output:

array(0) { } int(139)

139 = Segmentation fault, but it doesn't help much since I have no clue what could be causing it. Running the same piece of code directly in terminal w开发者_如何学运维orks like a charm, but it's an issue if PHP tries to do the same via exec().

If I strip out the authentication, I get the correct output (request for authentication).

Chmod-ing Subversion executable to 777 doesn't seem to make any difference.

If it's of any use, it's Mac OS X 10.5.8, PHP 5.2.11 and Apache 2.2.13


exec() doesn't work with the < and > redirection operators: those are functions of a shell. The easy workaround is to call system() instead.


I also had similar problems after moving my PHP app from a Windows server to UNIX. More specifically, several of the svn command I was running via shell_exec() returned null output.

In my case, the problem was related to the UNIX permissions of the .svn directory and contained files. My svn checkout was owned by a standard user account. But when the PHP script (via the Apache process) ran the shell_exec() command it did so using a different account (nobody:nobody) which did not have write-access to the .svn directory and important files therein (such as the .lock file).

The solution for me was to use the chown command to make the .svn directories/files owned by the same group as the Apache process (chown -R :nobody .svn).


A couple of questions:

  1. What is the exact php you're using for the "strip out the authentication" code?

  2. Does your username or password contain any "funny" characters that could confuse the shell or php? (quotes, backticks, etc.)

0

精彩评论

暂无评论...
验证码 换一张
取 消