Jelajahi Sumber

merged branch dlsniper/openbasedir-enhancement (PR #1326)

Commits
-------

e718474 fixed CS and unsude variable (PR #1319)
b552354 Executable Finder will now try to match if a file is already in the open_basedir list before searching it thru that list

Discussion
----------

open_basedir exhancements for Executable Finder

I've made the some changed to the Executable Finder in order to handle the open_basedir ability to specify files in the list not just directories.

This should fix symfony/symfony#1319

Hope I didn't made any CS violations.
Fabien Potencier 14 tahun lalu
induk
melakukan
a29bdfef28
1 mengubah file dengan 17 tambahan dan 1 penghapusan
  1. 17 1
      src/Symfony/Component/Process/ExecutableFinder.php

+ 17 - 1
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 ($file == $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) {