From b55235441475aef4964933a45275b41b11df083a Mon Sep 17 00:00:00 2001 From: Florin Patan Date: Tue, 14 Jun 2011 13:36:01 -0400 Subject: [PATCH 1/2] Executable Finder will now try to match if a file is already in the open_basedir list before searching it thru that list --- .../Component/Process/ExecutableFinder.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index 0c2066f79e..c6de5b7050 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -41,7 +41,23 @@ class ExecutableFinder */ public function find($name, $default = null) { - $dirs = explode(PATH_SEPARATOR, ini_get('open_basedir') ? ini_get('open_basedir') : (getenv('PATH') ? getenv('PATH') : getenv('Path'))); + if (ini_get('open_basedir')) { + $searchPath = explode(PATH_SEPARATOR, getenv('open_basedir')); + $dirs = array(); + foreach($searchPath as $path) { + if (is_dir($path)) { + $dirs[] = $path; + } else { + $file = str_replace(dirname($path), '', $path); + if($path == $name && is_executable($path)) { + return $path; + } + } + } + } else { + $dirs = explode(PATH_SEPARATOR, getenv('PATH') ? getenv('PATH') : getenv('Path')); + } + $suffixes = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : $this->suffixes) : array(''); foreach ($suffixes as $suffix) { foreach ($dirs as $dir) { From e7184748731d6469b9d9c0db1464b72ae3400bc1 Mon Sep 17 00:00:00 2001 From: Florin Patan Date: Tue, 14 Jun 2011 14:05:40 -0400 Subject: [PATCH 2/2] fixed CS and unsude variable (PR #1319) --- src/Symfony/Component/Process/ExecutableFinder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index c6de5b7050..2467b7592d 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -44,12 +44,12 @@ class ExecutableFinder if (ini_get('open_basedir')) { $searchPath = explode(PATH_SEPARATOR, getenv('open_basedir')); $dirs = array(); - foreach($searchPath as $path) { + foreach ($searchPath as $path) { if (is_dir($path)) { $dirs[] = $path; } else { $file = str_replace(dirname($path), '', $path); - if($path == $name && is_executable($path)) { + if ($file == $name && is_executable($path)) { return $path; } }