Fixed issue 119, no environment for the shell_exec and exec calls.

For each call exec or shell_exec, I have added the ability to prepend a
string. For example '/usr/bin/env -i '.
This commit is contained in:
Loic d'Anterroches 2009-01-29 20:29:45 +01:00
parent 6724238616
commit 6153cd0b13
8 changed files with 20 additions and 5 deletions

View File

@ -191,7 +191,8 @@ class IDF_Plugin_SyncGit_Serve
public function initRepository($fullpath)
{
mkdir($fullpath, 0750, true);
exec(sprintf('git --git-dir=%s init', escapeshellarg($fullpath)),
exec(sprintf(Pluf::f('idf_exec_cmd_prefix', '').
'git --git-dir=%s init', escapeshellarg($fullpath)),
$out, $res);
if ($res != 0) {
throw new Exception(sprintf('Init repository error, exit status %d.', $res));

View File

@ -79,6 +79,7 @@ class IDF_Plugin_SyncMercurial
$output = array();
$cmd = sprintf('hg init %s',
escapeshellarg($mercurial_path.'/'.$shortname));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$ll = exec($cmd, $output, $return);
return ($return == 0);
}

View File

@ -79,6 +79,7 @@ class IDF_Plugin_SyncSvn
$output = array();
$cmd = sprintf('svnadmin create %s',
escapeshellarg($svn_path.'/'.$shortname));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$ll = exec($cmd, $output, $return);
return ($return == 0);
}

View File

@ -52,6 +52,7 @@ class IDF_Scm
*/
public static function exec($command, &$output=array(), &$return=0)
{
$command = Pluf::f('idf_exec_cmd_prefix', '').$command;
$key = md5($command);
$cache = Pluf_Cache::factory();
if (null === ($res=$cache->get($key))) {
@ -74,6 +75,7 @@ class IDF_Scm
*/
public static function shell_exec($command)
{
$command = Pluf::f('idf_exec_cmd_prefix', '').$command;
$key = md5($command);
$cache = Pluf_Cache::factory();
if (null === ($res=$cache->get($key))) {

View File

@ -235,7 +235,8 @@ class IDF_Scm_Git
*/
public function getBlob($request_file_info, $dummy=null)
{
return shell_exec(sprintf('GIT_DIR=%s git cat-file blob %s',
return shell_exec(sprintf(Pluf::f('idf_exec_cmd_prefix', '').
'GIT_DIR=%s git cat-file blob %s',
escapeshellarg($this->repo),
escapeshellarg($request_file_info->hash)));
}
@ -410,7 +411,8 @@ class IDF_Scm_Git
*/
public function getArchiveCommand($commit, $prefix='git-repo-dump/')
{
return sprintf('GIT_DIR=%s git archive --format=zip --prefix=%s %s',
return sprintf(Pluf::f('idf_exec_cmd_prefix', '').
'GIT_DIR=%s git archive --format=zip --prefix=%s %s',
escapeshellarg($this->repo),
escapeshellarg($prefix),
escapeshellarg($commit));

View File

@ -398,7 +398,8 @@ class IDF_Scm_Mercurial
*/
public function getArchiveCommand($commit, $prefix='')
{
return sprintf('hg archive --type=zip -R %s -r %s -',
return sprintf(Pluf::f('idf_exec_cmd_prefix', '').
'hg archive --type=zip -R %s -r %s -',
escapeshellarg($this->repo),
escapeshellarg($commit));
}

View File

@ -369,7 +369,7 @@ class IDF_Scm_Svn
*/
public function getArchiveCommand($commit, $prefix='git-repo-dump/')
{
throw new Exception(('Unsupported feature.'));
throw new Exception('Unsupported feature.');
}

View File

@ -201,4 +201,11 @@ $cfg['allowed_scm'] = array('git' => 'IDF_Scm_Git',
# Extra text files when displaying source
# $cfg['idf_extra_text_ext'] = 'ext1 ext2 ext3';
# If you can execute the shell commands executed to get info
# from the scm with the user of your PHP process but it is
# not working from within PHP, this can be due to the environment
# variables not being set correctly. Note the trailing space.
# $cfg['idf_exec_cmd_prefix'] = '/usr/bin/env -i ';
return $cfg;