From 02eb765a9c45fef7a925401381500d680d35d9af Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 19 Jul 2014 17:29:08 -0600 Subject: [PATCH 1/3] [Process] Fixes issue #11421 --- src/Symfony/Component/Process/ExecutableFinder.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index 44f1605fa9..6ae74dca17 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -59,8 +59,7 @@ class ExecutableFinder if (is_dir($path)) { $dirs[] = $path; } else { - $file = str_replace(dirname($path), '', $path); - if ($file == $name && is_executable($path)) { + if (basename($path) == $name && is_executable($path)) { return $path; } } From 9f4313cf6f550d829e761e1add5ee8f74f5861a6 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 19 Jul 2014 17:48:53 -0600 Subject: [PATCH 2/3] [Process] Add test to verify fix for issue #11421 --- .../Process/Tests/ExecutableFinderTest.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index e728c0ee73..0a905e946c 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -110,6 +110,27 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase $this->assertSamePath(PHP_BINARY, $result); } + public function testFindProcessInOpenBasedir() + { + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + + if (!defined('PHP_BINARY')) { + $this->markTestSkipped('Requires the PHP_BINARY constant'); + } + + $execPath = __DIR__.DIRECTORY_SEPARATOR.'SignalListener.php'; + + $this->setPath(''); + ini_set('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/'); + + $finder = new ExecutableFinder; + $result = $finder->find($this->getPhpBinaryName(), false); + + $this->assertSamePath(PHP_BINARY, $result); + } + private function assertSamePath($expected, $tested) { if (defined('PHP_WINDOWS_VERSION_BUILD')) { From 4cf50e8d3036664d51efb7709e770d209358cd2b Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 20 Jul 2014 22:50:55 -0600 Subject: [PATCH 3/3] Bring code into standard --- src/Symfony/Component/Process/Tests/ExecutableFinderTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index 0a905e946c..3b5bff26e9 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -120,12 +120,12 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('Requires the PHP_BINARY constant'); } - $execPath = __DIR__.DIRECTORY_SEPARATOR.'SignalListener.php'; + $execPath = __DIR__.'/SignalListener.php'; $this->setPath(''); ini_set('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/'); - $finder = new ExecutableFinder; + $finder = new ExecutableFinder(); $result = $finder->find($this->getPhpBinaryName(), false); $this->assertSamePath(PHP_BINARY, $result);