diff --git a/lib/private/helper.php b/lib/private/helper.php index 9d7e86658b..c5fcd27f2b 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -2,29 +2,28 @@ /** * @author Arthur Schiwon * @author Bart Visscher - * @author Björn Schießle - * @author Christopher Schäpers + * @author Björn Schießle + * @author Christopher Schäpers * @author Fabian Henze * @author Felix Moeller - * @author François Kubler + * @author François Kubler * @author Frank Karlitschek * @author Georg Ehrke - * @author Georg Ehrke * @author Jakob Sack * @author Jan-Christoph Borchardt * @author Joas Schilling - * @author Jörn Friedrich Dreyer + * @author Jörn Friedrich Dreyer * @author Lukas Reschke * @author Michael Gapczynski * @author Morris Jobke - * @author Olivier Paroz + * @author Olivier Paroz * @author Owen Winkler * @author Pellaeon Lin * @author Robin Appelman * @author Robin McCorkell * @author Roeland Jago Douma - * @author Simon Könnecke - * @author Thomas Müller + * @author Simon Könnecke + * @author Thomas Müller * @author Thomas Tanghus * @author Valerio Ponte * @author Vincent Petry @@ -45,6 +44,7 @@ * along with this program. If not, see * */ +use Symfony\Component\Process\ExecutableFinder; /** * Collection of useful functions @@ -926,9 +926,16 @@ class OC_Helper { } $result = null; if (!\OC_Util::runningOnWindows() && self::is_function_enabled('exec')) { - exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode); - if ($returnCode === 0 && count($output) > 0) { - $result = escapeshellcmd($output[0]); + $exeSniffer = new ExecutableFinder(); + // Returns null if nothing is found + $result = $exeSniffer->find($program); + if (empty($result)) { + $paths = str_replace(':','/ ',getenv('PATH')); + $command = 'find ' . $paths . ' -name ' . escapeshellarg($program) . ' 2> /dev/null'; + exec($command, $output, $returnCode); + if (count($output) > 0) { + $result = escapeshellcmd($output[0]); + } } } $memcache->set($program, $result, 3600);